Create rule S5869[kotlin]: Character classes in regular expressions should not contain the same character twice (#441)
This commit is contained in:
parent
b35c9593c5
commit
fba9aabf26
@ -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[]
|
||||
|
3
rules/S5869/kotlin/metadata.json
Normal file
3
rules/S5869/kotlin/metadata.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
|
||||
}
|
28
rules/S5869/kotlin/rule.adoc
Normal file
28
rules/S5869/kotlin/rule.adoc
Normal 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[]
|
Loading…
x
Reference in New Issue
Block a user