From e39785564d40b0b2a1c7df0a1743a532d62fc73c Mon Sep 17 00:00:00 2001 From: Nils Werner <64034005+nils-werner-sonarsource@users.noreply.github.com> Date: Tue, 29 Mar 2022 09:47:35 +0200 Subject: [PATCH] Modify rule S6331: Add Python as covered language (#798) --- rules/S6331/description.adoc | 2 +- rules/S6331/implementation.adoc | 17 +++++++++++++++++ rules/S6331/php/rule.adoc | 18 +----------------- rules/S6331/python/metadata.json | 2 ++ rules/S6331/python/rule.adoc | 17 +++++++++++++++++ 5 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 rules/S6331/implementation.adoc create mode 100644 rules/S6331/python/metadata.json create mode 100644 rules/S6331/python/rule.adoc diff --git a/rules/S6331/description.adoc b/rules/S6331/description.adoc index 205bc7a9b7..2cd6c5a1e1 100644 --- a/rules/S6331/description.adoc +++ b/rules/S6331/description.adoc @@ -1,6 +1,6 @@ There are several reasons to use a group in a regular expression: -* to change the precedence (e.g. ``++/do(g|or)/++`` will match 'dog' and 'door') +* to change the precedence (e.g. `do(g|or)` will match 'dog' and 'door') * to remember parenthesised part of the match in the case of capturing group * to improve readability diff --git a/rules/S6331/implementation.adoc b/rules/S6331/implementation.adoc new file mode 100644 index 0000000000..b6b7426cb0 --- /dev/null +++ b/rules/S6331/implementation.adoc @@ -0,0 +1,17 @@ +ifdef::env-github,rspecator-view[] + +''' +== Implementation Specification +(visible only on this page) + +== Message + +Remove this empty group. + +== Highlighting + +The empty group should be highlighted. + +''' + +endif::env-github,rspecator-view[] diff --git a/rules/S6331/php/rule.adoc b/rules/S6331/php/rule.adoc index 4e0b3cff83..0f4195f0b3 100644 --- a/rules/S6331/php/rule.adoc +++ b/rules/S6331/php/rule.adoc @@ -14,20 +14,4 @@ include::../description.adoc[] "/foo\(\)/" // Matches 'foo()' ---- -ifdef::env-github,rspecator-view[] - -''' -== Implementation Specification -(visible only on this page) - -== Message - -Remove this empty group. - -== Highlighting - -The empty group should be highlighted. - -''' - -endif::env-github,rspecator-view[] \ No newline at end of file +include::../implementation.adoc[] diff --git a/rules/S6331/python/metadata.json b/rules/S6331/python/metadata.json new file mode 100644 index 0000000000..7a73a41bfd --- /dev/null +++ b/rules/S6331/python/metadata.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/rules/S6331/python/rule.adoc b/rules/S6331/python/rule.adoc new file mode 100644 index 0000000000..d0f672cf0a --- /dev/null +++ b/rules/S6331/python/rule.adoc @@ -0,0 +1,17 @@ +include::../description.adoc[] + +== Noncompliant Code Example + +[source,python] +---- +r"foo()" # Noncompliant, will match only 'foo' +---- + +== Compliant Solution + +[source,python] +---- +r"foo\(\)" # Matches 'foo()' +---- + +include::../implementation.adoc[]