Cleanup
Recipes
- Avoid
System.exitin library code - Avoid empty catch blocks
- Encapsulate public mutable fields
- Ensure Log4j is patched against CVE-2021-44228
- Externalize hardcoded credentials
- Externalize hardcoded timeouts
- Extract magic numbers to named constants
- Inventory Typesafe Config usage
- Inventory scala-logging usage
- Keep classes small (max 30 members)
- Keep methods short (max 20 statements)
- Prefer
Optionovernull - Prefer Scala-style property access over Java getters
- Prefer explicit imports over wildcards
- Prefer immutable collections
- Prefer pattern matching over
asInstanceOfcasts - Prefer pattern matching over
isInstanceOf/asInstanceOfchains - Prefer specific types over
Any - Prefer string interpolation over concatenation
- Prefer
valovervar - Reduce deep nesting by extracting methods
- Reduce parameter count (max 5 parameters)
- Remove explicit
returnstatements - Remove redundant
toStringonString - Remove unnecessary
: Unitreturn type - Remove unused variable bindings
- Replace
.getOrElse(null)with.orNull - Replace
JavaConverterswithCollectionConverters - Replace unnecessary intermediate collection before
.toSet - Resolve TODO/FIXME comments
- Review deprecated API declarations
- Simplify boolean expression
- Use
Optionsafely - Use logging framework instead of
printStackTrace - Use logging framework instead of
println