Skip to content

Gradle: Add additional development and test configurations for common plugins#1685

Merged
zlav merged 5 commits intomasterfrom
gradle-dev-test-configs
Apr 8, 2026
Merged

Gradle: Add additional development and test configurations for common plugins#1685
zlav merged 5 commits intomasterfrom
gradle-dev-test-configs

Conversation

@zlav
Copy link
Copy Markdown
Member

@zlav zlav commented Apr 8, 2026

Overview

Classifies several Gradle configurations from the SpotBugs and JaCoCo plugins as development-only or test-only, reducing false-positive security alerts on dependencies that never ship to production.

This is a re-push of #1684 from a branch on the main repo so that CI can run (the original PR was from a first-time contributor and CI was gated).

Original PR: #1684 by @jeffalder
Original commits preserved with their authorship.

Changes:

  • New dev configs: spotbugs, spotbugsPlugins, spotbugsSlf4j
  • New test configs: aggregateCodeCoverageReportResults, jacocoAgent, jacocoAggregation, jacocoAnt
  • Refactored configNameToLabel to use a list lookup for dev configs (mirroring the existing pattern for test configs)
  • Updated docs and changelog

Acceptance criteria

When users run fossa analyze on a Gradle project with the SpotBugs or JaCoCo plugins applied, dependencies from those configurations should no longer surface as production security alerts.

Testing plan

  • Existing Gradle integration tests cover the modified configNameToLabel branches
  • The change is purely declarative (adding entries to two lists), so no new unit tests added
  • Configuration names verified against official Gradle, SpotBugs, and JaCoCo plugin documentation

Risks

Minimal -- additive change to two known-config lists. Worst case: a user who currently sees these deps as EnvOther in their FOSSA results will stop seeing them.

Metrics

N/A

References

