editorconfig-checker/editorconfig-checker.php

Search for .editorconfig recursively

Closed this issue · 2 comments

The tool currently tries to load the .editorconfig relativly to wherever it was started from. See https://github.com/editorconfig-checker/editorconfig-checker.php/blob/master/src/EditorconfigChecker/Cli/Cli.php#L27-L28

Issue 1: When I call it in »/tmp/« and want to check files in »/var/www/« it will fail, due to a missing EditorConfig in »/tmp/«.

Issue 2: A repository may have several .editorconfig files. For example one for the project itself and a custom one in a subfolder containing an old library with different code styles. The tool will then report false negatives.

For both issues it would be a good solution if there would be a recursive search for .editorconfig files. This should be done for each file/folder of course.

Hey @mstruebing I tested this new feature and ran into an error unfortunately. 😓 I executed ./bin/editorconfig-checker -e '\.(png|jpg|gif|ico|svg|js|css|lock|git)$' /home/johndoe/git/acme/src/php/* and got an exception (memory limit exhausted).

First issue: The valid editorconfig /home/johndoe/git/acme/src/php/.editorconfig is not found.

Second issue: The script searched for an editorconfig, could not find one, switched into the parent directory, could not find one, switched into the parent… and so on. If no editorconfig is found, then the find method will run indefinitely. Solution: Catch if the root is reached, cancel and show an error.

Thank you again :)
I will definitely harden the implementation as it is for now just a real naive one and will add some test cases before the next release. I hope to make it soon.

Could you test the auto-fix feature too?