rspec/rules/S5857/java/rule.adoc

38 lines
575 B
Plaintext
Raw Normal View History

include::../description.adoc[]
2021-04-28 16:49:39 +02:00
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
<.+?>
".*?"
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
<[^>]++>
"[^"]*+"
----
or
----
<[^>]+>
"[^"]*"
----
2021-04-28 16:49:39 +02:00
== Exceptions
This rule only applies in cases where the reluctant quantifier can easily be replaced with a negated character class. That means the repetition has to be terminated by a single character or character class. Patterns such as the following, where the alternatives without reluctant quantifiers are more complicated, are therefore not subject to this rule:
----
<!--.*?-->
/\*.*?\*/
----