Skip to content

Replace Gradle license analysis with jk1 for Groovy and Kotlin DSL#314

Open
woocheol-lge wants to merge 1 commit into
mainfrom
g_test
Open

Replace Gradle license analysis with jk1 for Groovy and Kotlin DSL#314
woocheol-lge wants to merge 1 commit into
mainfrom
g_test

Conversation

@woocheol-lge

@woocheol-lge woocheol-lge commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

Replace Gradle license analysis with jk1 for Groovy and Kotlin DSL

Summary by CodeRabbit

  • New Features
    • Added automatic Gradle license-report plugin injection and optional auto-run for applicable Gradle projects (non-Android).
    • Improved Kotlin DSL support by handling both build.gradle and build.gradle.kts during detection and processing.
  • Bug Fixes
    • More robust dependency/license parsing across different report formats, including improved license-name normalization and better fallback behavior when license data is missing.
    • Enhanced Gradle vs Android detection with clearer warnings when tooling can’t run.
  • Tests
    • Updated and regenerated Gradle license-report fixtures (JSON/XML/HTML) to match the new output format.

@woocheol-lge woocheol-lge self-assigned this Jun 8, 2026
@woocheol-lge woocheol-lge added the chore [PR/Issue] Refactoring, maintenance the code label Jun 8, 2026
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@woocheol-lge, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 12 minutes and 7 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 14383b39-4afe-4287-8b97-610ee1f1e407

📥 Commits

Reviewing files that changed from the base of the PR and between f0fec08 and 105abd4.

📒 Files selected for processing (11)
  • src/fosslight_dependency/_package_manager.py
  • src/fosslight_dependency/constant.py
  • src/fosslight_dependency/package_manager/Gradle.py
  • src/fosslight_dependency/run_dependency_scanner.py
  • tests/test_gradle/jib/build/reports/license/dependency-license.html
  • tests/test_gradle/jib/build/reports/license/dependency-license.json
  • tests/test_gradle/jib/build/reports/license/dependency-license.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.html
  • tests/test_gradle/jib/build/reports/license/license-dependency.json
  • tests/test_gradle/jib/build/reports/license/license-dependency.xml
  • tests/test_gradle2/build/reports/license/dependency-license.json
📝 Walkthrough

Walkthrough

Adds Kotlin DSL detection to build.gradle.kts, injects and conditionally runs the dependency-license-report plugin for Gradle projects, updates Gradle task branching and restore logic to handle both Android and Gradle platforms, and refactors license-report JSON parsing with license-name normalization.

Changes

Gradle License Report Plugin Integration

Layer / File(s) Summary
Kotlin DSL Build File Support
src/fosslight_dependency/constant.py, src/fosslight_dependency/run_dependency_scanner.py
GRADLE in SUPPORT_PACKAGE now includes both build.gradle and build.gradle.kts; find_package_manager() detects present build files and distinguishes Gradle vs Android using Groovy/Kotlin plugin keywords (java, java-library) and Android markers (android, SdkVersion).
Gradle wrapper parsing & plugin injection
src/fosslight_dependency/_package_manager.py
New get_gradle_version_from_wrapper() reads gradle-wrapper.properties and extracts version as integer tuple; new add_gradle_plugin_in_gradle() injects com.github.jk1.dependency-license-report (DSL-aware for Groovy and Kotlin), selects plugin version by Gradle version thresholds, and appends a licenseReport renderer to produce dependency-license.json.
Gradle Task Execution with Platform Branching
src/fosslight_dependency/_package_manager.py
run_gradle_task() calls plugin injection for non-Android Gradle projects, runs Android :{app}:generateLicenseTxt or Gradle generateLicenseReport via subprocess, conditions plugin_auto_run on expected output file presence, logs stderr on nonzero return codes, emits platform-specific warnings when gradlew is missing, restores Android module-level build.gradle backup in finally block, and switches exception logging to logger.warning.
New JSON Format License Parsing with License Normalization
src/fosslight_dependency/package_manager/Gradle.py
parse_oss_information() now handles top-level arrays or dicts from the plugin (moduleName/moduleVersion/moduleLicenses), builds download_location/homepage/purl from resolved Maven coordinates, sets comment for direct/transitive dependencies, and adds normalize_license_name_from_name() to canonicalize license names by trimming whitespace, stripping quotes, and removing ;link= suffixes.
Regenerated test fixture
tests/test_gradle/jib/build/reports/license/dependency-license.json
Test report replaced with the plugin-generated array schema (moduleName/moduleVersion/moduleUrls/moduleLicenses) and expanded entries.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • dd-jy
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: replacing Gradle license analysis with the jk1 plugin for both Groovy and Kotlin DSL support, which is reflected throughout the implementation changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch g_test

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/fosslight_dependency/package_manager/Gradle.py (1)

258-259: 💤 Low value

Consider using SPDX identifiers for public domain/unlicense.

"Public-Domain" is not a standard SPDX identifier. Consider:

  • Return "Unlicense" when the URL contains unlicense
  • Return "CC0-1.0" for public domain dedications where appropriate

This would improve consistency with the other SPDX-style license names returned by this function.

🔧 Suggested fix
-    if 'publicdomain' in url_lower or 'unlicense' in url_lower:
-        return "Public-Domain"
+    if 'unlicense' in url_lower:
+        return "Unlicense"
+
+    if 'publicdomain' in url_lower:
+        return "CC0-1.0"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fosslight_dependency/package_manager/Gradle.py` around lines 258 - 259,
Update the URL-to-license mapping in Gradle.py so it returns SPDX identifiers:
change the branch that checks url_lower for 'unlicense' and 'publicdomain' to
return "Unlicense" for URLs containing 'unlicense' and "CC0-1.0" for URLs
containing 'publicdomain' (replace the current "Public-Domain" return), ensuring
the conditional using url_lower is updated accordingly and any callers that
expect SPDX-style strings are left consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/fosslight_dependency/_package_manager.py`:
- Around line 311-316: The Kotlin DSL branch currently sets
output_property_access = 'outputDir' for all plugin_version values; change the
logic so that when plugin_version is v3+ (e.g., >= '3' or specifically for
'3.1.2' and above) output_property_access is set to 'absoluteOutputDir'
(matching the Groovy branch) and update the comment to reflect that v3+ uses
absoluteOutputDir (e.g., replace the misleading "v3+ might use
absoluteOutputDir" comment). Locate and modify the code that checks
plugin_version and assigns output_property_access in the Kotlin DSL path (the
variables plugin_version and output_property_access) so both Kotlin and Groovy
align on using 'absoluteOutputDir' for v3+.

In `@tests/test_gradle/jib/build/reports/license/dependency-license.json`:
- Around line 471-479: The parser in
src/fosslight_dependency/package_manager/Gradle.py (parse_oss_information) is
keeping the raw lic_name when lic_url is null, so entries like
"\"Apache-2.0\";link=\"https://...\"" survive instead of normalizing; update
parse_oss_information to detect and normalize lic_name when lic_url is missing
by stripping surrounding quotes and removing any trailing ;link="..." segment
(e.g., split on ';link=' or a regex, then strip quotes/whitespace) before using
lic_name, and also deduplicate/join moduleLicenses so oss_item.license contains
only the clean "Apache-2.0" entry rather than the combined string.

---

Nitpick comments:
In `@src/fosslight_dependency/package_manager/Gradle.py`:
- Around line 258-259: Update the URL-to-license mapping in Gradle.py so it
returns SPDX identifiers: change the branch that checks url_lower for
'unlicense' and 'publicdomain' to return "Unlicense" for URLs containing
'unlicense' and "CC0-1.0" for URLs containing 'publicdomain' (replace the
current "Public-Domain" return), ensuring the conditional using url_lower is
updated accordingly and any callers that expect SPDX-style strings are left
consistent.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d0301754-7050-4992-84cc-d74016d42204

📥 Commits

Reviewing files that changed from the base of the PR and between dbfcbb5 and ce2c543.

📒 Files selected for processing (10)
  • src/fosslight_dependency/_package_manager.py
  • src/fosslight_dependency/constant.py
  • src/fosslight_dependency/package_manager/Gradle.py
  • src/fosslight_dependency/run_dependency_scanner.py
  • tests/test_gradle/jib/build/reports/license/dependency-license.html
  • tests/test_gradle/jib/build/reports/license/dependency-license.json
  • tests/test_gradle/jib/build/reports/license/dependency-license.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.html
  • tests/test_gradle/jib/build/reports/license/license-dependency.json
  • tests/test_gradle/jib/build/reports/license/license-dependency.xml
💤 Files with no reviewable changes (5)
  • tests/test_gradle/jib/build/reports/license/license-dependency.html
  • tests/test_gradle/jib/build/reports/license/license-dependency.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.json
  • tests/test_gradle/jib/build/reports/license/dependency-license.xml
  • tests/test_gradle/jib/build/reports/license/dependency-license.html

Comment thread src/fosslight_dependency/_package_manager.py Outdated
Comment thread tests/test_gradle/jib/build/reports/license/dependency-license.json
@woocheol-lge woocheol-lge force-pushed the g_test branch 3 times, most recently from 36a12ac to f8ddbe8 Compare June 8, 2026 07:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (4)
src/fosslight_dependency/_package_manager.py (1)

517-530: 💤 Low value

Consider adding debug logging for parse failures.

The try-except-pass pattern works correctly as a fallback, but adding debug-level logging would help troubleshoot version detection issues without affecting functionality.

♻️ Proposed improvement
     try:
         with open(props_path, 'r', encoding='utf-8') as f:
             content = f.read()
         m = re.search(r'gradle-(\d+\.\d+(?:\.\d+)?)-', content)
         if m:
             return tuple(int(x) for x in m.group(1).split('.'))
-    except Exception:
-        pass
+    except Exception as e:
+        logger.debug(f"Failed to parse Gradle version from wrapper: {e}")
     return None
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fosslight_dependency/_package_manager.py` around lines 517 - 530, The
function get_gradle_version_from_wrapper swallows all exceptions and silent
parse failures; add debug logging to capture why parsing failed by obtaining a
logger (e.g., logger = logging.getLogger(__name__)) and logging both exceptions
(use logger.debug(..., exc_info=True) inside the except block) and unsuccessful
regex matches (log the props_path and a snippet or the whole content at debug
level when m is None) so you can troubleshoot version detection without changing
behavior.
src/fosslight_dependency/package_manager/Gradle.py (3)

159-163: 💤 Low value

Consider narrowing the exception catch.

The in operator on line 160 should not raise exceptions if relation_tree is a valid dict. The broad Exception catch could mask unexpected issues like relation_tree being None or a non-dict type.

♻️ Suggested refinement
             try:
                 if dep_key in self.relation_tree:
                     dep_item.depends_on_raw = self.relation_tree[dep_key]
-            except Exception as e:
+            except (KeyError, TypeError) as e:
                 logger.error(f"Fail to find dependency tree: {e}")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fosslight_dependency/package_manager/Gradle.py` around lines 159 - 163,
The broad except around checking "if dep_key in self.relation_tree" should be
narrowed and the root cause handled: ensure self.relation_tree is a mapping
before using "in" (e.g., check "if isinstance(self.relation_tree, dict)" or "if
self.relation_tree is not None and hasattr(self.relation_tree,
'__contains__')"), then set dep_item.depends_on_raw =
self.relation_tree[dep_key] only when present; replace the generic "except
Exception as e" with a specific guard or catch (e.g., TypeError or KeyError) and
update logger.error to log that specific condition referencing
self.relation_tree and dep_key so unexpected None/non-dict values aren’t
silently swallowed.

Source: Linters/SAST tools


235-239: 💤 Low value

Minor: GPL version matching could have edge cases.

The substring check 'gplv3' in url_lower could match unintended URLs like gplv32 or legplv3. Consider using word-boundary patterns or checking the full version string.

This is unlikely to cause real issues given typical license URL formats.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fosslight_dependency/package_manager/Gradle.py` around lines 235 - 239,
The current substring checks in Gradle.py (the conditions using 'gplv3' and
'gplv2' against url_lower) can produce false positives; change these to precise
matches by using a word-boundary regex or explicit URL/version patterns instead
of plain substring checks (e.g., use re.search(r'\bgplv3\b', url_lower) or match
'/gpl-3.0' and '/gpl-2.0' segments) when resolving the license in the method
that inspects url_lower so that only true GPL-3.0 and GPL-2.0 references return
"GPL-3.0" and "GPL-2.0" respectively.

271-272: Use SPDX license identifiers instead of "Public-Domain".

  • "Public-Domain" appears only in src/fosslight_dependency/package_manager/Gradle.py, so there’s no established convention to rely on.
  • "Public-Domain" isn’t a standard SPDX identifier; map the cases separately (e.g., return "Unlicense" when the URL contains unlicense, and map publicdomain to an appropriate SPDX identifier such as "CC0-1.0" or document a justified non-SPDX custom value).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fosslight_dependency/package_manager/Gradle.py` around lines 271 - 272,
Replace the non-SPDX "Public-Domain" return in the Gradle.py URL-to-license
mapping: locate the conditional that checks url_lower for 'publicdomain' or
'unlicense' and instead return SPDX identifiers—return "Unlicense" when
'unlicense' is present and return "CC0-1.0" (or another justified SPDX ID) when
'publicdomain' is present; update the conditional logic to check these cases
separately and adjust any tests/comments to reflect the SPDX identifiers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/fosslight_dependency/_package_manager.py`:
- Around line 517-530: The function get_gradle_version_from_wrapper swallows all
exceptions and silent parse failures; add debug logging to capture why parsing
failed by obtaining a logger (e.g., logger = logging.getLogger(__name__)) and
logging both exceptions (use logger.debug(..., exc_info=True) inside the except
block) and unsuccessful regex matches (log the props_path and a snippet or the
whole content at debug level when m is None) so you can troubleshoot version
detection without changing behavior.

In `@src/fosslight_dependency/package_manager/Gradle.py`:
- Around line 159-163: The broad except around checking "if dep_key in
self.relation_tree" should be narrowed and the root cause handled: ensure
self.relation_tree is a mapping before using "in" (e.g., check "if
isinstance(self.relation_tree, dict)" or "if self.relation_tree is not None and
hasattr(self.relation_tree, '__contains__')"), then set dep_item.depends_on_raw
= self.relation_tree[dep_key] only when present; replace the generic "except
Exception as e" with a specific guard or catch (e.g., TypeError or KeyError) and
update logger.error to log that specific condition referencing
self.relation_tree and dep_key so unexpected None/non-dict values aren’t
silently swallowed.
- Around line 235-239: The current substring checks in Gradle.py (the conditions
using 'gplv3' and 'gplv2' against url_lower) can produce false positives; change
these to precise matches by using a word-boundary regex or explicit URL/version
patterns instead of plain substring checks (e.g., use re.search(r'\bgplv3\b',
url_lower) or match '/gpl-3.0' and '/gpl-2.0' segments) when resolving the
license in the method that inspects url_lower so that only true GPL-3.0 and
GPL-2.0 references return "GPL-3.0" and "GPL-2.0" respectively.
- Around line 271-272: Replace the non-SPDX "Public-Domain" return in the
Gradle.py URL-to-license mapping: locate the conditional that checks url_lower
for 'publicdomain' or 'unlicense' and instead return SPDX identifiers—return
"Unlicense" when 'unlicense' is present and return "CC0-1.0" (or another
justified SPDX ID) when 'publicdomain' is present; update the conditional logic
to check these cases separately and adjust any tests/comments to reflect the
SPDX identifiers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d3f57318-b816-4e92-994f-109f0a77527e

📥 Commits

Reviewing files that changed from the base of the PR and between ce2c543 and f8ddbe8.

📒 Files selected for processing (10)
  • src/fosslight_dependency/_package_manager.py
  • src/fosslight_dependency/constant.py
  • src/fosslight_dependency/package_manager/Gradle.py
  • src/fosslight_dependency/run_dependency_scanner.py
  • tests/test_gradle/jib/build/reports/license/dependency-license.html
  • tests/test_gradle/jib/build/reports/license/dependency-license.json
  • tests/test_gradle/jib/build/reports/license/dependency-license.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.html
  • tests/test_gradle/jib/build/reports/license/license-dependency.json
  • tests/test_gradle/jib/build/reports/license/license-dependency.xml
💤 Files with no reviewable changes (5)
  • tests/test_gradle/jib/build/reports/license/license-dependency.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.json
  • tests/test_gradle/jib/build/reports/license/license-dependency.html
  • tests/test_gradle/jib/build/reports/license/dependency-license.xml
  • tests/test_gradle/jib/build/reports/license/dependency-license.html
✅ Files skipped from review due to trivial changes (1)
  • src/fosslight_dependency/constant.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_gradle/jib/build/reports/license/dependency-license.json

@woocheol-lge woocheol-lge requested a review from dd-jy June 9, 2026 05:24

@dd-jy dd-jy left a comment

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.

@woocheol-lge
license명 url 대신 name을 보거나, normalize_license_name_from_url에 들어있는 url 타입이 아닌 경우 name 보도록 수정해주시기 바랍니다.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

♻️ Duplicate comments (1)
src/fosslight_dependency/_package_manager.py (1)

301-307: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep Kotlin DSL renderer output access aligned with Groovy for jk1 v3+.

The Kotlin branch still uses data.project.licenseReport.outputDir for every plugin version, while the Groovy branch switches to absoluteOutputDir for v3+. This appears to be the same jk1 v3+ output-directory mismatch flagged previously.

🐛 Proposed fix
             plugin_id_line = f'    id("com.github.jk1.dependency-license-report") version "{plugin_version}"\n'
             output_config = '    outputDir = "$buildDir/reports/license"'
-            output_property_access = 'outputDir'
+            output_property_access = 'outputDir' if plugin_version in ('1.9', '2.9') else 'absoluteOutputDir'

Please verify against the jk1 version used by this branch:

For jk1 Gradle-License-Report 3.1.2, should custom renderers access LicenseReportExtension.outputDir or absoluteOutputDir when writing report files?
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fosslight_dependency/_package_manager.py` around lines 301 - 307, The
Kotlin DSL renderer (when is_kts is true) uses a hardcoded
output_property_access variable set to 'outputDir' for all jk1 plugin versions,
but should conditionally use 'absoluteOutputDir' for jk1 v3+ to match the
behavior already implemented in the Groovy branch. Update the assignment of
output_property_access in the is_kts block to check the plugin_version and set
it to 'absoluteOutputDir' when the version is 3 or higher, using the same
version-checking logic that the Groovy branch uses to determine when to switch
output directory access patterns.
🧹 Nitpick comments (1)
src/fosslight_dependency/package_manager/Gradle.py (1)

158-162: 💤 Low value

Consider narrowing the exception type.

The broad Exception catch (flagged by static analysis BLE001) could hide unexpected errors. Since this block only accesses self.relation_tree[dep_key], the expected failure modes are KeyError or TypeError (if relation_tree is None).

-                except Exception as e:
+                except (KeyError, TypeError) as e:

Alternatively, if broader defensive catching is intentional, this is acceptable as-is given it's non-critical logging.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fosslight_dependency/package_manager/Gradle.py` around lines 158 - 162,
The broad Exception catch in the try-except block around the relation_tree
access is flagged for being too general and could mask unexpected errors.
Replace the generic Exception with more specific exception types that match the
actual failure modes: catch KeyError for missing keys in the dictionary or
TypeError if relation_tree is None, by changing the except clause to catch these
specific exceptions instead of the blanket Exception type.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/fosslight_dependency/_package_manager.py`:
- Around line 115-118: When the Gradle plugin is added via the
add_gradle_plugin_in_gradle method and the required dependency-license.json file
is still not created afterward, the scan should be marked as failed by setting
ret_task to False instead of allowing analysis to continue. Check the return
value from add_gradle_plugin_in_gradle (in file
src/fosslight_dependency/_package_manager.py at lines 115-118, 178-184, and
190-193) and when the file still does not exist after the method executes, set
ret_task = False to properly fail the scan, since Gradle.parse_oss_information()
requires this file to exist to function correctly.
- Line 157: The subprocess.run() calls in the Gradle plugin subprocess execution
can block indefinitely due to dependency resolution, daemon startup, or network
issues. Add timeout=600 parameter to the subprocess.run() calls and implement a
separate exception handler for subprocess.TimeoutExpired to provide an
actionable error message, following the established timeout pattern already
present elsewhere in the file. Apply this same timeout and exception handling
approach to all subprocess.run() calls in the Gradle plugin section to ensure
consistent timeout protection across all dependency resolution operations.

In `@src/fosslight_dependency/package_manager/Gradle.py`:
- Around line 232-233: The string literal 'opensource.org/licenses/CDDL-1.0'
contains uppercase characters but is being compared against url_lower, which is
a lowercased URL string. Change the string literal in the condition to use
lowercase 'cddl-1.0' instead so the comparison will match correctly when the URL
contains this license pattern.
- Around line 66-70: The membership test on line 67 in the Gradle.py file uses
incorrect syntax `not lic_name.lower() in multi_license_keywords` which should
be `lic_name.lower() not in multi_license_keywords` per Python style guidelines
(E713). Additionally, the current logic only matches exact keyword strings, so
it would match "dual" but not "Dual License". To properly detect multi-license
indicators within license names, change the logic to check if any of the
keywords in multi_license_keywords appear as a substring within the lowercased
lic_name, so that longer license name strings containing these keywords are
properly identified and skipped from URL-based normalization.

---

Duplicate comments:
In `@src/fosslight_dependency/_package_manager.py`:
- Around line 301-307: The Kotlin DSL renderer (when is_kts is true) uses a
hardcoded output_property_access variable set to 'outputDir' for all jk1 plugin
versions, but should conditionally use 'absoluteOutputDir' for jk1 v3+ to match
the behavior already implemented in the Groovy branch. Update the assignment of
output_property_access in the is_kts block to check the plugin_version and set
it to 'absoluteOutputDir' when the version is 3 or higher, using the same
version-checking logic that the Groovy branch uses to determine when to switch
output directory access patterns.

---

Nitpick comments:
In `@src/fosslight_dependency/package_manager/Gradle.py`:
- Around line 158-162: The broad Exception catch in the try-except block around
the relation_tree access is flagged for being too general and could mask
unexpected errors. Replace the generic Exception with more specific exception
types that match the actual failure modes: catch KeyError for missing keys in
the dictionary or TypeError if relation_tree is None, by changing the except
clause to catch these specific exceptions instead of the blanket Exception type.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8aabba40-7160-46ee-b141-ac23fbbdf13f

📥 Commits

Reviewing files that changed from the base of the PR and between f8ddbe8 and 3ee6c67.

📒 Files selected for processing (10)
  • src/fosslight_dependency/_package_manager.py
  • src/fosslight_dependency/constant.py
  • src/fosslight_dependency/package_manager/Gradle.py
  • src/fosslight_dependency/run_dependency_scanner.py
  • tests/test_gradle/jib/build/reports/license/dependency-license.html
  • tests/test_gradle/jib/build/reports/license/dependency-license.json
  • tests/test_gradle/jib/build/reports/license/dependency-license.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.html
  • tests/test_gradle/jib/build/reports/license/license-dependency.json
  • tests/test_gradle/jib/build/reports/license/license-dependency.xml
💤 Files with no reviewable changes (5)
  • tests/test_gradle/jib/build/reports/license/dependency-license.html
  • tests/test_gradle/jib/build/reports/license/license-dependency.json
  • tests/test_gradle/jib/build/reports/license/dependency-license.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.html
✅ Files skipped from review due to trivial changes (1)
  • tests/test_gradle/jib/build/reports/license/dependency-license.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/fosslight_dependency/constant.py

Comment thread src/fosslight_dependency/_package_manager.py
Comment thread src/fosslight_dependency/_package_manager.py
Comment thread src/fosslight_dependency/package_manager/Gradle.py Outdated
Comment thread src/fosslight_dependency/package_manager/Gradle.py Outdated
@woocheol-lge woocheol-lge force-pushed the g_test branch 2 times, most recently from 9661ab0 to d6fecb5 Compare June 15, 2026 07:13
Comment thread src/fosslight_dependency/package_manager/Gradle.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/fosslight_dependency/package_manager/Gradle.py (1)

149-153: 💤 Low value

Consider more specific exception handling or a pre-check.

The broad Exception catch could mask unexpected errors. Since the code already checks dep_key in self.relation_tree, a KeyError is unlikely. The main risk is AttributeError if self.relation_tree is None.

Suggested improvement
-            try:
-                if dep_key in self.relation_tree:
-                    dep_item.depends_on_raw = self.relation_tree[dep_key]
-            except Exception as e:
-                logger.error(f"Fail to find dependency tree: {e}")
+            if self.relation_tree and dep_key in self.relation_tree:
+                dep_item.depends_on_raw = self.relation_tree[dep_key]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/fosslight_dependency/package_manager/Gradle.py` around lines 149 - 153,
The broad Exception catch in the dependency tree lookup could mask unexpected
errors. Since the code already checks if dep_key exists in self.relation_tree,
the main risk is AttributeError if self.relation_tree is None. Add a pre-check
to verify self.relation_tree is not None before attempting the dictionary check,
or replace the generic Exception catch with a specific AttributeError catch to
handle the case where self.relation_tree could be None, while still allowing
unexpected errors to surface for debugging.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/fosslight_dependency/_package_manager.py`:
- Around line 301-309: The Kotlin DSL path unconditionally sets
output_property_access to 'outputDir', but it should conditionally select
between 'outputDir' (for plugin versions 1.9 and 2.9) and 'absoluteOutputDir'
(for v3+), matching the logic already implemented in the Groovy DSL path.
Replace the unconditional assignment of output_property_access = 'outputDir' in
the if is_kts block with conditional logic that checks the plugin_version and
assigns 'outputDir' if plugin_version is in ('1.9', '2.9'), otherwise assigns
'absoluteOutputDir', so that Kotlin DSL correctly resolves the output directory
for all plugin versions.

---

Nitpick comments:
In `@src/fosslight_dependency/package_manager/Gradle.py`:
- Around line 149-153: The broad Exception catch in the dependency tree lookup
could mask unexpected errors. Since the code already checks if dep_key exists in
self.relation_tree, the main risk is AttributeError if self.relation_tree is
None. Add a pre-check to verify self.relation_tree is not None before attempting
the dictionary check, or replace the generic Exception catch with a specific
AttributeError catch to handle the case where self.relation_tree could be None,
while still allowing unexpected errors to surface for debugging.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e654cc50-04df-4268-93f1-bfcfd11558fb

📥 Commits

Reviewing files that changed from the base of the PR and between 3ee6c67 and f0fec08.

📒 Files selected for processing (10)
  • src/fosslight_dependency/_package_manager.py
  • src/fosslight_dependency/constant.py
  • src/fosslight_dependency/package_manager/Gradle.py
  • src/fosslight_dependency/run_dependency_scanner.py
  • tests/test_gradle/jib/build/reports/license/dependency-license.html
  • tests/test_gradle/jib/build/reports/license/dependency-license.json
  • tests/test_gradle/jib/build/reports/license/dependency-license.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.html
  • tests/test_gradle/jib/build/reports/license/license-dependency.json
  • tests/test_gradle/jib/build/reports/license/license-dependency.xml
💤 Files with no reviewable changes (5)
  • tests/test_gradle/jib/build/reports/license/license-dependency.json
  • tests/test_gradle/jib/build/reports/license/dependency-license.html
  • tests/test_gradle/jib/build/reports/license/dependency-license.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.xml
  • tests/test_gradle/jib/build/reports/license/license-dependency.html
✅ Files skipped from review due to trivial changes (1)
  • tests/test_gradle/jib/build/reports/license/dependency-license.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/fosslight_dependency/constant.py

Comment thread src/fosslight_dependency/_package_manager.py
… and Kotlin DSL

Signed-off-by: woocheol <jayden6659@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore [PR/Issue] Refactoring, maintenance the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants