Code Monkey home page Code Monkey logo

codacy-pmd's People

Contributors

andreatp avatar bmbferreira avatar caxaria avatar cog avatar dmarinhocodacy avatar dotdoom avatar felitchia avatar josemiguelmelo avatar kidsoncoffee avatar lolgab avatar machadoit avatar mrfyda avatar nmatpt avatar pedrocodacy avatar pedrorijo91 avatar rtfpessoa avatar stefanvacareanu7 avatar vascorsd avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codacy-pmd's Issues

Package private test methods with JUnit 5

I'm using a project with JUnit 5 and I'd like to follow the default JUnit 5 recommendation of using package private tests. See here: https://junit.org/junit5/docs/current/user-guide/#writing-tests-classes-and-methods, specifically the note:

Neither test classes nor test methods need to be public

The default PMD configuration for Codacy complains if I use package private test methods. It shows:

image

Can default Codacy PMD configuration be adjusted to properly allow package private JUnit 5 tests? I really don't want to go to a custom XML ruleset just for a small tweak. In the meanwhile I'm just making the tests public but then other tooling that does follow the JUnit 5 recommendation needs tweaking. Thanks!

PMD 6.0.0 update

The PMD maintainers asked how to make sure that Codacy is able to timely update their PMD version when 6.0 is out here: pmd/pmd#709

Is there anything I can tell them? How fast can you do it and do you see any obstacles with integrating 6.0 into your existing plugin? Feel free directly jump into the above mentioned issue.

[TS-697] Customise PMD rule

Hello,

Could you please clarify how PMD customisation works under the hood. If I provide ruleset.xml will Codacy take own "default" ruleset and apply my file on top of it or will it just take my file? Other words, if I customise one existing rule in my ruleset - this rule is the only thing that going to be checked or default behaviour of all other rules will also be executed?
If Codacy will take only my ruleset.xml - how I can practically customise any rule? I mean I am quite happy with default set, but looks like single rule customisation will "disable" everything else.

Thanks,
Aleksandr

Support for new PMD rules required?

I am not quite sure I've understood the technical details entirely ...

Does codacy-pmdjava understand any rule the underlying pmd version supports or is there a need for an explicit "mapping" within this project here in order to support the rules the underlying pmd supports? (The code indicates this if I am not mistaken.)

I am asking because pmd was upgraded from 5.3.6 to 5.4.1 in April. I am missing rulesets/java/comments.xml/CommentDefaultAccessModifier introduced with 5.4.0 which can act as a "saner" replacement for rulesets/java/controversial.xml/DefaultPackage.

PMD DocGenerator generates strange pattern titles

PMD DocGenerator uses the message as pattern title for the documentation.
Sometimes this choice is far from ideal: "The method {0}() has an NCSS line count of {1}".

We want, instead, use the pattern title converting from CamelCase to a sentence:
ExcessiveMethodLength should become: Excessive method length

It should manage constants names with all upper case letters:
TO_TIMESTAMPWithoutDateFormat should become: TO_TIMESTAMP without date format

[feature] As a ruleset admin I want to see if and why my ruleset made PMD fail

When there are errors in the custom ruleset.xml the engine silently fails without giving any notice. In Code Climate there is a status for each commit with a very detail error output showing why an engine failed.

As I expect users of this engine to play around a lot with their ruleset.xml this is a crucial feature.

Time to fix always shows 5min

cursor_und_2team_-_codacy_-_issues

Couldn't we use an engine specific parameter as we did for Code Climate. They use a complicated Remediation Point system. Why not have a "time to fix in minutes" which also can be null which means "depends".

Cannot configure tool with .codacy.yml

If we have a .codacy.yml like this:

---
engines:
 pmd:
  exclude_paths:
   - '**.sql'

PMD will not exclude SQL files.

Acceptance criteria:

  • It's possible to exclude paths for PMD

[CY-6456] ERROR c.c.a.c.a.CodacyPluginsAnalyser:52 - Failed metrics for metrics

I just create a test project code(only some md files and one tf file) and run scan with below command
java -jar /codacy-analysis-cli-assembly-7.6.6.jar analyze --project-token 2cf7xxxxxx --directory $CI_PROJECT_DIR --allow-network --verbose --output output.txt --skip-uncommitted-files-check --fail-if-incomplete

but got

