SAT Checks - Hilbrand/static-code-analysis GitHub Wiki
Ideas for sat checks
Logging:
- Geen toString in error messages (or any place when not needed)
- Geen log to error
- missing placeholders in log messages
- Geen concatenation in log messages
- Log ook exceptie variable
- Logger final
Exceptions:
- https://pmd.github.io/latest/pmd_rules_java_errorprone.html#usecorrectexceptionlogging (related: https://github.com/openhab/static-code-analysis/pull/238)
- Geen catch Exception als Exception niet gethrowed wordt: https://pmd.github.io/latest/pmd_rules_java_design.html#avoidcatchinggenericexception
- Method throws exceptie maar die wordt niet gethrowed.
- InterruptedException goed afvangen
Other:
- check final fields: https://pmd.github.io/latest/pmd_rules_java_design.html#immutablefield
- field sort order: http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder
- Gebruik van
StandardCharsets
ipv literal: https://github.com/checkstyle/checkstyle/pull/5191/files - https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#usetrywithresources
- Gebruik interface ipv class (List ipv ArrayList)
- Gebruik java8 lambda voor functies
- Nog andere java8 notatie optimalisaties
- https://pmd.github.io/latest/pmd_rules_java_performance.html#inefficientemptystringcheck
-
http://checkstyle.sourceforge.net/config_imports.html#RedundantImport - http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile
- http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName
- http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier
- http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder
- https://checkstyle.sourceforge.io/config_coding.html#StringLiteralEquality
- https://checkstyle.sourceforge.io/config_coding.html#SimplifyBooleanReturn
- https://checkstyle.sourceforge.io/config_coding.html#SimplifyBooleanExpression
- https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheck.html
- https://pmd.github.io/latest/pmd_rules_java_performance.html#inefficientstringbuffering
- https://pmd.github.io/latest/pmd_rules_java_performance.html#integerinstantiation, https://pmd.github.io/latest/pmd_rules_java_performance.html#longinstantiation
- https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#avoidprintstacktrace
- https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#loosecoupling
- https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#positionliteralsfirstincaseinsensitivecomparisons
- https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#systemprintln
- https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#unusedimports
- https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#usecollectionisempty
- https://pmd.github.io/latest/pmd_rules_java_design.html#excessivemethodlength
- https://pmd.github.io/latest/pmd_rules_java_errorprone.html#compareobjectswithequals
- Geen
Thread.sleep
: http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline - https://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html DiamondOperatorForVariableDefinitionCheck
openHAB specific:
- Check of binding aanwezig is in: CODEOWNERS, bom and feature file
- Check if all words in label start with uppercase character
- Geen NoneNull annotation: http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline
- Null annotaties op fields en methods inline op zelfde regel.
Automatically report sat issues to pr
https://github.com/tomasbjerre/violation-comments-to-github-maven-plugin