Skip to content

Commit 43295e2

Browse files
Curly braces should not be a quantifier in general (#981)
* Curly braces should not be a quantifier in general * Adapt ITS expected results Co-authored-by: Karim El Ouerghemmi <[email protected]>
1 parent 2db67cb commit 43295e2

File tree

5 files changed

+13
-35
lines changed

5 files changed

+13
-35
lines changed

its/ruling/src/test/resources/expected/python-S5843.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
'project:django-2.2.3/django/utils/translation/template.py':[
1616
29,
1717
],
18+
'project:django-2.2.3/django/utils/translation/trans_real.py':[
19+
35,
20+
],
1821
'project:numpy-1.16.4/numpy/f2py/crackfortran.py':[
1922
874,
2023
878,

its/ruling/src/test/resources/expected/python-S5856.json

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
'project:biopython/Bio/motifs/pfm.py':[
33
338,
44
],
5-
'project:buildbot-slave-0.8.6p1/buildslave/runprocess.py':[
6-
300,
7-
],
8-
'project:django-2.2.3/django/utils/translation/trans_real.py':[
9-
36,
10-
],
115
'project:mypy-0.782/test-data/stdlib-samples/3.2/glob.py':[
126
76,
137
77,
@@ -18,19 +12,10 @@
1812
'project:tensorflow/python/distribute/cluster_resolver/slurm_cluster_resolver.py':[
1913
75,
2014
],
21-
'project:tensorflow/python/keras/callbacks.py':[
22-
1373,
23-
],
24-
'project:tensorflow/tools/docs/py_guide_parser.py':[
25-
65,
26-
],
2715
'project:tornado-2.3/demos/appengine/markdown.py':[
2816
826,
2917
],
3018
'project:tornado-2.3/demos/blog/markdown.py':[
3119
826,
3220
],
33-
'project:twisted-12.1.0/twisted/words/protocols/jabber/sasl.py':[
34-
84,
35-
],
3621
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<mockito.version>3.9.0</mockito.version>
9292
<sonar.version>8.9.0.43852</sonar.version>
9393
<sonar.orchestrator.version>3.35.1.2719</sonar.orchestrator.version>
94-
<sonar-analyzer-commons.version>1.21.0.818</sonar-analyzer-commons.version>
94+
<sonar-analyzer-commons.version>1.21.0.821</sonar-analyzer-commons.version>
9595
<sonarlint-core.version>6.0.0.32513</sonarlint-core.version>
9696
<sslr.version>1.23</sslr.version>
9797
<protobuf.version>3.17.3</protobuf.version>

python-checks/src/test/resources/checks/regex/invalidRegexCheck.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ def non_compliant(input):
55
re.match(r'(', input) # Noncompliant {{Fix the syntax error inside this regex.}}
66
# ^
77
# ^@-1< {{Expected ')', but found the end of the regex}}
8-
re.match(r'x{1,2,3}|(', input) # Noncompliant {{Fix the syntax errors inside this regex.}}
9-
# ^
10-
# ^@-1< {{Expected '}', but found ','}}
11-
# ^@-2< {{Expected ')', but found the end of the regex}}
128
re.match(r'$[a-z^', input) # Noncompliant {{Fix the syntax error inside this regex.}}
139
# ^
1410
# ^@-1< {{Expected ']', but found the end of the regex}}
@@ -22,19 +18,13 @@ def compliant(input):
2218

2319

2420
def unsupported_feature(input):
25-
re.match(r'\p{Lower}', input) # Noncompliant
21+
# atomic group
2622
re.match(r'(?>x)', input) # Noncompliant
23+
# possessive quantifier
2724
re.match(r'x*+', input) # Noncompliant
2825

2926

3027
def false_positives():
3128
re.compile(r"\s*([ACGT])\s*[[]*[|]*\s*([0-9.\s]+)\s*[]]*\s*") # Noncompliant
32-
# Noncompliant@+3
33-
re.compile(r'''
34-
([A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*|\*) # "en", "en-au", "x-y-z", "es-419", "*"
35-
(?:\s*;\s*q=(0(?:\.\d{,3})?|1(?:\.0{,3})?))? # Optional "q=1.00", "q=0.8"
36-
(?:\s*,\s*|$) # Multiple accepts per header.
37-
''', re.VERBOSE)
3829
re.compile(r'^\s+\[([\s*[0-9]*)\] ([a-zA-Z0-9_]*)') # Noncompliant
3930
re.compile(r'([^,[\]]*)(\[([^\]]+)\])?$') # Noncompliant
40-
re.compile(r'{.*}') # Noncompliant

python-checks/src/test/resources/checks/regex/stringReplaceCheck.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
def non_compliant():
44
input = "Bob is a Bird... Bob is a Plane... Bob is Superman!"
5-
changed = re.sub(r"Bob is", "It's", input) # Noncompliant {{Replace this "re.sub()" call by a "str.replace()" function call.}}
5+
changed = re.sub(r"Bob is", "It's", input) # Noncompliant {{Replace this "re.sub()" call by a "str.replace()" function call.}}
66
# ^^^^^^ ^^^^^^< {{Expression without regular expression features.}}
7-
changed = re.sub(r"\.\.\.", ";", input) # Noncompliant
8-
changed = re.sub(r"\Q...\E", ";", input) # Noncompliant
9-
changed = re.sub(r"\\", "It's", input) # Noncompliant
10-
changed = re.sub(r"\.", "It's", input) # Noncompliant
11-
changed = re.sub(r"!", "It's", input) # Noncompliant
7+
changed = re.sub(r"\.\.\.", ";", input) # Noncompliant
8+
changed = re.sub(r"\Q...\E", ";", input) # Noncompliant
9+
changed = re.sub(r"\\", "It's", input) # Noncompliant
10+
changed = re.sub(r"\.", "It's", input) # Noncompliant
11+
changed = re.sub(r"!", "It's", input) # Noncompliant
12+
changed = re.sub(r"{", "It's", input) # Noncompliant
1213

1314
def compliant():
1415
input = "Bob is a Bird... Bob is a Plane... Bob is Superman!"
@@ -25,7 +26,6 @@ def compliant():
2526
changed = re.sub(r"()", "It's", input)
2627
changed = re.sub(r"[", "It's", input)
2728
changed = re.sub(r"[a-z]]", "It's", input)
28-
changed = re.sub(r"{", "It's", input)
2929
changed = re.sub(r"x{3}", "It's", input)
3030
changed = re.sub(r"^", "It's", input)
3131
changed = re.sub(r"?", "It's", input)

0 commit comments

Comments
 (0)