Skip to content

[core] Deprecate IntegerProperty#1485

Merged
adangel merged 4 commits into
pmd:masterfrom
oowekyala:deprecate-intproperty
Nov 28, 2018
Merged

[core] Deprecate IntegerProperty#1485
adangel merged 4 commits into
pmd:masterfrom
oowekyala:deprecate-intproperty

Conversation

@oowekyala

@oowekyala oowekyala commented Nov 28, 2018

Copy link
Copy Markdown
Member
  • I removed most internal usages, except where it was public (if it's public and in a concrete rule class I refactored it anyway).
  • I intend to do one such PR for each property type (depending on number of usages) so it will take some time. But after this one they'll mostly be independent so I can maybe open the PRs in parallel
  • I did the big documentation effort in this PR, next prs for other property types won't be as big

Refs #1432

@oowekyala oowekyala added this to the 6.10.0 milestone Nov 28, 2018
@ghost

ghost commented Nov 28, 2018

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

Generated by 🚫 Danger

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

Great, looks good!

Since arbitrary types may be represented, `type` will become obsolete as it can't represent generic types,
which will nevertheless be representable with the XML syntax. It was only used for documentation, but a
new way to document these properties exhaustively will be added with 7.0.0.
* {% jdoc :PDr#errorFor(java.lang.Object) %} is deprecated as its return type will be changed to `Optional<String>` with the shift to Java 8.

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.

This might be different - if we collect errors and return all violated constraints on the property, we might just add a List<String> errorsFor(T value) or something even more sophisticated. We could have a look e.g. at the bean validation api - there a Set<ConstraintValidation> is returned. So we could return something more structured than just a string.

= PropertyFactory.intProperty("problemDepth")
.desc("The if statement depth reporting threshold")
.range(1, 25).defaultValue(3).uiOrder(1.0f).build();
.require(positive()).defaultValue(3).build();

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.

Just wondered, whether we would have documented the minimum/maximum already (which we now change....) - but we don't: https://pmd.github.io/pmd-6.9.0/pmd_rules_apex_design.html#avoiddeeplynestedifstmts
So. no problem here. Limiting the the problemDepth to 25 was arbitrary anyways.

* <ul>
* <li>A name: filled-in when obtaining the builder
* <li>A description: see {@link #desc(String)}
* <li>A default value: see {@link #defaultValue(Object)}

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.

Is this a new requirement, that default values must be specified? This definitely makes sense!
I noticed, that the StatisticalRule defines properties with "null" as the default value... Which means, the property has no value, see https://pmd.github.io/pmd-6.9.0/pmd_rules_java_design.html#excessivemethodlength

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In fact that has been documented for a while, but not enforced properly ^^ Disallowing null values now allows to check easily whether the value was set or not.

StatisticalRule's properties exploit some of the cracks in the current framework. Reworking them is impossible, because the same descriptor is used for many rules, which don't share a sensible default value... so better scrap them directly when the time comes

*
* @author Brian Remedios
*/
@Deprecated

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.

We should make sure that we cover the testcases in a new unit test class.

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 think, this is probably covered by NumericConstraintsTest and PropertyDescriptorTest.

@adangel adangel merged commit 5c58e12 into pmd:master Nov 28, 2018
@oowekyala oowekyala deleted the deprecate-intproperty branch November 28, 2018 23:46
@oowekyala oowekyala added the is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them label Dec 3, 2018
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.

2 participants