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] MissingOverride: False negative for enum method · Issue #3542 · pmd/pmd

[java] MissingOverride: False negative for enum method #3542

New issue
Copy link
New issue
Copy link
Closed
#3543
Closed
[java] MissingOverride: False negative for enum method#3542
#3543
Copy link
Assignees
adangel
Labels
a:false-negativePMD doesn't flag a problematic piece of codein:type-resolutionAffects the type resolution code
Milestone
6.40.0

Description

@Zustin
Zustin
opened on Oct 7, 2021
Issue body actions

Affects PMD Version:6.39.0

Rule:MissingOverride

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/pmd-6.39.0/pmd_rules_java_bestpractices.html#missingoverride

Description:
PMD should have reported two warnings at line 3 and line 10. These two methods are inherited from superclass and they are belong to corresponding enum classes.

Code Sample demonstrating the issue:

public enum enumClazz {
    sub_EnumClazz {
        // missing @Override --> this is already reported
        public String toString() {
            return "test";
        }
        // missing @Override --> this violation is missing
        public void notOverride() {
            System.out.println("test");
        }
    };

    // missing @Override --> this is already reported
    public String toString() {
        return "test";
    }
    public void notOverride() {
        System.out.println("test");
    }
}

Expected outcome: Two warnings

PMD should report three violations at line 4, 8, and 14, but doesn't. Only 4 and 14 are reported. Line 8 is missing. This is a false-negative.

Running PMD through: [Maven]

Activity

  1. Zustin
    added
    a:false-negativePMD doesn't flag a problematic piece of code
    on Oct 7, 2021
  2. adangel
    changed the title [-][Java] A false negative about the rule MissingOverride[/-] [+][java] A false negative about the rule MissingOverride[/+] on Oct 7, 2021
  3. adangel commented on Oct 7, 2021

    @adangel
    adangel
    on Oct 7, 2021
    Member
    More actions

    Actually, the two violations for the missing override for the toString() methods are reported.
    However, there is a missing violation for the method notOverride() inside the enum value.

    Since you don't get the violations, you seem to do not execute PMD correctly (see also #3541) - how exactly do you run PMD? Do you have a project to share?

  4. adangel
    changed the title [-][java] A false negative about the rule MissingOverride[/-] [+][java] MissingOverride: False negative for enum method[/+] on Oct 7, 2021
  5. adangel
    self-assigned this
    on Oct 7, 2021
  6. adangel
    added
    in:type-resolutionAffects the type resolution code
    on Oct 7, 2021
  7. adangel
    added this to the 6.40.0 milestone on Oct 7, 2021
  8. adangel
    added a commit that references this issue on Oct 7, 2021

    [java] MissingOverride: False negative for enum method pmd#3542

    a1a3586
  9. Zustin commented on Oct 21, 2021

    @Zustin
    Zustin
    on Oct 21, 2021
    Author
    More actions

    Hi, Andreas! Thanks for your help. I have checked my project and the outcome is same as your comments.

  10. Zustin
    closed this as completedon Oct 21, 2021
  11. adangel commented on Oct 22, 2021

    @adangel
    adangel
    on Oct 22, 2021
    Member
    More actions

    Thanks for the feedback.
    I'm reopening this, because there is actually one false-negative, which will be fixed by #3543 .

  12. adangel
    reopened this on Oct 22, 2021
  13. adangel
    added a commit that references this issue on Oct 29, 2021

    Merge pull request pmd#3543 from adangel:issue-3542-missing-override-…

    15270c8
  14. adangel
    closed this as completedin #3543on Oct 29, 2021
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-negativePMD doesn't flag a problematic piece of codein:type-resolutionAffects the type resolution code

Type

No type

Projects

No projects

    Milestone

    • 6.40.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.