Create rule S5869[javascript]: Character classes in regular expressions should not contain the same character twice (#267)

This commit is contained in:
Yassin Kammoun 2021-09-03 14:17:40 +02:00 committed by GitHub
parent fe53c11d24
commit de831a5e80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,3 @@
{
}

View 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.\-_]/
----

View File

@ -12,7 +12,9 @@
"extra": {
"coveredLanguages": [
"Java",
"PHP"
"PHP",
"JavaScript",
"TypeScript"
],
"replacementRules": [