-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JS: Promote js/regex/duplicate-in-character-class
to quality
#19711
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
JS: Promote js/regex/duplicate-in-character-class
to quality
#19711
Conversation
QHelp previews: javascript/ql/src/RegExp/DuplicateCharacterInCharacterClass.qhelpDuplicate character in character classCharacter classes in regular expressions (denoted by square brackets Common mistakes include:
RecommendationExamine each duplicate character to determine the intended behavior:
ExampleExample 1: Confusing character classes with groups The pattern if (/[password|pwd] =/.test(input))
console.log("Found password!"); To fix this problem, the regular expression should be rewritten to Example 2: CSS unit matching The pattern Similarly, References
|
84cc0c3
to
d68f5eb
Compare
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.
Pull Request Overview
Promote the js/regex/duplicate-in-character-class
query to the quality suite by adjusting metadata, expanding tests, and enhancing documentation.
- Update query tags from reliability to quality and include
correctness
®ular-expressions
- Add new regex patterns to
tst.js
and dynamic replacement tests intst_replace.js
, plus expected-alert entries - Enhance
.qhelp
with a clearer overview, recommendations, examples, and references; include the rule in the quality-suite integration tests
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
javascript/ql/test/query-tests/RegExp/DuplicateCharacterInCharacterClass/tst_replace.js | Added dynamic‐pattern replacement test functions and new test cases |
javascript/ql/test/query-tests/RegExp/DuplicateCharacterInCharacterClass/tst.js | Added a variety of new regex literals to trigger duplicate alerts |
javascript/ql/src/RegExp/DuplicateCharacterInCharacterClass.ql | Changed @tags from reliability to quality suite and added tags |
javascript/ql/src/RegExp/DuplicateCharacterInCharacterClass.qhelp | Expanded overview, recommendations, examples, and reference links |
javascript/ql/integration-tests/query-suite/javascript-code-quality.qls.expected | Added the duplicate-character-class rule to the code-quality suite |
Comments suppressed due to low confidence (2)
javascript/ql/test/query-tests/RegExp/DuplicateCharacterInCharacterClass/tst_replace.js:1
- [nitpick] Function names
reg
,reg1
,reg2
,reg3
are ambiguous; consider using more descriptive test function names to clarify their purpose.
function reg(){
javascript/ql/src/RegExp/DuplicateCharacterInCharacterClass.ql:9
- [nitpick] The
reliability
tag is on a separate line without an@tags
prefix; consolidate tags into a single@tags quality, reliability, correctness, regular-expressions
annotation for consistency.
* reliability
javascript/ql/test/query-tests/RegExp/DuplicateCharacterInCharacterClass/tst_replace.js
Show resolved
Hide resolved
javascript/ql/test/query-tests/RegExp/DuplicateCharacterInCharacterClass/tst_replace.js
Show resolved
Hide resolved
javascript/ql/test/query-tests/RegExp/DuplicateCharacterInCharacterClass/tst_replace.js
Show resolved
Hide resolved
javascript/ql/test/query-tests/RegExp/DuplicateCharacterInCharacterClass/tst_replace.js
Show resolved
Hide resolved
javascript/ql/test/query-tests/RegExp/DuplicateCharacterInCharacterClass/tst.js
Outdated
Show resolved
Hide resolved
…acterClass/tst.js Co-authored-by: Copilot <[email protected]>
The following pull request aims to promote
js/regex/duplicate-in-character-class
to quality-suite.