Skip to content

[core] Deprecate string property and string multi property#1501

Merged
adangel merged 11 commits into
pmd:masterfrom
oowekyala:deprecate-string-property
Dec 5, 2018
Merged

[core] Deprecate string property and string multi property#1501
adangel merged 11 commits into
pmd:masterfrom
oowekyala:deprecate-string-property

Conversation

@oowekyala

Copy link
Copy Markdown
Member

Refs #1432

Many usages cannot be replaced just yet, because they are published API. Interestingly, AvoidDuplicateLiterals tried to implement its own StringMultiProperty based on a StringProperty, which makes it really hard to refactor. I think it's better to leave it like that until 7.0.0.

There's surprisingly nearly nothing to do for #1027, and all of it will have to wait for 7.0.0. I suppose we don't use so many regexes.

@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 4, 2018
@oowekyala oowekyala added this to the 6.10.0 milestone Dec 4, 2018
@ghost

ghost commented Dec 4, 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
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.

Can you have a look, whether we need the delim(",") call for the stringListProperties?
We should probably make the properties of Rule (violationSuppression**) and XPathRule (xpath, version) and all properties of all renderers private/package private in 7.0.0. I don't see a use case to have them public. Wdyt?

* matching a regular expression.
*/
// TODO 7.0.0 use PropertyDescriptor<Pattern>
StringProperty VIOLATION_SUPPRESS_REGEX_DESCRIPTOR = new StringProperty("violationSuppressRegex",

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.

Ok, we can't switch it now, because the properties are a field of the interface Rule - which makes it public API.

Maybe we should remove it here in the (Java) API in 7.0.0? The only API left would be, when using a rule and setting the properties in the ruleset xml. There the type doesn't matter - since the String is then automatically converted into a Pattern.

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.

Yeah it would make sense to hide the descriptors. But we should probably allow setting these from Java somehow, for external tools that edit rules. The descriptors are definitely an implementation detail

public class XPathRule extends AbstractRule {

// TODO 7.0.0 use PropertyDescriptor<String>
public static final StringProperty XPATH_DESCRIPTOR = StringProperty.named("xpath")

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.

Same here - the properties of XPathRule shouldn't probably be public.
Maybe tag them for now as @internalapi?

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 I think for 7.0.0 XPathRule as a whole should be internal API. Since we're introducing XML sugar for XPath rules, we could jump on the occasion to completely hide away the implementation of XPath rules, and only provide a set of interfaces as API. That would allow language implementations to use different XPath rule classes at their discretion, and us to change the implementation transparently for any users. XPathRule's API would anyway be significantly broken by dropping Jaxen...

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.

Yes, this makes sense, having XPathRule as whole internal API.

public class YAHTMLRenderer extends AbstractAccumulatingRenderer {

public static final String NAME = "yahtml";
// TODO 7.0.0 use PropertyDescriptor<Optional<File>> with a constraint that the file is an existing directory

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 like it

*/
public class GenericClassCounterRule extends AbstractJavaRule {

// Class is unused, properties won't be converted

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.

On first look, this rule might be use case for multi file analysis...

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.

Maybe... We should probably scrap the class and add its purpose somewhere on the roadmap

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.

Yes, no need to keep this class - we should just keep the idea/purpose of the rule.

@adangel adangel self-assigned this Dec 5, 2018
@adangel adangel merged commit 9cb7ac6 into pmd:master Dec 5, 2018
@oowekyala oowekyala deleted the deprecate-string-property branch December 6, 2018 00:59
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