-
Notifications
You must be signed in to change notification settings - Fork 1
feat: ignore test paths #8
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
Conversation
codeql-config.yml
Outdated
- '**/test*' | ||
- '**/__test__/**' | ||
- '**/__tests__/**' | ||
- '**/*test.*' |
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.
Hmm, looking at https://github.com/search?q=org%3Aopengovsg+path%3A*test*&type=code I see a couple of matches like:
The rest that are in this search would be matched by the folder rules or maybe an additional folder:
- '**/test/*'
- '**/tests/*'
Would this make sense?
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.
Just to clarify is this what youre proposing?
- '**/*test*'
- '**/test/*'
- '**/tests/*'
I think that makes sense
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.
Yep! Actually just the foldernames
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.
Ok I figured out a way to test across all repos and I tested with
- '**/test/*'
- '**/tests/*'
- '**/__test__/*'
- '**/__tests__/*'
There are still some paths that are considered tests by AI and not covered
Of the above, I think we should add the unit tests and the playwright tests to the exclusion list with *.test.*
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.
Makes sense!
Context
This repo contains a custom codeql config which is used by some repos in their workflows.
We note that there are many CodeQL alerts generated from test files, which are all irrelevant as the tests are not deployed in production code.
Of 300+ alerts on our repo, 30+ of them are alerts from test files, and all of them have been evaluated to be ignoreable.
Approach
This PR adjusts the CodeQL config to remove test files from being scanned, using the
paths-ignore
directive.Risks
Due to the regex used, there is a possibility of interpreting non-test files as test files and therefore ignoring them.
However the reduction in false positives should readily outweigh potentially missing a finding or two.