Skip to content

Conversation

@zhamborova
Copy link
Contributor

@zhamborova zhamborova commented Apr 2, 2025

test with java repo

codacy-cli-local analyze --tool pmd --rulesets /Users/yasmin/IdeaProjects/codacy-cli-v2/tools/pmd/default-ruleset.xml -o sarif.json --format sarif

  "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
  "version": "2.1.0",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "PMD",
          "version": "6.55.0",
          "informationUri": "https://pmd.github.io/pmd/",
          "rules": [
            {
              "id": "UnusedPrivateField",
              "shortDescription": {
                "text": "Avoid unused private fields such as 'x'."
              },
              "fullDescription": {
                "text": "\nDetects when a private field is declared and/or assigned a value, but not used.\n\nSince PMD 6.50.0 private fields are ignored, if the fields are annotated with any annotation or the\nenclosing class has any annotation. Annotations often enable a framework (such as dependency injection, mocking\nor e.g. Lombok) which use the fields by reflection or other means. This usage can't be detected by static code analysis.\nPreviously these frameworks where explicitly allowed by listing their annotations in the property\n\"ignoredAnnotations\", but that turned out to be prone of false positive for any not explicitly considered framework.\n        "
              },
              "helpUri": "https://pmd.github.io/pmd-6.55.0/pmd_rules_java_bestpractices.html#unusedprivatefield",
              "help": {
                "text": "\nDetects when a private field is declared and/or assigned a value, but not used.\n\nSince PMD 6.50.0 private fields are ignored, if the fields are annotated with any annotation or the\nenclosing class has any annotation. Annotations often enable a framework (such as dependency injection, mocking\nor e.g. Lombok) which use the fields by reflection or other means. This usage can't be detected by static code analysis.\nPreviously these frameworks where explicitly allowed by listing their annotations in the property\n\"ignoredAnnotations\", but that turned out to be prone of false positive for any not explicitly considered framework.\n        "
              },
              "properties": {
                "ruleset": "Best Practices",
                "priority": 3,
                "tags": [
                  "Best Practices"
                ]
              }
            }
          ]
        }
      },
      "results": [
        {
          "ruleId": "UnusedPrivateField",
          "ruleIndex": 0,
          "message": {
            "text": "Avoid unused private fields such as 'x'."
          },
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "/Users/yasmin/IdeaProjects/coverage-example-java/src/main/java/com/codacy/utils/RulesBreaker.java"
                },
                "region": {
                  "startLine": 6,
                  "startColumn": 17,
                  "endLine": 6,
                  "endColumn": 17
                }
              }
            }
          ]
        }
      ],
      "invocations": [
        {
          "executionSuccessful": true,
          "toolConfigurationNotifications": [],
          "toolExecutionNotifications": []
        }
      ]
    }
  ]
}%                                 ```

@zhamborova zhamborova force-pushed the PLUTO-1374_pmd_configuration branch from ee2d8d6 to de783d7 Compare April 2, 2025 12:29
@codacy-production
Copy link

codacy-production bot commented Apr 2, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+2.21% 46.52%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (58327d1) 2011 494 24.56%
Head commit (4c9cfaa) 2200 (+189) 589 (+95) 26.77% (+2.21%)

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 (#51) 230 107 46.52%

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

@zhamborova zhamborova force-pushed the PLUTO-1374_pmd_configuration branch from de783d7 to a685a55 Compare April 3, 2025 12:25
@zhamborova zhamborova requested a review from Copilot April 3, 2025 12:27
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 adjusts the PMD integration to use PMD version 6.55.0 and updates related configuration and test logic for generating and verifying SARIF reports as well as PMD ruleset XMLs.

  • Updated PMD runner and test files to use the new binary, command line arguments, and output normalization.
  • Introduced PMD configuration creation functions and corresponding tests.
  • Modified plugin configuration, initialization, and Codacy configuration files to reflect the updated PMD version.

Reviewed Changes

Copilot reviewed 7 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/pmdRunner_test.go Updated tests for SARIF output normalization and revised PMD binary path
tools/pmdRunner.go Changed command arguments to align with the new PMD runner expectations
tools/pmdConfigCreator_test.go Added unit tests for generating PMD config XML and verifying disabled rule exclusion
tools/pmdConfigCreator.go Implemented PMD config creation logic using embedded default ruleset XML
plugins/tools/pmd/plugin.yaml Updated download URL and binary path for PMD binary version 6.55.0
cmd/init.go Integrated PMD configuration generation into the project initialization process
.codacy/codacy.yaml Updated the PMD tool version from 7.12.0 to 6.55.0
Files not reviewed (3)
  • tools/pmd/default-ruleset.xml: Language not supported
  • tools/testdata/repositories/pmd/expected-ruleset.xml: Language not supported
  • tools/testdata/repositories/pmd/expected.sarif: Language not supported

@zhamborova zhamborova marked this pull request as ready for review April 3, 2025 12:29
@zhamborova zhamborova requested a review from Copilot April 3, 2025 12:33
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

The PR updates PMD configuration functionality and corrects misspellings and version references across the codebase. Key changes include:

  • Renaming the mispelled "ParamenterConfigurations" to "ParameterConfigurations" in multiple files.
  • Updating PMD version references from 7.12.0 to 6.55.0 in tests, configuration files, and plugins.
  • Adjusting command arguments and file paths for consistent behavior with the updated configurations.

Reviewed Changes

Copilot reviewed 12 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/trivyConfigCreator_test.go Corrected parameter field name spelling in test definitions.
tools/trivyConfigCreator.go Fixed spelling for parameter configurations in the configuration code.
tools/pmdRunner_test.go Updated PMD binary path and error handling for SARIF output.
tools/pmdRunner.go Revised command argument construction for PMD execution.
tools/pmdConfigCreator_test.go Added tests for PMD config creation based on tool configuration.
tools/pmdConfigCreator.go Implemented PMD config generation with proper XML formatting.
tools/eslintConfigCreator_test.go Corrected spelling errors in ESLint config test cases.
tools/eslintConfigCreator.go Fixed parameter configurations spelling in ESLint config creator.
tools/ToolConfigurationStruct.go Updated field name spelling for parameter configurations.
plugins/tools/pmd/plugin.yaml Updated PMD download and binary path information.
cmd/init.go Adjusted PMD version and configuration file creation logic.
.codacy/codacy.yaml Updated PMD version reference for Codacy configuration.
Files not reviewed (3)
  • tools/pmd/default-ruleset.xml: Language not supported
  • tools/testdata/repositories/pmd/expected-ruleset.xml: Language not supported
  • tools/testdata/repositories/pmd/expected.sarif: Language not supported

Copy link
Contributor

@machadoit machadoit left a comment

Choose a reason for hiding this comment

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

🚢

@zhamborova zhamborova merged commit 5b319ed into main Apr 3, 2025
7 checks passed
heliocodacy pushed a commit that referenced this pull request Apr 4, 2025
@zhamborova zhamborova deleted the PLUTO-1374_pmd_configuration branch April 23, 2025 10:21
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