gpt4 book ai didi

PHPcs xml 配置禁用一些规则

转载 作者:行者123 更新时间:2023-12-03 21:23:20 24 4
gpt4 key购买 nike

我了解如何使用 xml 配置 phpcs,但找不到如何禁用某些嗅探。这是我目前的配置(甚至不知道这是否正确):

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="custom"
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">
<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/controversial.xml/Superglobals"/>
<rule ref="rulesets/controversial.xml/CamelCaseParameterName"/>
<rule ref="rulesets/controversial.xml/CamelCaseVariableName"/>
<rule ref="rulesets/design.xml"/>
<rule ref="rulesets/naming.xml/ShortMethodName"/>
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass"/>
<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>
<rule ref="rulesets/naming.xml/BooleanGetMethodName">
<properties>
<property name="checkParameterizedMethods" value="true"/>
</properties>
</rule>
<rule ref="rulesets/unusedcode.xml"/>

<arg name="tab-width" value="2"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="2"/>
</properties>
</rule>

<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="140"/>
<property name="absoluteLineLimit" value="0"/>
</properties>
</rule>
</ruleset>

我想禁用这些:
  • [phpcs] @copyright tag must contain a year and the name of the copyright holder所有文档评论嗅探(我不需要它们)
  • [phpcs] PHP version not specified
  • [phpcs] There must be exactly one blank line before the tags in a doc comment
  • [phpcs] The open comment tag must be the only content on the line
  • [phpcs] Missing short description in doc comment
  • [phpcs] The close comment tag must be the only content on the line
  • [phpcs] Line indented incorrectly; expected at least 4 spaces, found 2我用了两个空格!
  • [phpcs] Missing file doc comment
  • [phpcs] Line exceeds 85 characters; contains 91 characters我希望最多 140

  • 如果我想添加更多,我可以在哪里搜索可能的配置?

    最佳答案

    忽略规则的另一种方法是使用 --exclude旗帜。

    vendor/bin/phpcs --standard=PSR2  --exclude=Generic.Files.LineLength,Generic.WhiteSpace.ScopeIndent app/

    为了找到要排除的规则名称,请在以下目录中找到相应的规则集:
    vendor/squizlabs/php_codesniffer/src/Standards/<coding standard>/ruleset.xml
    规则名称将在 中引用 节点:
     <rule ref="Generic.Files.LineLength">
    <properties>
    <property name="lineLimit" value="120"/>
    <property name="absoluteLineLimit" value="0"/>
    </properties>
    </rule>

    与创建单独的规则集相比,它更快、更简单。

    关于PHPcs xml 配置禁用一些规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50944925/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com