pmd / pmd/pmd

[apex] Flag ANY use of @SuppressWarnings or //NOPMD, not just unused ones

Open
#5,795 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

a:new-rule
Dominant language
Java
Stars
5.5k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
54

Description

Proposed Rule Name:
WarningSuppression

Proposed Category: Best Practices

Description:
Should be available to all languages.

Flag ANY use of @SuppressWarnings or //NOPMD. Defaults to Sev5.

While this is a nuclear option, the ability to flag every use of suppression will ensure that devs don't do bad things and include an override.

Code Sample: This should include code, that should be flagged by the rule. If possible, the "correct" code
according to this new rule should also be demonstrated.

List<Account> aList = [SELECT Id FROM Account WITH SYSTEM_MODE]; //NOPMD

Possible Properties:

  • Should this rule be customizable via properties?
    It would be nice to have, for the annotation, a special string that would bypass this violation. In effect, a meta-suppression. This isn't ideal, but I think we need to have a way to flag things so PMD is a solid screening tool.

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

The issue names the proposed WarningSuppression rule and provides an Apex sample, but it names no files, tests, or entry points. Start by locating existing handling for @SuppressWarnings and //NOPMD, then verify that any use is reported at Sev5 and that the requested bypass property behavior is defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.