Skip to content

Conversation

@andrzej-janczak
Copy link
Contributor

@andrzej-janczak andrzej-janczak commented Apr 1, 2025

tested locally ✅

❯ go run cli-v2.go analyze --tool pmd --rulesets ./tools/testdata/repositories/pmd/pmd-ruleset.xml
Running original CLI functionality...
2025/04/01 16:57:53 Running pmd...
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r <file> to output the report to a file instead.
[WARN] Removed misconfigured rule: LoosePackageCoupling cause: No packages or classes specified
[WARN] This analysis could be faster, please consider using Incremental Analysis: https://docs.pmd-code.org/pmd-doc-7.12.0/pmd_userdocs_incremental_analysis.html
/Users/czak/GIT/codacy/codacy-cli-v2/tools/testdata/repositories/pmd/RulesBreaker.java:15:      AtLeastOneConstructor:  Each class should declare at least one constructor
/Users/czak/GIT/codacy/codacy-cli-v2/tools/testdata/repositories/pmd/RulesBreaker.java:18:      UnusedPrivateField:     Avoid unused private fields such as 'x'.
/Users/czak/GIT/codacy/codacy-cli-v2/tools/testdata/repositories/pmd/RulesBreaker.java:18:      ShortVariable:  Avoid variables with short names like x
/Users/czak/GIT/codacy/codacy-cli-v2/tools/testdata/repositories/pmd/RulesBreaker.java:18:      CommentRequired:        Field comments are required
LoosePackageCoupling    -       No packages or classes specified

@codacy-production
Copy link

codacy-production bot commented Apr 1, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.86% 48.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (557ff3d) 1749 460 26.30%
Head commit (7264dcd) 1819 (+70) 494 (+34) 27.16% (+0.86%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#48) 75 36 48.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

)

func DownloadFile(url string, destDir string) (string, error) {
log.Printf("Attempting to download from URL: %s", url)
Copy link
Contributor Author

@andrzej-janczak andrzej-janczak Apr 1, 2025

Choose a reason for hiding this comment

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

AI added some logs which is generally fine, but in next PR I want to add some --verbose flag
cause client do not need this, but for us while we develop it can be helpful
or maybe better --debug flag

@andrzej-janczak andrzej-janczak requested a review from Copilot April 1, 2025 15:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for PMD analysis in the Codacy CLI by introducing new functionality and integrating PMD into relevant workflows and test suites. Key changes include:

  • Enhancements to the download process with additional logging and improved HTTP request handling.
  • New PMD integration via the addition of PMD-specific flags, analysis functions, and configuration files.
  • Updates to plugin utilities to handle dynamic binary paths and updates to test files to cover PMD analysis.

Reviewed Changes

Copilot reviewed 8 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
utils/download.go Adds logging messages and implements file existence check logic
tools/testdata/repositories/pmd/RulesBreaker.java Test data file intentionally violating PMD rules
tools/pmdRunner_test.go Introduces tests for PMD runner functionality
tools/pmdRunner.go Implements PMD runner with proper exit code handling
plugins/tools/pmd/plugin.yaml Defines the PMD plugin configuration
plugins/tool-utils.go Adjusts binary path templating logic in plugin utilities
cmd/analyze.go Adds PMD as an analysis option and related command-line flag
.codacy/codacy.yaml Updates Codacy configuration to include PMD
Files not reviewed (3)
  • .cursor/rules/cursor.mdc: Language not supported
  • tools/testdata/repositories/pmd/expected.sarif: Language not supported
  • tools/testdata/repositories/pmd/pmd-ruleset.xml: Language not supported
Comments suppressed due to low confidence (1)

utils/download.go:24

  • The file existence check using os.IsExist may be incorrect. Instead, consider using 'if errInfo == nil' to verify that the file exists.
if errInfo != nil && os.IsExist(errInfo) {

Copy link
Contributor

@zhamborova zhamborova left a comment

Choose a reason for hiding this comment

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

lgtm

@andrzej-janczak andrzej-janczak merged commit 8bc9720 into main Apr 2, 2025
8 checks passed
@alerizzo alerizzo deleted the feature/pmd branch June 3, 2025 09:45
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