Include-pattern/exclude-pattern in the PHP CodeSniffer rule doesn’t work.

Hello. I have a problem with PHP CodeSniffer settings. It looks like include/exclude patterns are not supported. I tired different approaches but result is always the same. 

In the CLI result is correct, but in the GUI, PHP_CS checks all rules for a file, regardless of the extension pattern in the rule.

I think problem started after plugin or PS update. I'm not sure.

Do you know how to solve this? 

 

ENV: PHPStorm: Build #PS-232.8660.205, MacOS 13.5, local: PHP 8.1, CodeSniffer 3.6.0, source

Prerequisites

vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard,../../phpcompatibility/php-compatibility/PHPCompatibility

CLI Test

vendor/bin/phpcs -i

Result: correct

The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1, PSR12, Magento2Framework and Magento2
vendor/bin/phpcs --standard=Magento2 app/code/Comapany/Module/Model/Test.php

Result: correct
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
28 | WARNING | [x] Closing brace must be on a line by itself
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

GUI Test

Result: too many warnings for *.php extension

Rule

<rule ref="Magento2.Templates.ThisInTemplate">
<include-pattern>*\.phtml$</include-pattern>
<severity>8</severity>
<type>warning</type>
</rule>

GUI Settings

0

Hi,
Apparently, you are experiencing the following issue:
https://youtrack.jetbrains.com/issue/WI-73310/Exclude-Include-patterns-based-on-file-path-in-quality-tools-configs-are-not-applied-when-run-a-tool-based-on-stdin

Could you please try to install PhpStorm 2023.2.1 Preview build and check if it is also reproducible for you there?

0

It's fixed in preview build of PHPStorm. Thanks.

0

Fantastic, thank you for the update!

0

请先登录再写评论。