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
notName
/notPath
ignored if filename provided as parameter
#4882
Comments
Just to add, i tried using notPath, same it is not respected. Whereas the In fact, even |
From the documentation:
This means files passed as arguments on command line are always fixed, you should avoid passing them. |
@julienfalque Thanks for your return. I was aware of this, but specifing a path in cli, the config file is well taked into account despite what is said in documentation, using default path-mode. For instance: But with So there seems to really be a different behaviour between passing a path and a file. Path use config, file not. I will try --path-mode=intersection, thanks! |
Just tried with Running: Just to say, on our pipeline this is one of the very few tools which doesn't respect it's config when passing direct file fullpath on command lines. I think this issue could be reopend, and if it is not a bug but the intended way to work so this issue should be labeled as improvement, so it works same than other well-know linting tools Thanks. |
Mmmh indeed, maybe this could be improved, or the doc should be at least. |
This comment was marked as outdated.
This comment was marked as outdated.
Hi, should not be closed as it need a fix or documentation update. Thanks. |
notName
/notPath
ignored if filename provided as parameter
This comment has been minimized.
This comment has been minimized.
This bug currently prevents us from efficiently running through only the files that have been changed in a precommit hook instead of running through all files. IFS='
'
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB)
if [ -n "$CHANGED_FILES" ]; then
# EXTRA_ARGS=$(printf -- '--path-mode=override\n--\n%s' "${CHANGED_FILES}");
lib/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --path-mode=intersection -vv --stop-on-violation # --using-cache=no ${EXTRA_ARGS}
fi Running trough the complete project takes much more time and blocks somehow.. |
@s0me0ther I think #7777 can help you with this too, because parallel analysis would be faster for the whole project. Anyway, this issue should be solved so it's possible to specify list of paths and exclude some of them on config level. |
Since this issue has not had any activity within the last 90 days, I have marked it as stale. The purpose of this action is to enforce backlog review once in a while. This is mostly for maintainers and helps with keeping repository in good condition, because stale issues and PRs can accumulate over time and make it harder for others to find relevant information. It is also possible that some changes has been made to the repo already, and issue or PR became outdated, but wasn't closed for some reason. This action helps with periodic review and closing of such stale items in automated way. You may let maintainers handle this or verify current relevancy by yourself, to help with re-triage. Any activity will remove stale label so it won't be automatically closed at this point. I will close it if no further activity occurs within the next 30 days. |
Hello,
Using
->notName('*.html.php')
works fine if PHP CS Fixer is run on a directory.But if a file is passed
php php-cs-fixer.phar fix myfile.html.php
it get formated.It should not as the config forbid it.
Use case:
It breaks tools like lint-staged or other commit hook tools which send list of files. So even excluded name with notName are formated.
It is pretty dangerous and should clearly indicated in documentation that passing a file will ignore notName rules.
I didn't check if exclude/notPath are ignored or not...
But as rules of thumbs, what is said in config file should be respected whatever parameter (field or directory) is passed to php-cs-fixer.phar.
Hope it could be fixed.
For now the solution is to make shell wrappers to try to pre-check before running php-cs-fixer.phar or configure more grainy the commit hook tools to exclude files at this level.
Thanks.
The text was updated successfully, but these errors were encountered: