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

Allow inverting/negating file and line RegEx rules #534

Closed
j-ulrich opened this issue Jun 16, 2015 · 4 comments · Fixed by #536
Closed

Allow inverting/negating file and line RegEx rules #534

j-ulrich opened this issue Jun 16, 2015 · 4 comments · Fixed by #536

Comments

@j-ulrich
Copy link

Often it is impossible or very hard to detect files/lines which do not contain a certain pattern using regular expressions while it is easy to match the files/lines which do contain the pattern.

Therefore, it would be great if the File RegEx rule and Line RegEx rule could be negated to generate an error if a file or line does not match the given regex.
There could be a checkbox on the rule creation popup to enabled/disable the negation.

Example use case: Detect header files without include guards/pragma once

@jmecosta
Copy link
Member

I suppose the include guards could be even a rule. We usually require this

@guwirth
Copy link
Collaborator

guwirth commented Jun 16, 2015

For me this sounds useful. I think it is less effort.

@guwirth guwirth added this to the M 0.9.4 milestone Jun 20, 2015
@guwirth guwirth self-assigned this Jun 20, 2015
@guwirth
Copy link
Collaborator

guwirth commented Jun 20, 2015

@j-ulrich please test #536

@j-ulrich
Copy link
Author

It works! Thank you! :-)

However, I had to skip the unit tests because they were failing due to path issues with 8.3 path names (I don't have a Linux box around at the moment).

I used this RegEx to detect the include guards: \s*#ifndef\s+(\w+)\s*\n#define\s+\1\s*\n[\w\W]+|[\w\W]*#pragma once\s*\n[\w\W]+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants