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

Add the ability to disable rules through configuration #1223

Open
TravisCarden opened this issue Jun 16, 2023 · 0 comments
Open

Add the ability to disable rules through configuration #1223

TravisCarden opened this issue Jun 16, 2023 · 0 comments

Comments

@TravisCarden
Copy link

I would like the ability to disable rules in my deptrac.yaml without the use of custom events. (c.f. #1220.) Maybe something like this, for example:

deptrac:
    disable_rules:
        - DependsOnInternalToken

Examples from some other tools provide might be helpful:

PHPStan

https://phpstan.org/config-reference

parameters:

    # Enable/disable a feature by boolean "switch":
    treatPhpDocTypesAsCertain: false

    # Ignore errors by path:
    ignoreErrors:
        -
            message: '#Function pcntl_open not found\.#'
            paths:
                - build
                - tests

PHPCS

https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset

<ruleset name="Custom Standard" namespace="MyProject\CS\Standard">

    <!-- Configure a feature: -->
    <config name="zend_ca_path" value="/path/to/ZendCodeAnalyzer"/>

    <!-- Exclude all by path: -->
    <exclude-pattern>*/tests/*</exclude-pattern>
    <exclude-pattern>*/data/*</exclude-pattern>

    <!-- Exclude a rule by path: -->
    <rule ref="Squiz">
        <exclude name="Squiz.PHP.CommentedOutCode"/>
    </rule>

    <!-- Exclude a single sniff message. -->
    <rule ref="Squiz">
        <exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
    </rule>

    <!-- Exclude a whole category of sniffs. -->
    <rule ref="Squiz">
        <exclude name="Squiz.PHP"/>
    </rule>

    <!-- Exclude by path: -->
    <rule ref="Squiz.Strings.DoubleQuoteUsage">
        <exclude-pattern>*/tests/*</exclude-pattern>
        <exclude-pattern>*/data/*</exclude-pattern>
    </rule>

</ruleset>

Psalm

https://psalm.dev/docs/running_psalm/dealing_with_code_issues/

<issueHandlers>
  <!-- Exclude a rule altogether. -->
  <MissingPropertyType errorLevel="suppress" />

  <!-- Exclude a rule by path. -->
  <InvalidReturnType>
    <errorLevel type="suppress">
      <directory name="some_bad_directory" />
      <file name="some_bad_file.php" />
    </errorLevel>
  </InvalidReturnType>

</issueHandlers>

PHPMD

https://phpmd.org/documentation/creating-a-ruleset.html#excluding-rules-from-a-rule-set

<ruleset>

    <!-- Exclude parts of a rule. -->
    <rule ref="rulesets/naming.xml">
        <exclude name="LongClassName"/>
        <exclude name="ShortVariable" />
        <exclude name="LongVariable" />
    </rule>

</ruleset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants