Common static analysis issues

MSAL

Resolve common static analysis issues (also known as SAST issues).

org.openrewrite.staticanalysis.CommonStaticAnalysis
mod run . --recipe=org.openrewrite.staticanalysis.CommonStaticAnalysis

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Constructors of an abstract class should not be declared public
  2. AtomicBoolean, AtomicInteger, and AtomicLong equality checks compare their values
  3. BigDecimal rounding constants to RoundingMode enums
  4. Boolean checks should not be inverted
  5. Case-insensitive comparisons do not alter case
  6. Catch clause should do more than just rethrow
  7. Chain StringBuilder.append() calls
  8. Collection.toArray() should be passed an array of the proper type
  9. Covariant equals
  10. Default comes last
  11. Remove empty blocks
  12. Equals avoids null
  13. Explicit initialization
  14. Externalizable classes have no-arguments constructor
  15. Finalize private fields
  16. Finalize classes with private constructors
  17. Fix String#format and String#formatted expressions
  18. for loop counters incremented in update
  19. Use indexOf(String, int)
  20. indexOf() replaceable by contains()
  21. indexOf should not compare greater than zero
  22. Inline variable
  23. Use Collection#isEmpty() instead of comparing size()
  24. Use Map#isEmpty() instead of comparing size()
  25. Simplify lambda blocks to expressions
  26. switch statements should have at least 3 case clauses
  27. Modifier order
  28. No multiple variable declarations
  29. Fix missing braces
  30. Nested enums are not static
  31. Change StringBuilder and StringBuffer character constructor argument to String
  32. No double brace initialization
  33. Use Collections#emptyList(), emptyMap(), and emptySet()
  34. Use comparison rather than equality checks in for conditions
  35. No primitive wrappers for #toString() or #compareTo(..)
  36. Jump statements should not be redundant
  37. Unnecessary String#toString
  38. Unnecessary String#valueOf(..)
  39. finalize() calls super
  40. Prefer System.getProperty(..) over System.getenv(..)
  41. Use primitive wrapper valueOf method
  42. Redundant File creation
  43. Remove extra semicolons
  44. Remove no argument super() constructor calls
  45. Remove redundant null checks before instanceof
  46. Remove redundant null checks before literal equals
  47. Rename methods named hashcode, equal, or tostring
  48. Replace A.class.isInstance(a) with a instanceof A
  49. Use method references in lambda
  50. Replace StringBuilder#append with String
  51. Replace String concatenation with String.valueOf()
  52. Simplify Arrays.asList(..) with varargs
  53. Simplify boolean expression
  54. Simplify boolean return
  55. Static methods need not be final
  56. Use String.equals() on String literals
  57. Unnecessary close in try-with-resources
  58. Unnecessary explicit type arguments
  59. Remove unnecessary parentheses
  60. Remove @Nullable and @CheckForNull annotations from primitives
  61. Unnecessary return as last statement in void method
  62. Upper case literal suffixes
  63. Use the diamond operator
  64. No C-style array declarations
  65. Use %n instead of \n in format strings
  66. Prefer while over for loops
  67. Write octal values as decimal
  68. Structural equality tests should use == or !=
  69. it shouldn't be used as a lambda parameter name
  70. Replace Char#toInt() with Char#code
  71. Order imports