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

Trim exceptions for StaticAccess #343

Merged
merged 3 commits into from Mar 10, 2016

Conversation

Projects
None yet
3 participants
@Gisleburt

Gisleburt commented Feb 3, 2016

Not sure how thrilled the xml purests will be however, it we trim the results of this list, we can split the exception string onto multiple lines.

Before:

    <rule ref="rulesets/cleancode.xml/StaticAccess">
        <properties>
            <property name="exceptions" value="\Foundry\Masonry\Core\Notification,\Foundry\Masonry\Core\GlobalRegister,\Foundry\Masonry\ModuleRegister\ModuleRegister,\Symfony\Component\Yaml\Yaml"/>
        </properties>
    </rule>

After:

    <rule ref="rulesets/cleancode.xml/StaticAccess">
        <properties>
            <property name="exceptions" value="
                \Foundry\Masonry\Core\Notification,
                \Foundry\Masonry\Core\GlobalRegister,
                \Foundry\Masonry\ModuleRegister\ModuleRegister,
                \Symfony\Component\Yaml\Yaml
                "/>
        </properties>
    </rule>

A better solution from an xml point of view might be to have individual elements for each exception, however this at least makes the XML file readable

@Gisleburt

This comment has been minimized.

Gisleburt commented Feb 3, 2016

Actually I spotted another problem in this class whereby it treats static access to classes in the same namespace differently to classes with a "use" statement. When a classes that has a use statement is statically accessed, the class name begins with a \, if it's in the same namespace and therefore doesn't need a use the full class name will appear without the leading \.

If you put the use in, this fixes the difference between the exception and the detection, but of course this is considered "unused code" by IDEs since you didnt need to do that.

PHP is fun. :)

I'll add that to this patch.

@ravage84 ravage84 added this to the 2.3.3 milestone Feb 3, 2016

@ravage84 ravage84 self-assigned this Feb 3, 2016

@ravage84 ravage84 modified the milestones: 2.3.3, 2.4.2 Mar 8, 2016

@manuelpichler manuelpichler modified the milestones: 2.4.2, 2.4.3 Mar 10, 2016

@manuelpichler manuelpichler merged commit 61c9099 into phpmd:master Mar 10, 2016

3 checks passed

Scrutinizer 1 updated code elements
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ravage84 ravage84 modified the milestones: 2.4.2, 2.4.3 Mar 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment