-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat: add support for skipcq comments to ignore issues #154
base: master
Are you sure you want to change the base?
feat: add support for skipcq comments to ignore issues #154
Conversation
Signed-off-by: Maharshi Basu <[email protected]>
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
Current behaviorTesting with Test file (without skipcq comment) import ssl
from pyOpenSSL import SSL
# <expect-error>
ssl.wrap_socket(ssl_version=ssl.PROTOCOL_SSLv2)
# <expect-error>
SSL.Context(method=SSL.SSLv2_METHOD)
# <expect-error>
SSL.Context(method=SSL.SSLv23_METHOD) Globstar logs Test file (with skipcq comment) import ssl
from pyOpenSSL import SSL
# <expect-error>
ssl.wrap_socket(ssl_version=ssl.PROTOCOL_SSLv2)
# <expect-error>
SSL.Context(method=SSL.SSLv2_METHOD)
# <expect-error>
SSL.Context(method=SSL.SSLv23_METHOD) # skipcq Globstar logs |
Signed-off-by: Maharshi Basu <[email protected]>
Current behaviour
|
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.
Checking for skipcq can be done as a post-processor, after all the analysis has run.
It'd be best if you could add unit tests as well.
// utility function to check if a node or its line has a skipcq comment | ||
// Format for the skipcq directive: | ||
// `// skipcq: <language>:<checker_name>` | ||
func HasSkipCQComment(source []byte, node *sitter.Node, checker YamlChecker) bool { |
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.
Instead of regex-based search for a comment, I'd recommend using tree-sitter to search for all comments, and then using a function like this to match if it is a valid skipcq comment.
var directive string | ||
var found bool | ||
|
||
commentFormats := []struct { |
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.
Comment identifier should be based on the language.
This PR introduces support for
skipcq
comments to ignore specific issues in the source code.Checklist
skipcq
functionality (ignores all checkers)Related to #135