Skip to content

[java] CommentRequired: make property names consistent - #2069

Merged
adangel merged 4 commits into
pmd:masterfrom
snuyanzin:PMD-1683
Dec 20, 2019
Merged

adangel merged 4 commits into
pmd:masterfrom
snuyanzin:PMD-1683

Conversation

@snuyanzin

Copy link
Copy Markdown
Contributor

The PR fixes #1683 by introducing a separate property for class comment and making header property checking only header top-level comments

@ghost

ghost commented Oct 15, 2019 •

Copy link
Copy Markdown
1 Message
📖 This changeset introduces 6939 new violations, 0 new errors and 0 new configuration errors,
removes 6933 violations, 2 errors and 2 configuration errors.
Full report
✅ This changeset introduces 6939 new violations, 0 new errors and 0 new configuration errors,
removes 6933 violations, 2 errors and 2 configuration errors.
Full report
✅ This changeset introduces 14995 new violations, 0 new errors and 0 new configuration errors,
removes 6931 violations, 2 errors and 2 configuration errors.
Full report

Generated by 🚫 Danger

@snuyanzin

Copy link
Copy Markdown
Contributor Author

I changed default value for headerCommentRequirement to reduce the number of violations in the report

@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.

Thanks for your PR!
Unfortunately, I don't think we can merge it as is: We should try to keep the change as backwards compatible as possible. This means:

  • Introducing a new property for class comments ✅ - already done: "classCommentRequirement"
  • Deprecate the property "headerCommentRequirement" - since this will be replaced by the correctly named "classCommentRequirement".
    • You can achieve this by starting the property description with the string "Deprecated! ". Then it will be rendered in the documentation as deprecated.
    • To make the change for the users easier, we should then
      • log a deprecation warning, if this property is not the default (the default is, as before Required).
      • If the new property is the default value but the old, deprecated property is not, then use the value of the old deprecated property. This is the case, if some user configured the rule using the deprecated property
      • If the new property is not the default value, then we ignore the deprecated property value. The new property will be used. We would still log a warning, if the old deprecated property has a non-default value - because then the user configured both properties, which is wrong.
  • We might introduce a new property "packageCommentRequired" in order to check for formal comments for packages. However, this is completely different:
    • package javadoc comments are not in every file, but only in the file package-info.java
    • if the file package-info.java doesn't exist, we won't analyze it, so we can't require this comment
    • the only check we could do here is "Unwanted"
    • So, I'm not sure, whether checking for package comments makes sense at all?
  • IMHO header comments (such as license headers, ...) are not javadoc (/** ... */) comments, but normal (/* ... */) comments. The rule however only checks for javadoc/formal comments. So, header comments are irrelevant for this rule.
  • We should also improve the rule description: It currently talks about comments, which is not precise. We should clarify, that this rule only checks javadoc (formal) comments.

@adangel adangel changed the title [java][PMD-1683] Separate header comment from CommentRequired as class comm… [java] CommentRequired: Renamed property headerCommentRequirement Oct 19, 2019
@adangel adangel changed the title [java] CommentRequired: Renamed property headerCommentRequirement [java] CommentRequired: Rename property headerCommentRequirement Oct 19, 2019
@adangel adangel changed the title [java] CommentRequired: Rename property headerCommentRequirement [java] CommentRequired: make property names consistent Oct 19, 2019
@adangel adangel added the is:WIP For PRs that are not fully ready, or issues that are actively being tackled label Oct 25, 2019
@adangel adangel added this to the 6.21.0 milestone Dec 17, 2019
@adangel adangel removed the is:WIP For PRs that are not fully ready, or issues that are actively being tackled label Dec 17, 2019
@adangel
adangel merged commit 3ec8914 into pmd:master Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[java] CommentRequired property names are inconsistent

2 participants