08/25 14:06:38 INFO  CodacyPlugins:26 - Running docker image codacy/codacy-remark-lint:2.5.100. took 1157ms
08/25 14:06:38 ERROR c.c.a.c.a.CodacyPluginsAnalyser:31 - Failed analysis for remark-lint
java.lang.Throwable:
Docker exited with code 1
stdout:
stderr: node:internal/fs/utils:344
    throw err;
    ^

Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (node:fs:723:3)
    at tryReadSync (node:fs:433:20)
    at Object.readFileSync (node:fs:479:19)
    at Object.readFileSync [as default] (/app/build/main/lib/util/file.js:8:57)
    at parseCodacyConfiguration (/app/build/main/lib/codacy-configuration.js:23:46)
    at configFromCodacy (/app/build/main/lib/codacy-configuration.js:10:26)
    at Object.run [as default] (/app/build/main/lib/remark-runner.js:37:11)
    at Object.<anonymous> (/app/build/main/index.js:26:24)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) {
  errno: -21,
  syscall: 'read',
  code: 'EISDIR'
}

	at com.codacy.plugins.runners.BinaryDockerRunner.$anonfun$run$4(BinaryDockerRunner.scala:84)
	at scala.util.Success.flatMap(Try.scala:251)

and

08/25 14:06:47 INFO  CodacyPlugins:26 - Running docker image codacy/codacy-metrics-cloc:0.4.3. took 1518ms
08/25 14:06:47 ERROR c.c.a.c.a.CodacyPluginsAnalyser:52 - Failed metrics for metrics
java.lang.Throwable:
Docker exited with code 1
stdout:
stderr: java.io.IOException: Is a directory
	at java.base/sun.nio.ch.FileDispatcherImpl.read0(Native Method)
	at java.base/sun.nio.ch.FileDispatcherImpl.read(FileDispatcherImpl.java:48)
	at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
	at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:245)
	at java.base/sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:223)
	at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
	at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:107)
	at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:101)

output

# cat output.txt
Starting analysis ...
Found [Warning] `Ensure no hard coded AWS access key and secret key exists in provider` in secret.tf:1 (Checkov_CKV_AWS_41)
Found [Warning] `AWS Access Key` in secret.tf:3 (Checkov_CKV_SECRET_2)
Found [Warning] `Base64 High Entropy String` in secret.tf:4 (Checkov_CKV_SECRET_6)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:70 (markdownlint_MD022)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:92 (markdownlint_MD022)
Found [Info] `Expected: 80; Actual: 234` in README.md:65 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 303` in README.md:85 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 196` in README.md:17 (markdownlint_MD013)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:76 (markdownlint_MD022)
Found [Info] `Expected: 80; Actual: 89` in README.md:83 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 235` in README.md:68 (markdownlint_MD013)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:67 (markdownlint_MD022)
Found [Info] `Expected: 0 or 2; Actual: 1` in README.md:2 (markdownlint_MD009)
Found [Info] `Expected: 80; Actual: 387` in README.md:56 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 125` in README.md:77 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 193` in README.md:18 (markdownlint_MD013)
Found [Info] `Expected: 1; Actual: 3` in README.md:8 (markdownlint_MD012)
Found [Info] `Multiple top-level headings in the same document` in README.md:51 (markdownlint_MD025)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:1 (markdownlint_MD022)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:64 (markdownlint_MD022)
Found [Info] `Expected: 1; Actual: 2` in README.md:7 (markdownlint_MD012)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:73 (markdownlint_MD022)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:61 (markdownlint_MD022)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:79 (markdownlint_MD022)
Found [Info] `Expected: 80; Actual: 262` in README.md:53 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 91` in README.md:80 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 139` in README.md:13 (markdownlint_MD013)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:58 (markdownlint_MD022)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:55 (markdownlint_MD022)
Found [Info] `Expected: 80; Actual: 92` in README.md:11 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 332` in README.md:87 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 304` in README.md:62 (markdownlint_MD013)
Found [Info] `Fenced code blocks should have a language specified` in README.md:20 (markdownlint_MD040)
Found [Info] `Expected: 80; Actual: 259` in README.md:74 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 158` in README.md:44 (markdownlint_MD013)
Found [Info] `Expected: 80; Actual: 535` in README.md:71 (markdownlint_MD013)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:89 (markdownlint_MD022)
Found [Info] `Expected: 80; Actual: 336` in README.md:96 (markdownlint_MD013)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:82 (markdownlint_MD022)
Found [Info] `Expected: 1; Actual: 0; Below` in README.md:95 (markdownlint_MD022)
Found [Metrics] in README.md:
  LOC - 63
Found [Metrics] in .gitlab-ci.yml:
  LOC - 59
Found [Metrics] in secret.tf:
  LOC - 4
Analysis complete

False positive in UnusedPrivateMethod

Hello!

We use Codacy CI to check PRs in Checkstyle repo with the following configuration. PMD's check (UnusedPrivateMethod) which is used in Codacy reports that method verifyWarnd is unused, however, it is used multiple times in the class IndentationCheckTest where it is declared. We also use maven pmd plugin and the rule UnusedPrivateMethod from PMD and it does not report any violations for 'verifyWarnd' method. So, I think it is Codacy's issue. Now we have to exclude the method from the validation as you can see from the configuration.

Please, contact me if you need more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.