pmd / pmd/pmd

[apex] Duplicate warning for EmptyStatementBlock and EmptyIfStmt

Open
#3,164 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

a:bug needs:pmd7-revalidation
Dominant language
Java
Stars
5.5k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
54

Description

Affects PMD Version:
PMD 6.32

Description:

With a class that contains code like this:

[...]
        if( processCasesMap.containsKey('C_RT_TakeoverEle') ) {}
[...]

PMD will report 2 warnings, one for ]EmptyStatementBlock](https://pmd.github.io/latest/pmd_rules_apex_errorprone.html#emptystatementblock) the other for EmptyIfStmt on the same line

Code Sample demonstrating the issue:

TestClass.cls.txt

is reporting duplicate warning on the following lines:
image

Steps to reproduce:

  1. Download the TestClass.cls.txt file
  2. Rename the file to TestClass.cls
  3. run PMF 6.32 with apex_ruleset.xml.txt

Running PMD through: [CLI]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report with TestClass.cls.txt and apex_ruleset.xml.txt using the PMD CLI, then inspect the EmptyStatementBlock and EmptyIfStmt rules. Done means the empty if statement no longer produces duplicate warnings while the relevant rule behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.