Skip to content

PMD: fix the 117 violations reported with the project ruleset (empty catch blocks, Thread.run(), always-true if, unary operators, qualified names, parentheses) #114

Description

@bertysentry

PMD, run with the project's own pmd.xml ruleset exactly as the CI site build does (mvn pmd:pmd, maven-pmd-plugin 3.26.0 / PMD 7.7.0 on commit 255b812), reports 117 violations in 19 files (1 × priority 2, 12 × priority 3, 104 × priority 4). The report is generated on every build but never gated, so the count only grows.

Substantive violations (16, fix individually)

Rule Location Note
AvoidMultipleUnaryOperators (P2) core/common/TypeConverter.java:294 double unary operator; check the intended sign handling (1's/2's complement helpers)
EmptyCatchBlock client/runner/AbstractIpmiRunner.java:174 closeSession failure silently ignored in close()
EmptyCatchBlock client/runner/GetFrusRunner.java:188, :225, :236 FRU read / decode failures swallowed ("Nothing can be done") – a lost packet yields a truncated FRU without any log (see #102)
EmptyCatchBlock core/connection/ConnectionManager.java:144 InterruptedException swallowed (// TODO log) – see #79
EmptyCatchBlock core/connection/queue/MessageQueue.java:152 InterruptedException swallowed (// TODO log) – see #79
EmptyCatchBlock core/transport/UdpMessenger.java:222 InterruptedException swallowed in send() (// TODO: log)
EmptyControlStatement + UnconditionalIfStatement core/coding/commands/fru/ReadFruData.java:259 if that is always true/false with an empty body (the SPD TODO, see #107)
EmptyControlStatement core/api/sol/SerialOverLan.java:568 empty while – busy-wait
UnnecessaryReturn core/api/async/IpmiAsyncConnector.java:372
DontCallThreadRun core/transport/UdpMessenger.java:119, core/transport/UdpNotifier.java:46, core/coding/DecoderRunner.java:451 run() called directly instead of start() – in UdpMessenger this is the receive loop started from the constructor; verify the intent
AvoidUsingHardCodedIP core/transport/UdpMessenger.java:50 DEFAULT_ADDRESS hard-coded

Mechanical violations (101, fix in bulk)

  • UnnecessaryFullyQualifiedName (66): DecoderRunner ×26, TypeConverter ×21, ProductInfo ×7, BoardInfo ×5, ChassisInfo ×3, SolAckState ×3, UdpMessenger ×1 – e.g. java.lang.Thread.sleep(...), TypeConverter.* qualified inside TypeConverter itself.
  • UselessParentheses (35): GetChassisStatusResponseData ×23, TypeConverter ×4, CipherSuite ×3, BoardInfo, ChassisInfo, FullSensorRecord, GetSensorReading, ProductInfo ×1 each.

DecoderRunner alone accounts for 27 violations and is a main() harness that should simply be deleted (#99).

Acceptance

  • mvn pmd:pmd pmd:cpd reports 0 violations with pmd.xml.
  • Consider adding pmd:check (and cpd-check, see the CPD issue) to the verify phase, as done in winrm-java, so the report stays clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions