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

Enable checks from Error Prone Support #14137

Open
rickie opened this issue Dec 12, 2023 · 7 comments
Open

Enable checks from Error Prone Support #14137

rickie opened this issue Dec 12, 2023 · 7 comments

Comments

@rickie
Copy link
Contributor

rickie commented Dec 12, 2023

In PR #14136 I added Error Prone Support to Checkstyle. As @romani suggested in #14129, I'd like to create this issue to discuss which checks from Error Prone Support are useful for the Checkstyle project to enable.

The full list of checks can be found here: https://error-prone.picnic.tech/.

  1. AmbiguousJsonCreator
  2. AssertJIsNull
  3. AutowiredConstructor
  4. CanonicalAnnotationSyntax
  5. CollectorMutability
  6. DirectReturn
  7. EmptyMethod
  8. ExplicitEnumOrdering
  9. FormatStringConcatenation
  10. IdentityConversion
  11. ImmutablesSortedSetComparator
  12. IsInstanceLambdaUsage
  13. JUnitClassModifiers
  14. JUnitMethodDeclaration
  15. JUnitValueSource
  16. LexicographicalAnnotationAttributeListing
  17. MockitoMockClassReference
  18. MockitoStubbing
  19. NestedOptionals
  20. PrimitiveComparison
  21. RedundantStringConversion
  22. Slf4jLogStatement
  23. StaticImport
  24. StringJoin
  25. TimeZoneUsage

I omitted some of the checks from the list as they are definitely not applicable to this project (for example they are Spring or Reactor focused).

Let me know if this is the right approach, or if we should change something.

I'm curious to hear your thoughts on the checks!

@rickie
Copy link
Contributor Author

rickie commented Dec 12, 2023

Here are a few of my comments on some of the checks:


  1. AssertJIsNull: Only one AssertJ reference in Checkstyle, so not relevant.

  1. CollectorMutability: In this PR @romani mentioned that we should enable this rule 😄 Pull #12777: emphasize mutability of collectors #12777 (review).

  1. JUnitMethodDeclaration: @romani made a comment about that here, saying:

We had this violation in Sonarqube error-prone.picnic.tech/bugpatterns/JUnitMethodDeclaration
In team we agreed to have methods to be public even somebody think it is better to be package-private.

So this one is probably not interesting.


  1. StaticImport: In this comment @romani mentions the following:

error-prone.picnic.tech/bugpatterns/StaticImport
We like more explicit code, as majority of time we do code review from phones, so context matters for us.

Just to clarify, in this check we statically import these members. It is a list of carefully reviewed members that are statically imported as doing so doesn't result in a loss of context. So mostly to remove "duplicate words".

@romani
Copy link
Member

romani commented Dec 13, 2023

@Vyom-Yadav, FYI

rickie added a commit to rickie/checkstyle that referenced this issue Dec 13, 2023
rickie added a commit to rickie/checkstyle that referenced this issue Dec 14, 2023
@romani
Copy link
Member

romani commented Dec 17, 2023

Please activate:
AmbiguousJsonCreator
AssertJIsNull
AutowiredConstructor
CanonicalAnnotationSyntax
CollectorMutability


DirectReturn we can try in separate PR, to see a scope of violations, I remember in some cases it was benefitials to use not direct return.


please activate:
EmptyMethod
ExplicitEnumOrdering


FormatStringConcatenation we can try in separate PR, to see a scope of violations, I remember in some cases it was benefitials to use concatenation as compact syntax.


please activate:
IdentityConversion


ImmutablesSortedSetComparator we can try in separate PR. I have concern on extra dependency, we are library, we care about less transitive dependencies.


please activate:
IsInstanceLambdaUsage


lets suppress:
JUnitClassModifiers
JUnitMethodDeclaration
JUnitValueSource


please activate:
LexicographicalAnnotationAttributeListing
MockitoMockClassReference
MockitoStubbing
NestedOptionals
PrimitiveComparison
RedundantStringConversion
Slf4jLogStatement


lets suppress:
StaticImport


lets try:
StringJoin
TimeZoneUsage

@romani
Copy link
Member

romani commented Dec 17, 2023

@rickie, please send each activation in separate PR, AND isf there is bunch of udpates required, it is completely OK to split fixes( before activation) in separate PRs.
Some updates might be very controversial, so it is reasonable to have smaller PR to agree on style before forcing whole code to follow it.

rickie added a commit to rickie/checkstyle that referenced this issue Dec 20, 2023
@nrmancuso
Copy link
Member

I agree with prioritization and selection of bug patterns at #14137 (comment), @rickie please feel free to start sending PRs :)

@github-actions github-actions bot added this to the 10.12.7 milestone Dec 21, 2023
rickie added a commit to rickie/checkstyle that referenced this issue Dec 27, 2023
rickie added a commit to rickie/checkstyle that referenced this issue Dec 27, 2023
rickie added a commit to rickie/checkstyle that referenced this issue Dec 27, 2023
rickie added a commit to rickie/checkstyle that referenced this issue Dec 27, 2023
rickie added a commit to rickie/checkstyle that referenced this issue Dec 28, 2023
rickie added a commit to rickie/checkstyle that referenced this issue Jan 1, 2024
@Vyom-Yadav
Copy link
Member

I agree with the discussion above. @romani This can be a good third/fourth issue. Please convert the issue description to a checklist, I too can send a few PRs to have some examples.

@romani
Copy link
Member

romani commented Jan 3, 2024

This is not good for junior contributors as it might be controversial and tricky.
But you are not a junior, we are welcome with PR

rickie added a commit to rickie/checkstyle that referenced this issue Jan 5, 2024
rickie added a commit to rickie/checkstyle that referenced this issue Jan 5, 2024
rickie added a commit to rickie/checkstyle that referenced this issue Jan 5, 2024
rickie added a commit to rickie/checkstyle that referenced this issue Jan 5, 2024
romani pushed a commit that referenced this issue Jan 26, 2024
rickie added a commit to rickie/checkstyle that referenced this issue Jan 27, 2024
chrccl pushed a commit to chrccl/checkstyle that referenced this issue Jan 27, 2024
romani pushed a commit that referenced this issue Jan 27, 2024
rickie added a commit to rickie/checkstyle that referenced this issue Feb 2, 2024
rickie added a commit to rickie/checkstyle that referenced this issue Feb 2, 2024
rdiachenko pushed a commit to rickie/checkstyle that referenced this issue Feb 2, 2024
@github-actions github-actions bot modified the milestones: 10.13.0, 10.13.1 Feb 2, 2024
rickie added a commit to rickie/checkstyle that referenced this issue Feb 22, 2024
rickie added a commit to rickie/checkstyle that referenced this issue Feb 22, 2024
Coding-Aliens pushed a commit to Coding-Aliens/checkstyle that referenced this issue Feb 23, 2024
Bumps [com.google.truth:truth](https://github.com/google/truth) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/google/truth/releases)
- [Commits](google/truth@v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: com.google.truth:truth
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Issue checkstyle#6207: Enale XpathRegressionTest for IlegalTokenText

dependency: bump org.pitest:pitest-maven from 1.15.3 to 1.15.4

Bumps [org.pitest:pitest-maven](https://github.com/hcoles/pitest) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/hcoles/pitest/releases)
- [Commits](hcoles/pitest@1.15.3...1.15.4)

---
updated-dependencies:
- dependency-name: org.pitest:pitest-maven
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Issue checkstyle#13213: removed //ok metrics,design

Issue checkstyle#13213: Removed //ok from leftout files

Issue checkstyle#13999: Resolve pitest suppression for throwAst.getParent() of JavadocMethod

Issue checkstyle#13213: Removed //ok noncompilable/naming

dependency: bump org.pitest:pitest-maven from 1.15.4 to 1.15.6

Bumps [org.pitest:pitest-maven](https://github.com/hcoles/pitest) from 1.15.4 to 1.15.6.
- [Release notes](https://github.com/hcoles/pitest/releases)
- [Commits](hcoles/pitest@1.15.4...1.15.6)

---
updated-dependencies:
- dependency-name: org.pitest:pitest-maven
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Issue checkstyle#11163: Enforced file size inputs

Issue checkstyle#6207: Add XPath IT Regression test for CatchParameterName

Issue checkstyle#11163: Enforced filesize commentsindentation

Issue checkstyle#13213: removed //ok noncompilable/sizes

Issue checkstyle#13213: Removed //ok from methodcount

Issue checkstyle#11163: enforced filesize MissingJavadocTypeTags

Issue checkstyle#6207: Enable XpathRegressiontest for EqualsHashCode

Issue checkstyle#13213: Removed //ok from nolinewrap

Issue checkstyle#13213: Removed //ok from declarationorder

Issue checkstyle#14137: Enable `MockitoStubbing` check

Issue checkstyle#13213: removed //ok noncompilable/whitespace

Issue checkstyle#13345: Enable StaticVariableNameCheckExamplesTest

Issue checkstyle#14137: Enable `TimeZoneUsage` check

Issue checkstyle#11163: Enforced filesize TypeNoJavadoc1

doc: release notes for 10.13.0

[maven-release-plugin] prepare release checkstyle-10.13.0

[maven-release-plugin] prepare for next development iteration

doc: fix releasenotes.xml line length violation

Issue# 13999: RemoveConditionalMutator_EQUAL_IF on if (child.getType() == TokenTypes.PARAMETER_DEF)
rickie added a commit to rickie/checkstyle that referenced this issue Feb 23, 2024
romani pushed a commit that referenced this issue Feb 23, 2024
rickie added a commit to rickie/checkstyle that referenced this issue Feb 24, 2024
romani pushed a commit that referenced this issue Feb 24, 2024
kalpadiptyaroy pushed a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 27, 2024
kalpadiptyaroy pushed a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 27, 2024
kalpadiptyaroy pushed a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 27, 2024
kalpadiptyaroy pushed a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants