Skip to content

[core] Deprecate missing language attribute on rule definition#2617

Merged
adangel merged 10 commits into
pmd:masterfrom
oowekyala:deprecate-set-lang-in-java
Jul 30, 2020
Merged

[core] Deprecate missing language attribute on rule definition#2617
adangel merged 10 commits into
pmd:masterfrom
oowekyala:deprecate-set-lang-in-java

Conversation

@oowekyala

@oowekyala oowekyala commented Jun 27, 2020

Copy link
Copy Markdown
Member

Describe the PR

Deprecate the practice of setting a rule's language in java rather than in the XML.

This also avoids parsing rulesets multiple times, otherwise the warning may be repeated. I do this simply by caching parsed rulesets in a RulesetFactory. Is this enough? I'm not sure

From #2612:

Some base rule classes use setLanguage in their constructor, so that the language attribute doesn't need to appear in the rule definition element. It would be easier for tooling if this attribute was mandatory (eg to categorise rules without loading them), and it irons out an inconsistency between languages, so probably we should issue a deprecation warning for that

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by travis)
  • Added (in-code) documentation (if needed)

@oowekyala oowekyala added this to the 7.0.0 milestone Jun 27, 2020
@oowekyala oowekyala added the is:WIP For PRs that are not fully ready, or issues that are actively being tackled label Jul 2, 2020
@ghost

ghost commented Jul 6, 2020

Copy link
Copy Markdown
1 Message
📖 This changeset introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report

Generated by 🚫 Danger

@oowekyala oowekyala removed the is:WIP For PRs that are not fully ready, or issues that are actively being tackled label Jul 6, 2020
@oowekyala oowekyala modified the milestones: 7.0.0, 6.27.0 Jul 18, 2020
@adangel adangel added the is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them label Jul 19, 2020

@adangel adangel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do this simply by caching parsed rulesets in a RulesetFactory. Is this enough? I'm not sure

I think, that's good enough for now. If not, we can improve it later.


### API Changes

* In PMD 7, The `language` attribute will be required on all `rule` elements that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add the keyword "ruleset" - possibly as a section heading. Otherwise it is not clear, what we are talking about here...
Otherwise this is a good explanation, thanks!

@adangel adangel self-assigned this Jul 30, 2020
adangel added a commit that referenced this pull request Jul 30, 2020
[core] Deprecate missing language attribute on rule definition #2617
@adangel adangel merged commit 7ccec3b into pmd:master Jul 30, 2020
@oowekyala oowekyala deleted the deprecate-set-lang-in-java branch July 30, 2020 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[core] Avoid parsing rulesets multiple times

2 participants