Light-weight static code analysis framework
- Java 100%
|
Jens Bannmann
03cfe3bab4
Some checks failed
Build / build (push) Failing after 6s
|
||
|---|---|---|
| .forgejo/workflows | Move to Codeberg | |
| annotations | [gitflow] Update for next development version | |
| core | [gitflow] Update for next development version | |
| parent | [gitflow] Update for next development version | |
| .gitignore | Initial commit | |
| LICENSE | Initial code | |
| pom.xml | [gitflow] Update for next development version | |
| README.md | Add NeedlesslySpecificTypeInRecordPattern | |
Artifacts
annotations
core
Rules
- ⭐
RECOMMENDED - 📌
OPTIONAL - ➖
OFF - 🚧
EXPERIMENTAL
Java language syntax
| Rule | Description | |
|---|---|---|
| ⭐ | AssertStatementUsage |
The Java assert statement should not be used |
| ⭐ | BitwiseOperatorUsage |
Bitwise operators should be avoided |
| ⭐ | DefaultClauseInExhaustiveSwitch |
Switch expressions that are exhaustive should not have a default clause |
| ⭐ | ImplicitlyPermittedSubtypes |
Sealed types should not implicitly permit all subtypes in the same package |
| ⭐ | NeedlesslyQualifiedMemberAccess |
Classes should qualify member accesses with this only to resolve ambiguities |
| 📌 | NeedlesslySpecificTypeInRecordPattern |
Record patterns should use var instead of repeating the type of the record component |
| ⭐ | OctalNumberUsage |
Number literals should not use octal notation |
| ⭐ | SwitchAllowsFallthrough |
Switch statements and expressions should not use colon cases |
JDK class usage
| Rule | Description | |
|---|---|---|
| ⭐ | DeprecationWithoutRemovalValue |
Deprecations should specify a forRemoval value to clearly convey the (current) intent of the deprecation |
| ⭐ | HardcodedClassReference |
Classes should use getClass() to refer to themselves instead of hardcoded class literals |
| ⭐ | MisplacedDeprecationSinceElement |
Deprecations that specify since should follow JDK conventions by placing it as the first element |
| ⭐ | SerializationUsage |
Application code should not use Java Object Serialization |
| ⭐ | SuspiciousClassLoaderUse |
Classes should not use literals that reference other classes to load resources or get the class loader |
| ⭐ | SuspiciousThrowStatement |
Methods that return throwables should not contain throw statements |
Java record classes
| Rule | Description | |
|---|---|---|
| 📌 | RecordNotAnnotatedRegardingImmutability |
Records should be annotated with @ShallowlyImmutable, @EffectivelyImmutable or Error Prone's @Immutable |
| 📌 | RecordImmutabilityAnnotationOnClass |
@ShallowlyImmutable and @EffectivelyImmutable should only annotate records |
| 📌 | ConflictingRecordImmutabilityAnnotations |
Records should only be annotated with one of @ShallowlyImmutable, @EffectivelyImmutable or Error Prone's @Immutable |
jSpecify nullness annotations (docs)
| Rule | Description | |
|---|---|---|
| ⭐ | NullabilityAnnotationOutsideNullMarkedCode |
Classes using jSpecify nullability annotations need to be @NullMarked on package or class level |
| ⭐ | MisplacedNullabilityAnnotation |
@Nullable and @NonNull should annotate type uses, not entire methods or fields |
| ⭐ | RedundantlyNullMarkedCode |
@NullMarked should not be used inside code that is already @NullMarked |
| ⭐ | UndesiredNullabilityAnnotation |
@NullMarked code may only use nullability annotations from jSpecify (and Lombok's @NonNull) |
| 📌 | MissingPackageNullnessDefault |
Packages should explicitly declare nullness defaults |
@SuppressWarnings
| Rule | Description | |
|---|---|---|
| ⭐ | MissingSuppressionRationale |
Each @SuppressWarnings must have a corresponding @SuppressWarningsRationale |
| ⭐ | OrphanedSuppressionRationale |
Each @SuppressWarningsRationale must have a corresponding @SuppressWarnings |
| ⭐ | AmbiguousSuppressionRationale |
Each @SuppressWarningsRationale must map clearly to one suppressed warning |
| ⭐ | OvercomplicatedSuppressionRationale |
@SuppressWarningsRationale may only specify a name if there is more than one suppression |
Lombok
| Rule | Description | |
|---|---|---|
| ➖ | UtilityClassMemberInconsistentlyStatic |
@UtilityClass members should be declared consistently static / not static |
| ➖ | UtilityClassMemberMarkedStatic |
@UtilityClass members should not be declared static as it is redundant |
| ➖ | UtilityClassMemberWithoutStaticModifier |
@UtilityClass members should be explicitly declared static to make them usable in static imports |
| 📌 | CdiQualifierNotCopyableByLombok |
CDI qualifier annotations used on fields should be made copyable (to constructors, accessors etc.) via lombok.config |
Library usage
| Rule | Description | |
|---|---|---|
| 📌 | FieldInjectionUsage |
Classes should use constructor injection instead of field injection |
| 📌 | MisplacedCdiQualifier |
CDI qualifiers should annotate type uses, not entire methods or fields |
| 📌 | UndesiredThreadSafetyAnnotation |
Code should use one set of thread safety annotations (@ThreadSafe from Error Prone and @NotThreadSafe from net.jcip) |
Miscellaneous
| Rule | Description | |
|---|---|---|
| ⭐ | MalformedExhaustiveSwitch |
@ExhaustiveSwitch must annotate a variable initialized with a switch expression, followed by a method call on it |
About the name
In Malay and Indonesian, Mandor means "foreman," somebody who oversees workers and ensures adherence to plans.