GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] ArrayIsStoredDirectly reports duplicated violation · Issue #3879 · pmd/pmd

[java] ArrayIsStoredDirectly reports duplicated violation #3879

New issue
Copy link
New issue
Copy link
Closed
#3930
Closed
[java] ArrayIsStoredDirectly reports duplicated violation#3879
#3930
Copy link
Assignees
adangel
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.45.0

Description

@MetaBF
MetaBF
opened on Mar 29, 2022
Issue body actions

Affects PMD Version: 6.44.0

Rule: ArrayIsStoredDirectly
https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#arrayisstoreddirectly

Description:
PMD alert twice at line 5 in the following example. I think a single warning at line 7 is better since it's where the store operation takes place.

Code Sample demonstrating the issue:

public class ExampleAISD { 

    public String[] strs;

    public void func(String[] strs, boolean flag) { // line 5
        if (flag) {
            this.strs = strs; // line 7
        }
    }
}

Expected outcome:

PMD reports twice at line 5, but that's wrong.

Running PMD through: [CLI]

Activity

  1. MetaBF
    added
    a:false-positivePMD flags a piece of code that is not problematic
    on Mar 29, 2022
  2. MetaBF commented on Apr 20, 2022

    @MetaBF
    MetaBF
    on Apr 20, 2022
    Author
    More actions

    @oowekyala

  3. adangel commented on Apr 21, 2022

    @adangel
    adangel
    on Apr 21, 2022
    Member
    More actions

    I think, we have there two problems:

    1. I agree, it would be more useful, if the rule would report the violation on line 7. The current code always reports the formal parameter. That would be an improvement
    2. We seem to be confused by the field name - which is the same as the parameter name: strs...
    Reacted by MetaBF
  4. adangel
    changed the title [-][java] - ArrayIsStoredDirectly alert twice at improper line[/-] [+][java] ArrayIsStoredDirectly alert twice at improper line[/+] on Apr 21, 2022
  5. adangel
    self-assigned this
    on Apr 21, 2022
  6. adangel
    changed the title [-][java] ArrayIsStoredDirectly alert twice at improper line[/-] [+][java] ArrayIsStoredDirectly reports duplicated violation[/+] on Apr 21, 2022
  7. adangel
    added this to the 6.45.0 milestone on Apr 21, 2022
  8. adangel
    added a commit that references this issue on Apr 21, 2022

    [java] ArrayIsStoredDirectly - fix tree traversal

    This issue will close once commit 8d5c2e5 is merged into the 'main' branch.
    8d5c2e5
  9. adangel
    closed this as completedin #3930on Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @adangel
    adangel

Labels

a:false-positivePMD flags a piece of code that is not problematic

Type

No type

Projects

No projects

    Milestone

    • 6.45.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.