Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- UV: Fix fatal parse error on uv.lock files containing editable/workspace packages with dynamic versions ([#1682](https://github.com/fossas/fossa-cli/pull/1682))
- Gradle: Add additional development and test configurations for common plugins ([#1684](https://github.com/fossas/fossa-cli/pull/1684))

## 3.16.7

Expand Down
7 changes: 7 additions & 0 deletions docs/references/strategies/languages/gradle/gradle.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,17 @@ With newer versions of gradle, some configurations are no longer supported (`com
FOSSA classifies any dependencies originating from the following configurations as development dependencies:
```
- compileOnly
- spotbugs
- spotbugsPlugins
- spotbugsSlf4j
```

FOSSA classifies any dependencies originating from the following configurations as test dependencies:
```
- aggregateCodeCoverageReportResults
- jacocoAgent
- jacocoAggregation
- jacocoAnt
- testImplementation
- testCompileOnly
- testRuntimeOnly
Expand Down
16 changes: 14 additions & 2 deletions src/Strategy/Gradle/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ getLinesWithPrefix text prefix = prefixLines
configNameToLabel :: Text -> GradleLabel
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
Comment on lines 40 to 46
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.


knownTestConfigs :: [Text]
knownTestConfigs =
[ "testImplementation"
[ "aggregateCodeCoverageReportResults"
, "jacocoAgent"
, "jacocoAggregation"
, "jacocoAnt"
Comment on lines +50 to +53
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.

, "testImplementation"
, "testCompileOnly"
, "testRuntimeOnly"
, "testCompileClasspath"
Expand All @@ -61,6 +65,14 @@ knownTestConfigs =
, "testFixturesApiElements"
]

knownDevConfigs :: [Text]
knownDevConfigs =
[ "compileOnly"
, "spotbugs"
, "spotbugsPlugins"
, "spotbugsSlf4j"
]

getDebugMessages :: Text -> [Text]
getDebugMessages text = getLogWithPrefix text "FOSSA-DEBUG"

Expand Down
Loading