-
Notifications
You must be signed in to change notification settings - Fork 6
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
NEW Use symfony/finder to perform file lookups in checks #10
NEW Use symfony/finder to perform file lookups in checks #10
Conversation
e6f23b4
to
0291ddb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor things, and a query.
src/Check/CodeOrSrcFolderCheck.php
Outdated
->in($this->getSuite()->getModuleRoot()) | ||
->name('/code|src$/'); | ||
|
||
$this->setSuccessful(count($files) === 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have both code and src this will fail. It used to pass. Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was intentional because I figured you wouldn't have either, but I suppose that PSR-4 could be pointing at src
while devs could have something else in code for any reason, and that's valid. I'll update this and the test
$files = $this->getFinder() | ||
->files() | ||
->in($this->getSuite()->getModuleRoot()) | ||
->name('/contributing(?:\.md|\.txt)?$/i'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only have a smoke test that doesn't test the different paths of this. Perhaps a unit test to check the regex reliability would be good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, see AbstractFileCheckTest
src/Check/DocumentationCheck.php
Outdated
->in($this->getSuite()->getModuleRoot()) | ||
->name('docs'); | ||
|
||
$this->setSuccessful(count($files) > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we allow "doc" as equally valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure why not
break; | ||
} | ||
} | ||
$files = $this->getFinder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only have a smoke test that doesn't test the different paths of this. Perhaps a unit test to check the regex reliability would be good? I see you've done this for 'license'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's right - I only wrote the one test case because the logic in the readme and contributing check is the same thing as this one, so I've marked ReadmeCheckTest::testRun
as covering the other methods too. If you think its worthwhile I could duplicate the test for those cases as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, moved to AbstractFileCheckTest with individual cases for each file check's regex
This implements the symfony/finder component to replace manual filesystem checks, and uses regex patterns to reduce some duplication.
Resolves #2