LoginSignup
0
0

More than 1 year has passed since last update.

PHPMDの既存ルールセットのうち特定ルールだけ変更

Last updated at Posted at 2021-10-25

priorityを変更する

例えば、rulesets/codesize.xmlのルールを読み込みつつ、特定のルールだけ変更したい。

  1. rulesets/codesize.xmlを読み込み、変更したいルールを除外する
  2. 改めてrulesets/codesize.xml/xxxxで個別にルールを読み込み、設定を変更する
phpmd.xml
<?xml version="1.0"?>
<ruleset name="change priority"
         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>
        change prioriy
    </description>

    <!-- ルールセットを読み込む -->
    <rule ref="rulesets/codesize.xml">
        <!-- プライオリティを変更したいルールを除外 -->
        <exclude name="ExcessivePublicCount"/>
    </rule>
    <!-- 改めてルールを読み込んでプライオリティを変更 -->
    <rule ref="rulesets/codesize.xml/ExcessivePublicCount">
        <priority>5</priority>
    </rule>
</ruleset>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0