简体   繁体   English

代码嗅探器,如何验证只清除 PSR2?

[英]Code sniffer, How to validate just clear PSR2?

my configuration:我的配置:

phpcs --config-set default_standard PSR2

<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="test">
    <file>./../../web</file>

    <arg name="standard" value="PSR2"/>
    <arg name="extensions" value="php"/>
    <arg name="basepath" value="./../../"/>
    <arg name="tab-width" value="4"/>

    <rule ref="PSR2">
        <exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
        <exclude name="Generic.Files.LineLength.TooLong"/>
    </rule>

    <rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>

    <rule ref="Generic.WhiteSpace.ScopeIndent">
        <properties>
            <property name="indent" value="4"/>
            <property name="tabIndent" value="true"/>
        </properties>
    </rule>
</ruleset>

In report I have PSR1 , PSR2 , Generic and Squiz rules在报告中,我有PSR1PSR2GenericSquiz规则

How can I validate only clear PSR2 without Generic and Squiz ?如何在没有GenericSquiz情况下仅验证清晰的PSR2

And second things: where can I found standard documentation for Generic and Squiz ?第二件事:在哪里可以找到GenericSquiz的标准文档?

Thx.谢谢。

The PSR2 standard uses sniffs from other standards to enforce its rules. PSR2 标准使用来自其他标准的嗅探来执行其规则。 This is because there is a lot of overlap between standards and it doesn't make sense to duplicate the code.这是因为标准之间有很多重叠,复制代码没有意义。 So the PSR2 standard pulls in checks from other standards to enforce similar rules.因此 PSR2 标准从其他标准中提取检查以执行类似的规则。

When you tell PHP_CodeSniffer to check files using the PSR2 standard, you can be sure that it is only enforcing the PSR2 rules no matter what sniffs are being used to enforce it.当您告诉 PHP_CodeSniffer 使用 PSR2 标准检查文件时,您可以确定它只执行 PSR2 规则,无论使用什么嗅探来执行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM