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

Explicitly passing paths/files to command should still honour the configured exclusions #498

Closed
3 tasks done
claudiu-cristea opened this issue May 17, 2024 · 2 comments
Closed
3 tasks done

Comments

@claudiu-cristea
Copy link

claudiu-cristea commented May 17, 2024

Describe the bug

phpcs.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="foo">
  <arg name="extensions" value="inc,php"/>
  <file>/var/www/html/</file>
  <exclude-pattern>/var/www/html/excluded.php</exclude-pattern>
</ruleset>

When I run

phpcs /var/www/html/excluded.php

The file shouldn't be checked because is has been excluded in phpcs.xml, which is used to run the command.

Here's a use case: I'm detecting all changed files when pushing to a Git remote repository because I want to run PHPCS on Git pre-push hook. The set of files may contain files that are excluded phpcs.xml. I'm expecting that, even I'm passing them to phpcs, as arguments, phpcs.xml is honoured.

Code sample

See "Describe the bug" section

Custom ruleset

See "Describe the bug" section

To reproduce

See "Describe the bug" section

Expected behavior

Even paths or files are passed as arguments to the command line, I'm expecting that file/path exclusions, configured in phpcs.xml are respected.

Versions (please complete the following information)

Operating System Linux
PHP version 8.3
PHP_CodeSniffer version 3.9.2
Standard custom
Install type Composer

Additional context

None.

Please confirm

  • I have searched the issue list and am not opening a duplicate issue.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • I have verified the issue still exists in the master branch of PHP_CodeSniffer.
@jrfnl
Copy link
Member

jrfnl commented May 17, 2024

@claudiu-cristea Thanks for reporting this, but I don't think this is a bug in PHPCS. Rather, I think this is a problem with the paths not matching.

And yes, I've tested and could not reproduce the issue with the scenarios I ran.

To help you figure this out, I need more information though.

  • Where is your phpcs.xml file located in your directory structure ?
  • What directory are your running PHPCS from ?
  • The paths provided look like absolute paths ? Is there a particular reason for using absolute paths ?

@jrfnl
Copy link
Member

jrfnl commented Jun 11, 2024

Closing for lack of feedback. The issue can be reopened if the OP responds.

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Jun 11, 2024
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

2 participants