Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Disallow overriding rule message #3280

Open
oowekyala opened this issue May 15, 2021 · 0 comments
Open

[core] Disallow overriding rule message #3280

oowekyala opened this issue May 15, 2021 · 0 comments
Labels
a:RFC A drafted proposal on changes to PMD, up for feedback form the team and community

Comments

@oowekyala
Copy link
Member

Is your feature request related to a problem? Please describe.
Many Java rules build complex messages that use information about the specific problem, eg to provide a suggested fix or an explanation. For instance UnnecessaryModifier, ApexDoc, LinguisticNaming. These rules use the method AbstractNode#addViolationWithMessage, which ignores Rule#getMessage.

In parallel, we document that it's supported to override the message from the ruleset.

  • I don't really see how that is a feature. Ideally rule messages should be informative and one should not want to replace them.
  • Message overriding doesn't work with the previously mentioned rules.
  • Another problem with the ability to override messages is that they make the rule configuration brittle. If we change the number of template parameters of a default rule message, a user overriding the message may see broken messages with unreplaced template variables.

Describe the solution you'd like Remove the ability to override the rule message in pmd 7.

Describe alternatives you've considered

  • Make addViolationWithMessage consider message override: this makes no sense. This overload is made to override the message from the rule implementation
  • Stop using addViolationWithMessage: then we'd lose something that actually helps building more helpful rule messages
  • Live with this and document which rules support messages and which don't: this is a big maintenance effort
  • Live with this like now: sounds like a bad idea to me...

Additional context

  • If anyone is using this feature please defend it
  • The only decent reason I could see to override violation messages is to translate them. But internationalization would be better done from pmd itself.
@oowekyala oowekyala added the a:RFC A drafted proposal on changes to PMD, up for feedback form the team and community label May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:RFC A drafted proposal on changes to PMD, up for feedback form the team and community
Projects
None yet
Development

No branches or pull requests

1 participant