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

NEW Use symfony/finder to perform file lookups in checks #10

Merged
merged 5 commits into from
May 10, 2018

Conversation

robbieaverill
Copy link
Contributor

This implements the symfony/finder component to replace manual filesystem checks, and uses regex patterns to reduce some duplication.

Resolves #2

Copy link
Member

@sminnee sminnee left a 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.

->in($this->getSuite()->getModuleRoot())
->name('/code|src$/');

$this->setSuccessful(count($files) === 1);
Copy link
Member

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?

Copy link
Contributor Author

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');
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, see AbstractFileCheckTest

->in($this->getSuite()->getModuleRoot())
->name('docs');

$this->setSuccessful(count($files) > 0);
Copy link
Member

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?

Copy link
Contributor Author

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()
Copy link
Member

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'.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

@robbieaverill robbieaverill removed their assignment May 10, 2018
@sminnee sminnee merged commit 7847da4 into silverstripe:master May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants