Test "Verify latest PMD SNAPSHOT" #84
Annotations
4 errors and 11 warnings
No abstract method which means that the keyword is most likely used to prevent instantiation. Use a private or protected constructor instead.:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AbstractClassWithoutAnyMethodSample.java#L1
If an abstract class does not provide any methods, it may be acting as a simple data container
that is not meant to be instantiated. In this case, it is probably better to use a private or
protected constructor in order to prevent instantiation than make the class misleadingly abstract.
AbstractClassWithoutAnyMethod (Priority: 1, Ruleset: Design)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#abstractclasswithoutanymethod
|
No abstract method which means that the keyword is most likely used to prevent instantiation. Use a private or protected constructor instead.:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L5
If an abstract class does not provide any methods, it may be acting as a simple data container
that is not meant to be instantiated. In this case, it is probably better to use a private or
protected constructor in order to prevent instantiation than make the class misleadingly abstract.
AbstractClassWithoutAnyMethod (Priority: 1, Ruleset: Design)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_design.html#abstractclasswithoutanymethod
|
Return an empty collection rather than null.:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L42
For any method that returns an collection (such as an array, Collection or Map), it is better to return
an empty one rather than a null reference. This removes the need for null checking all results and avoids
inadvertent NullPointerExceptions.
See Effective Java, 3rd Edition, Item 54: Return empty collections or arrays instead of null
ReturnEmptyCollectionRatherThanNull (Priority: 1, Ruleset: Error Prone)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_errorprone.html#returnemptycollectionratherthannull
|
Return an empty collection rather than null.:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/UseCollectionIsEmptySample.java#L12
For any method that returns an collection (such as an array, Collection or Map), it is better to return
an empty one rather than a null reference. This removes the need for null checking all results and avoids
inadvertent NullPointerExceptions.
See Effective Java, 3rd Edition, Item 54: Return empty collections or arrays instead of null
ReturnEmptyCollectionRatherThanNull (Priority: 1, Ruleset: Error Prone)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_errorprone.html#returnemptycollectionratherthannull
|
pmd-code-scan
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: pmd/pmd-github-action@v1. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
|
All classes, interfaces, enums and annotations must belong to a named package:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AbstractClassWithoutAnyMethodSample.java#L1
Detects when a class, interface, enum or annotation does not have a package definition.
NoPackage (Priority: 3, Ruleset: Code Style)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#nopackage
|
All classes, interfaces, enums and annotations must belong to a named package:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L3
Detects when a class, interface, enum or annotation does not have a package definition.
NoPackage (Priority: 3, Ruleset: Code Style)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#nopackage
|
Empty try body:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L11
Reports control statements whose body is empty, as well as empty initializers.
The checked code constructs are the following:
- bodies of `try` statements
- `finally` clauses of `try` statements
- `switch` statements
- `synchronized` statements
- `if` statements
- loop statements: `while`, `for`, `do .. while`
- initializers
- blocks used as statements (for scoping)
This rule replaces the rules EmptyFinallyBlock,
EmptyIfStmt, EmptyInitializer, EmptyStatementBlock,
EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, and EmptyWhileStmt.
Notice that {% rule java/errorprone/EmptyCatchBlock %} is still an independent rule.
EmptyStatementNotInLoop is replaced by {% rule java/codestyle/UnnecessarySemicolon %}.
EmptyControlStatement (Priority: 3, Ruleset: Code Style)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#emptycontrolstatement
|
A catch statement should never catch throwable since it includes errors.:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L13
Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
OutOfMemoryError that should be exposed and managed separately.
AvoidCatchingThrowable (Priority: 3, Ruleset: Error Prone)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_errorprone.html#avoidcatchingthrowable
|
Avoid returning from a finally block:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L24
Avoid returning from a finally block, this can discard exceptions.
ReturnFromFinallyBlock (Priority: 3, Ruleset: Error Prone)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_errorprone.html#returnfromfinallyblock
|
Do not use if statements that are always true or always false:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L29
Do not use "if" statements whose conditionals are always true or always false.
UnconditionalIfStatement (Priority: 3, Ruleset: Error Prone)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_errorprone.html#unconditionalifstatement
|
Empty if statement:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L29
Reports control statements whose body is empty, as well as empty initializers.
The checked code constructs are the following:
- bodies of `try` statements
- `finally` clauses of `try` statements
- `switch` statements
- `synchronized` statements
- `if` statements
- loop statements: `while`, `for`, `do .. while`
- initializers
- blocks used as statements (for scoping)
This rule replaces the rules EmptyFinallyBlock,
EmptyIfStmt, EmptyInitializer, EmptyStatementBlock,
EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, and EmptyWhileStmt.
Notice that {% rule java/errorprone/EmptyCatchBlock %} is still an independent rule.
EmptyStatementNotInLoop is replaced by {% rule java/codestyle/UnnecessarySemicolon %}.
EmptyControlStatement (Priority: 3, Ruleset: Code Style)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#emptycontrolstatement
|
Empty if statement:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L36
Reports control statements whose body is empty, as well as empty initializers.
The checked code constructs are the following:
- bodies of `try` statements
- `finally` clauses of `try` statements
- `switch` statements
- `synchronized` statements
- `if` statements
- loop statements: `while`, `for`, `do .. while`
- initializers
- blocks used as statements (for scoping)
This rule replaces the rules EmptyFinallyBlock,
EmptyIfStmt, EmptyInitializer, EmptyStatementBlock,
EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, and EmptyWhileStmt.
Notice that {% rule java/errorprone/EmptyCatchBlock %} is still an independent rule.
EmptyStatementNotInLoop is replaced by {% rule java/codestyle/UnnecessarySemicolon %}.
EmptyControlStatement (Priority: 3, Ruleset: Code Style)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#emptycontrolstatement
|
Substitute calls to size() == 0 (or size() != 0, size() > 0, size() < 1) with calls to isEmpty():
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AllInOne.java#L36
The isEmpty() method on java.util.Collection is provided to determine if a collection has any elements.
Comparing the value of size() to 0 does not convey intent as well as the isEmpty() method.
UseCollectionIsEmpty (Priority: 3, Ruleset: Best Practices)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_bestpractices.html#usecollectionisempty
|
All classes, interfaces, enums and annotations must belong to a named package:
file:///home/runner/work/pmd-github-action-tests/pmd-github-action-tests/src/main/java/AvoidCatchingThrowableSample.java#L1
Detects when a class, interface, enum or annotation does not have a package definition.
NoPackage (Priority: 3, Ruleset: Code Style)
https://docs.pmd-code.org/pmd-doc-7.0.0-rc4/pmd_rules_java_codestyle.html#nopackage
|
Artifacts
Produced during runtime
Name | Size | |
---|---|---|
PMD Report
Expired
|
19.4 KB |
|