Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrite Rule Properties Without Excluding the Rule #664

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

tis-dm-webfactory
Copy link

@tis-dm-webfactory tis-dm-webfactory commented Aug 14, 2019

Add possibility to modify rule properties via config file without defining a completely new rule like this:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="pcsg-generated-ruleset"
         xmlns="http://pmd.sf.net/ruleset/1.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
         xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
    <description>Created with the PHP Coding Standard Generator.
        http://edorian.github.com/php-coding-standard-generator/
    </description>

    <rule ref="rulesets/design.xml" />
    <rule name="CouplingBetweenObjects">
        <properties>
            <property name="maximum" value="20" />
        </properties>
    </rule>
</ruleset>

Fix #39

@kylekatarnls
Copy link
Member

Hi thanks, I like this feature a lot. I fixed the PHP 5.3 compatibility in your PR (please pull the change). Could you now add a unit test for that?

And it would be perfect to add a note about this in https://github.com/phpmd/phpmd/blob/master/src/site/rst/documentation/creating-a-ruleset.rst

So other users will know this exists.

@tis-dm-webfactory
Copy link
Author

hi Kyle,

yeah sure - I've added two (simple) tests and also wrote a paragraph about how this feature works.
I've pushed it in our repo - if you need another pull request just let me know.

kylekatarnls
kylekatarnls previously approved these changes Aug 14, 2019
Copy link
Member

@kylekatarnls kylekatarnls left a comment

Choose a reason for hiding this comment

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

Very nice!

MarkVaughn
MarkVaughn previously approved these changes Aug 21, 2019
Copy link
Collaborator

@MarkVaughn MarkVaughn left a comment

Choose a reason for hiding this comment

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

Noice

@kylekatarnls
Copy link
Member

@ravage84 A last word on this before merging?

Copy link
Member

@ravage84 ravage84 left a comment

Choose a reason for hiding this comment

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

If I understand this PR correctly, it adds the possibility to overwrite the properties of rules without excluding them, once they are added through a rule set, correct?

src/main/php/PHPMD/RuleSetFactory.php Outdated Show resolved Hide resolved
src/main/php/PHPMD/RuleSetFactory.php Outdated Show resolved Hide resolved
src/test/php/PHPMD/RuleSetFactoryTest.php Outdated Show resolved Hide resolved
src/test/php/PHPMD/RuleSetFactoryTest.php Outdated Show resolved Hide resolved
src/test/resources/files/rulesets/refset5.xml Outdated Show resolved Hide resolved
src/test/resources/files/rulesets/refset5.xml Outdated Show resolved Hide resolved
src/test/resources/files/rulesets/set3.xml Outdated Show resolved Hide resolved
src/test/resources/files/rulesets/set3.xml Outdated Show resolved Hide resolved
@kylekatarnls kylekatarnls self-requested a review August 21, 2019 15:11
Daniel Fischer added 3 commits August 23, 2019 13:02
fixed errors from copy/paste in test rulesets
added description to test ruleset to say what's going on
extract searching for a rule to a method
improve/modify comments for added methods
@tis-dm-webfactory
Copy link
Author

tis-dm-webfactory commented Aug 26, 2019

@ravage84

If I understand this PR correctly, it adds the possibility to overwrite the properties of rules without excluding them, once they are added through a rule set, correct?

absolutely correct ;-)

@tis-dm-webfactory
Copy link
Author

@ravage84
@MarkVaughn
@kylekatarnls
do you need any more changes? there's been no more comments since my last update.

kylekatarnls
kylekatarnls previously approved these changes Sep 17, 2019
Copy link
Member

@kylekatarnls kylekatarnls left a comment

Choose a reason for hiding this comment

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

It's alright for me.

@kylekatarnls
Copy link
Member

I fixed the test to make it check what it intended to and sadly it fails (0 instead of 42 in test1 property).

@kylekatarnls
Copy link
Member

I checked, It's just a problem with the test. The feature works properly with the example given in the new documentation.

@kylekatarnls
Copy link
Member

Test fixed. It was a naming problem: RuleOneInThirdRuleSet instead of RuleOneInFifthRuleSet as it refers to the set3.xml.

kylekatarnls
kylekatarnls previously approved these changes May 23, 2020
Copy link
Member

@kylekatarnls kylekatarnls left a comment

Choose a reason for hiding this comment

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

@tvbeek
Copy link
Member

tvbeek commented Apr 12, 2022

@tis-dm-webfactory I'm realizing that this is an old PR. Are you able to rebase it to handle the conflicts and let it run the tests with the GitHub actions?

@kylekatarnls kylekatarnls modified the milestones: 2.12.0, 2.13.0 Jun 19, 2022
@kylekatarnls kylekatarnls modified the milestones: 2.13.0, 2.14.0 Sep 10, 2022
@kylekatarnls kylekatarnls modified the milestones: 2.14.0, 2.15.0 Sep 27, 2023
@kylekatarnls kylekatarnls modified the milestones: 2.15.0, 2.16.0 Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Support ruleset ref + properties
5 participants