phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 431 forks source link

How can I just add a few regular expressions to validate? #257

Closed Bilge closed 7 years ago

Bilge commented 7 years ago
Q A
Question? yes

I just want to add a list of regular expressions that must pass for each commit. This should be a simple task but the documentation is not clear on how to do this at all. How do I do this?

jyggen commented 7 years ago

It depends on what you want to match the regexps against really. File names? File contents? Commit messages?

Bilge commented 7 years ago

File contents.

On 9 Jan 2017 23:24, "Jonas Stendahl" notifications@github.com wrote:

It depends on what you want to match the regexps against really. File names? File contents? Commit messages?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/phpro/grumphp/issues/257#issuecomment-271440089, or mute the thread https://github.com/notifications/unsubscribe-auth/AAcuYgtaFChtepwREuZsw8H5fXX9iEApks5rQsGegaJpZM4Lexlb .

veewee commented 7 years ago

Hello @Bilge,

Currently there is no task for matching file contents against regexes. If you e.g. want to check class docblocks for copyright information, you could use the phpparser task, but you would have to create your own visitor. Another option is to create a task that matches file content against a regular expression.

Bilge commented 7 years ago

Do I understand the correct way to implement this is to write a custom task?

veewee commented 7 years ago

Yes, you'll need to create your own task for that.