Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] Fix #4225 MissingStaticMethodInNonInstantiatableClass: Exclude lombok's @NoArgsConstructor annotation #4227

Merged
merged 3 commits into from
Nov 25, 2022

Conversation

LynnBroe
Copy link
Contributor

Describe the PR

This PR excludes lombok's @NoArgsConstructor annotation which generates a public constructor but PMD treats it as a false positive.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@pmd-test
Copy link

pmd-test commented Nov 23, 2022

1 Message
📖 Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 2 errors and 7 configuration errors.
Full report
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 2 errors and 7 configuration errors.
Full report
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 2 errors and 7 configuration errors.
Full report

Generated by 🚫 Danger

@adangel adangel changed the title Fix #4225 MissingStaticMethodInNonInstantiatableClass : Exclude lombok's @NoArgsConstructor annotation [java] Fix #4225 MissingStaticMethodInNonInstantiatableClass : Exclude lombok's @NoArgsConstructor annotation Nov 24, 2022
Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Can you please also create test cases for the other two lombok annotations which generate constructors?

  • @RequiredArgsConstructor
  • @AllArgsConstructor

See https://projectlombok.org/features/constructor for the full lombok documentation.

@adangel adangel added this to the 6.53.0 milestone Nov 24, 2022
@LynnBroe
Copy link
Contributor Author

Ok, Iwill create some test cases for the other two lombok annotations

@adangel adangel changed the title [java] Fix #4225 MissingStaticMethodInNonInstantiatableClass : Exclude lombok's @NoArgsConstructor annotation [java] Fix #4225 MissingStaticMethodInNonInstantiatableClass: Exclude lombok's @NoArgsConstructor annotation Nov 25, 2022
Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment on lines +392 to +393
private Test(int a, int b, int c, String abc, long d, double p,
String[] arr, int data, long in, float fl, String res) { } // 11 params
Copy link
Member

@adangel adangel Nov 25, 2022

Choose a reason for hiding this comment

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

I'll change these test samples myself when I merge it, because the sample classes should have fields and not constructors. The constructors are generated by lombok, so no need to define them. But the generated constructors would depend on the fields (at least for allargs and required args). That way, the examples are more "realistic".

@adangel adangel modified the milestones: 6.53.0, 6.52.0 Nov 25, 2022
@adangel adangel merged commit cdaf0d2 into pmd:master Nov 25, 2022
adangel added a commit to adangel/pmd that referenced this pull request Nov 25, 2022
adangel added a commit to adangel/pmd that referenced this pull request Nov 25, 2022
[java] Fix pmd#4225 MissingStaticMethodInNonInstantiatableClass: Exclude lombok's @NoArgsConstructor annotation pmd#4227
@LynnBroe LynnBroe deleted the issue4225 branch November 29, 2022 11:07
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.

[java] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @NoArgsConstructor
3 participants