Create rule S5869[javascript]: Character classes in regular expressions should not contain the same character twice (#267)
This commit is contained in:
parent
fe53c11d24
commit
de831a5e80
3
rules/S5869/javascript/metadata.json
Normal file
3
rules/S5869/javascript/metadata.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
|
||||
}
|
16
rules/S5869/javascript/rule.adoc
Normal file
16
rules/S5869/javascript/rule.adoc
Normal file
@ -0,0 +1,16 @@
|
||||
include::../description.adoc[]
|
||||
|
||||
== Noncompliant Code Example
|
||||
|
||||
----
|
||||
/[0-99]/ // Noncompliant, this won't actually match strings with two digits
|
||||
/[0-9.-_]/ // Noncompliant, .-_ is a range that already contains 0-9 (as well as various other characters such as capital letters)
|
||||
----
|
||||
|
||||
|
||||
== Compliant Solution
|
||||
|
||||
----
|
||||
/[0-9]{1,2}/
|
||||
/[0-9.\-_]/
|
||||
----
|
@ -12,7 +12,9 @@
|
||||
"extra": {
|
||||
"coveredLanguages": [
|
||||
"Java",
|
||||
"PHP"
|
||||
"PHP",
|
||||
"JavaScript",
|
||||
"TypeScript"
|
||||
],
|
||||
"replacementRules": [
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user