Skip to content

[core] Update properties framework#4380

Merged
adangel merged 118 commits into
pmd:masterfrom
oowekyala:port-properties
Aug 22, 2023
Merged

[core] Update properties framework#4380
adangel merged 118 commits into
pmd:masterfrom
oowekyala:port-properties

Conversation

@oowekyala

@oowekyala oowekyala commented Feb 5, 2023

Copy link
Copy Markdown
Member

Describe the PR

Update the property framework for PMD 7.

  • remove deprecated API
  • turn PropertyDescriptor into a class because it only needs a single implementation now
  • prepare the framework to support new XML syntax in the future. This PR does not change the XML schema, but changes its interpretation in the following places:
    • the delimiter attribute for property definitions is deprecated, produces a warning and its value is ignored.
    • the min and max attributes for property definitions of numeric properties are no longer required, and can now appear separately, or not at all.

Maybe the most arbitrary change is that I removed the ability to configure the delimiter for multi-value properties, and changed the default delimiter to a comma (,) for all properties. The default delimiter was previously inconsistent as string properties used | for some reason. Many properties were overwriting this with a comma, in an inconsistent and unpredictable manner. There is no change in expressivity as the comma may now be escaped by a backslash. The actual reason I did this is because having a custom delimiter complicates the round-tripping through RulesetWriter a lot. Also I expect that the new syntax for list properties (which is not in this PR) will anyway become a nicer way to write list properties when writing a comma-delimited list is ugly.

The API for rules (PropertyFactory) is unchanged except for a couple of new convenience methods, to create enumerated properties from an Enum class.
'

Related issues

Ready?

@oowekyala oowekyala changed the base branch from pmd/7.0.x to master April 20, 2023 15:22
@oowekyala oowekyala marked this pull request as ready for review May 28, 2023 13:11
@adangel adangel self-requested a review May 30, 2023 17:26
@adangel adangel self-assigned this May 30, 2023

@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! I finally got around to go through the changes.

I'm planning to work on the TODOs/comments myself in the next couple of days and merge it afterwards.

Comment thread docs/pages/pmd/userdocs/extending/defining_properties.md Outdated
Comment thread docs/pages/pmd/userdocs/extending/defining_properties.md
Comment thread docs/pages/release_notes.md Outdated
Comment thread docs/pages/release_notes.md
Comment thread docs/pages/release_notes.md
Comment thread pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java Outdated
Comment thread pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java Outdated
@adangel adangel mentioned this pull request Aug 12, 2023
4 tasks
@adangel adangel merged commit 027fb4b into pmd:master Aug 22, 2023
@oowekyala oowekyala deleted the port-properties branch August 23, 2023 09:09
@oowekyala

Copy link
Copy Markdown
Member Author

Thanks for finishing this @adangel !

adangel added a commit to adangel/pmd that referenced this pull request Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

an:enhancement An improvement on existing features / rules

Projects

None yet

2 participants