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

This commit is contained in:
Johann Beleites 2021-10-20 12:43:34 +02:00 committed by GitHub
parent b35c9593c5
commit fba9aabf26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 2 deletions

View File

@ -21,8 +21,8 @@ ifdef::env-github,rspecator-view[]
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::../message.adoc[]
include::highlighting.adoc[]
include::../highlighting.adoc[]
endif::env-github,rspecator-view[]

View File

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

View File

@ -0,0 +1,28 @@
include::../description.adoc[]
== Noncompliant Code Example
----
Regex("[0-99]") // Noncompliant, this won't actually match strings with two digits
Regex("[0-9.-_]") // Noncompliant, .-_ is a range that already contains 0-9 (as well as various other characters such as capital letters)
----
== Compliant Solution
----
Regex("[0-9]{1,2}")
Regex("[0-9.\\-_]")
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
endif::env-github,rspecator-view[]