Checklist

  • I added tests for this PR's change (or explained in the PR description why tests don't make sense).
  • If this PR introduced a user-visible change, I added documentation into docs/.
  • If this change is externally visible, I updated Changelog.md. If this PR did not mark a release, I added my changes into an ## Unreleased section at the top.
  • If I made changes to .fossa.yml or fossa-deps.{json.yml}, I updated docs/references/files/*.schema.json AND I have updated example files used by fossa init command.
    • N/A
  • If I made changes to a subcommand's options, I updated docs/references/subcommands/<subcommand>.md.
    • N/A

@zlav zlav requested a review from a team as a code owner April 8, 2026 18:54
@zlav zlav requested a review from csasarak April 8, 2026 18:54
@zlav zlav mentioned this pull request Apr 8, 2026
3 tasks
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

Walkthrough

This pull request enhances Gradle configuration mapping to classify additional plugin-related configurations as development or test dependencies. The implementation refactors configNameToLabel to use lookup lists (knownDevConfigs and knownTestConfigs) instead of direct pattern matching. New development configurations include SpotBugs-related entries, while test configurations expand to include Jacoco and code coverage entries. Documentation and changelog entries are updated accordingly.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding Gradle configurations for SpotBugs and JaCoCo plugins to the development and test classification system.
Description check ✅ Passed The description covers all required template sections with detailed information: overview with intent, acceptance criteria, testing plan, risks, references, and a complete checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/references/strategies/languages/gradle/gradle.md (1)

244-255: ⚠️ Potential issue | 🟡 Minor

Test configuration docs are now partially updated but still incomplete.
The list omits testFixtures* configurations that are still classified as test in src/Strategy/Gradle/Common.hs (Lines 59-66). Please either document all supported configs or explicitly label this as a non-exhaustive subset.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/references/strategies/languages/gradle/gradle.md` around lines 244 -
255, The docs list of test configurations in gradle.md is incomplete because the
code in src/Strategy/Gradle/Common.hs still treats testFixtures* configurations
as test deps; update the docs to either add the missing testFixtures entries
(e.g., testFixturesImplementation, testFixturesCompileOnly,
testFixturesRuntimeOnly, testFixturesCompileClasspath,
testFixturesRuntimeClasspath) to the enumerated list (the same list that
currently shows testImplementation, testCompileOnly, testRuntimeOnly,
testCompileClasspath, testRuntimeClasspath, etc.) or explicitly mark the section
as a non-exhaustive subset and point readers to the canonical source in
Common.hs that defines the full classification.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Strategy/Gradle/Common.hs`:
- Around line 50-53: Add explicit unit tests verifying that each new config-name
string literal (e.g., "aggregateCodeCoverageReportResults", "jacocoAgent",
"jacocoAggregation", "jacocoAnt" and the similar literals at lines 68-74) is
classified to the intended environment rather than falling through to EnvOther;
locate the classification function in Common.hs (e.g., the mapping or function
that returns EnvOther) and write tests that call that classifier with each
literal and assert the expected non-EnvOther value, including negative tests to
ensure typos would fail.
- Around line 40-46: Replace the match-guard form in configNameToLabel with an
explicit if/then/else chain that evaluates the same predicates in order: check x
`elem` knownDevConfigs, then x `elem` knownTestConfigs, then
isDefaultAndroidDevConfig x, then isDefaultAndroidTestConfig x, and finally
default to Env (EnvOther x); return EnvDevelopment/EnvTesting or EnvOther
accordingly, preserving the same semantics and using the existing symbols
(knownDevConfigs, knownTestConfigs, isDefaultAndroidDevConfig,
isDefaultAndroidTestConfig, Env, EnvDevelopment, EnvTesting, EnvOther) to locate
the code to change.

---

Outside diff comments:
In `@docs/references/strategies/languages/gradle/gradle.md`:
- Around line 244-255: The docs list of test configurations in gradle.md is
incomplete because the code in src/Strategy/Gradle/Common.hs still treats
testFixtures* configurations as test deps; update the docs to either add the
missing testFixtures entries (e.g., testFixturesImplementation,
testFixturesCompileOnly, testFixturesRuntimeOnly, testFixturesCompileClasspath,
testFixturesRuntimeClasspath) to the enumerated list (the same list that
currently shows testImplementation, testCompileOnly, testRuntimeOnly,
testCompileClasspath, testRuntimeClasspath, etc.) or explicitly mark the section
as a non-exhaustive subset and point readers to the canonical source in
Common.hs that defines the full classification.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: bcd95f74-54b7-4868-975d-56b8b055cf51

📥 Commits

Reviewing files that changed from the base of the PR and between 4762c78 and ce9fe8f.

📒 Files selected for processing (3)
  • Changelog.md
  • docs/references/strategies/languages/gradle/gradle.md
  • src/Strategy/Gradle/Common.hs

Comment on lines 40 to 46
configNameToLabel conf =
case conf of
"compileOnly" -> Env EnvDevelopment
x | x `elem` knownDevConfigs -> Env EnvDevelopment
x | x `elem` knownTestConfigs -> Env EnvTesting
x | isDefaultAndroidDevConfig x -> Env EnvDevelopment
x | isDefaultAndroidTestConfig x -> Env EnvTesting
x -> Env $ EnvOther x
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n src/Strategy/Gradle/Common.hs | head -60

Repository: fossas/fossa-cli

Length of output: 2395


Replace match guards in configNameToLabel.

This function uses match guards (| syntax), which violates the Haskell guideline: "avoid partial functions, list comprehensions, and match guards."

Suggested refactor
 configNameToLabel :: Text -> GradleLabel
 configNameToLabel conf =
-  case conf of
-    x | x `elem` knownDevConfigs -> Env EnvDevelopment
-    x | x `elem` knownTestConfigs -> Env EnvTesting
-    x | isDefaultAndroidDevConfig x -> Env EnvDevelopment
-    x | isDefaultAndroidTestConfig x -> Env EnvTesting
-    x -> Env $ EnvOther x
+  if conf `elem` knownDevConfigs
+    then Env EnvDevelopment
+    else
+      if conf `elem` knownTestConfigs
+        then Env EnvTesting
+        else
+          if isDefaultAndroidDevConfig conf
+            then Env EnvDevelopment
+            else
+              if isDefaultAndroidTestConfig conf
+                then Env EnvTesting
+                else Env (EnvOther conf)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Strategy/Gradle/Common.hs` around lines 40 - 46, Replace the match-guard
form in configNameToLabel with an explicit if/then/else chain that evaluates the
same predicates in order: check x `elem` knownDevConfigs, then x `elem`
knownTestConfigs, then isDefaultAndroidDevConfig x, then
isDefaultAndroidTestConfig x, and finally default to Env (EnvOther x); return
EnvDevelopment/EnvTesting or EnvOther accordingly, preserving the same semantics
and using the existing symbols (knownDevConfigs, knownTestConfigs,
isDefaultAndroidDevConfig, isDefaultAndroidTestConfig, Env, EnvDevelopment,
EnvTesting, EnvOther) to locate the code to change.

Comment on lines +50 to +53
[ "aggregateCodeCoverageReportResults"
, "jacocoAgent"
, "jacocoAggregation"
, "jacocoAnt"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add explicit tests for the new config-name mappings.
These new string literals are on the classification path; a typo/regression silently falls through to EnvOther, which directly impacts alert labeling behavior.

As per coding guidelines, "Code should be thoroughly tested with appropriate unit tests".

Also applies to: 68-74

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Strategy/Gradle/Common.hs` around lines 50 - 53, Add explicit unit tests
verifying that each new config-name string literal (e.g.,
"aggregateCodeCoverageReportResults", "jacocoAgent", "jacocoAggregation",
"jacocoAnt" and the similar literals at lines 68-74) is classified to the
intended environment rather than falling through to EnvOther; locate the
classification function in Common.hs (e.g., the mapping or function that returns
EnvOther) and write tests that call that classifier with each literal and assert
the expected non-EnvOther value, including negative tests to ensure typos would
fail.

@zlav zlav enabled auto-merge (squash) April 8, 2026 19:03
@zlav zlav merged commit a97e774 into master Apr 8, 2026
19 checks passed
@zlav zlav deleted the gradle-dev-test-configs branch April 8, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants