saros icon indicating copy to clipboard operation
saros copied to clipboard

PMD ruleset

Open m273d15 opened this issue 5 years ago • 3 comments
trafficstars

We are currently defining our PMD ruleset. We should start with the most relevant rules that are contained in PMD's best-practices ruleset.

  • [ ] AbstractClassWithoutAbstractMethod
  • [ ] AccessorClassGeneration
  • [ ] AccessorMethodGeneration
  • [ ] ArrayIsStoredDirectly
  • [ ] AvoidMessageDigestField
  • [ ] AvoidPrintStackTrace
  • [ ] AvoidReassigningLoopVariables
  • [ ] AvoidReassigningParameters
  • [ ] AvoidStringBufferField
  • [ ] AvoidUsingHardCodedIP
  • [ ] CheckResultSet
  • [ ] ConstantsInInterface
  • [ ] DefaultLabelNotLastInSwitchStmt
  • [ ] DoubleBraceInitialization
  • [ ] ForLoopCanBeForeach
  • [ ] ForLoopVariableCount
  • [ ] GuardLogStatement
  • [ ] JUnit4SuitesShouldUseSuiteAnnotation
  • [ ] JUnit4TestShouldUseAfterAnnotation
  • [ ] JUnit4TestShouldUseBeforeAnnotation
  • [ ] JUnit4TestShouldUseTestAnnotation
  • [ ] JUnitAssertionsShouldIncludeMessage
  • [ ] JUnitTestContainsTooManyAsserts
  • [ ] JUnitTestsShouldIncludeAssert
  • [ ] JUnitUseExpected
  • [ ] LooseCoupling
  • [ ] MethodReturnsInternalArray
  • [ ] MissingOverride
  • [ ] OneDeclarationPerLine
  • [ ] PositionLiteralsFirstInCaseInsensitiveComparisons
  • [ ] PositionLiteralsFirstInComparisons
  • [ ] PreserveStackTrace
  • [ ] ReplaceEnumerationWithIterator
  • [ ] ReplaceHashtableWithMap
  • [ ] ReplaceVectorWithList
  • [ ] SwitchStmtsShouldHaveDefault
  • [ ] SystemPrintln
  • [X] UnusedFormalParameter
  • [ ] UnusedImports (produces multiple false positives)
  • [X] UnusedLocalVariable
  • [X] UnusedPrivateField
  • [X] UnusedPrivateMethod
  • [ ] UseAssertEqualsInsteadOfAssertTrue
  • [ ] UseAssertNullInsteadOfAssertTrue
  • [ ] UseAssertSameInsteadOfAssertTrue
  • [ ] UseAssertTrueInsteadOfAssertEquals
  • [ ] UseCollectionIsEmpty
  • [ ] UseTryWithResources
  • [ ] UseVarargs
  • [ ] WhileLoopWithLiteralBoolean

Which rules would you like to add (we have to add the rules step-by-step because we need to fix the violations and then add the rule to the set.)

m273d15 avatar May 11 '20 09:05 m273d15

I would add:

  • AbstractClassWithoutAbstractMethod
  • SystemPrintln (I assume we have to ignore the rule in Saros.java and probably the server)
  • UseTryWithResources
  • ForLoopCanBeForeach
  • UseCollectionIsEmpty

There are also more rules I would like to add in the future.

m273d15 avatar May 11 '20 09:05 m273d15

We could currently already enable some of the recommended rules that have no violations (like AccessorClassGeneration, AccessorMethodGeneration, and AvoidMessageDigestField).

The question is what our aim with the new rule set is. Do we want to keep as many rules from the best practices section as possible or do we want to keep the set as small as possible?

tobous avatar May 11 '20 11:05 tobous

The question is what our aim with the new ruleset is. Do we want to keep as many rules from the best practices section as possible or do we want to keep the set as small as possible?

I would say:

  • Use all rules from PMD best-practices we can agree on
  • Add rules that enforce our best-practices (if we agree on these best-practices). E.g. naming

m273d15 avatar May 12 '20 09:05 m273d15