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] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch · Issue #2737 · pmd/pmd

[java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch #2737

New issue
Copy link
New issue
Copy link
Closed
#3259
Closed
[java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch#2737
#3259
Copy link
Assignees
oowekyala
Labels
in:documentationAffects the documentation [doc]
Milestone
6.35.0

Description

@vojtapol
vojtapol
opened on Aug 24, 2020
Issue body actions

Affects PMD Version: 6.26.0

Description:
https://github.com/pmd/pmd/blob/master/pmd-java/src/main/resources/category/java/bestpractices.xml#L1277

The message of the rule is misleading for the case of exhaustive enums. When an enum case is missing it will prompt the developer to add a default case but an alternative solution which is likely more correct is to add the missing cases and make the switch exhaustive. I propose the message is updated to:

Switch statements should have a default label or be exhaustive in case of enums

I also have a question, what is the purpose of the <description> element in rules? Is there any way it could be printed alongside the rule message when the rule fails when using pmd-maven-plugin?

Activity

  1. vojtapol
    added
    a:bugPMD crashes or fails to analyse a file.
    on Aug 24, 2020
  2. oowekyala commented on Aug 24, 2020

    @oowekyala
    oowekyala
    on Aug 24, 2020
    Member
    More actions

    Your suggestion makes sense!

    The description of rules is used to generate documentation, like here on the website. I don't think the maven plugin can print the description. For some rules the description can be quite long though, so I think it's for the best. Maybe it would make sense to have a "short description" element, to give the gist of the rule?

  3. oowekyala
    added
    in:documentationAffects the documentation [doc]
    and removed
    a:bugPMD crashes or fails to analyse a file.
    on Aug 24, 2020
  4. vojtapol commented on Aug 25, 2020

    @vojtapol
    vojtapol
    on Aug 25, 2020
    Author
    More actions

    The description of rules is used to generate documentation, like here on the website.

    Thanks, that makes sense to me. I think the message is good enough as long as we make sure they have all the necessary info.

  5. oowekyala
    changed the title [-][java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault[/-] [+][java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch[/+] on Nov 11, 2020
  6. oowekyala
    added this to the 6.35.0 milestone on Apr 26, 2021
  7. oowekyala
    self-assigned this
    on Apr 26, 2021
  8. oowekyala
    added a commit that references this issue on May 6, 2021

    Improve doc of SwitchStmtsShouldHaveDefault, fix pmd#2737

    This issue will close once commit 223b4e6 is merged into the 'main' branch.
    223b4e6
  9. adangel
    closed this as completedin #3259on May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @oowekyala
    oowekyala

Labels

in:documentationAffects the documentation [doc]

Type

No type

Projects

No projects

    Milestone

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