2
2
3
3
4
4
def non_compliant (input ):
5
- re .match (r"<.+?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]++ ".}}
6
- re .match (r"<\S+?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\s]++ ".}}
7
- re .match (r"<\D+?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\d]++ ".}}
8
- re .match (r"<\W+?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\w]++ ".}}
9
-
10
- re .match (r"<.{2,5}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]{2,5}+ ".}}
11
- re .match (r"<\S{2,5}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\s]{2,5}+ ".}}
12
- re .match (r"<\D{2,5}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\d]{2,5}+ ".}}
13
- re .match (r"<\W{2,5}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\w]{2,5}+ ".}}
14
-
15
- re .match (r"<.{2,}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]{2,}+ ".}}
16
- re .match (r"\".*?\"" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^\"]*+ ".}}
17
- re .match (r".*?\w" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "\W*+ ".}}
18
- re .match (r".*?\W" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "\w*+ ".}}
19
- re .match (r"\[.*?\]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^\]]*+ ".}}
20
- re .match (r".+?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc]++ ".}}
5
+ re .match (r"<.+?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]+".}}
6
+ re .match (r"<\S+?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\s]+".}}
7
+ re .match (r"<\D+?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\d]+".}}
8
+ re .match (r"<\W+?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\w]+".}}
9
+
10
+ re .match (r"<.{2,5}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]{2,5}".}}
11
+ re .match (r"<\S{2,5}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\s]{2,5}".}}
12
+ re .match (r"<\D{2,5}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\d]{2,5}".}}
13
+ re .match (r"<\W{2,5}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>\w]{2,5}".}}
14
+
15
+ re .match (r"<.{2,}?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]{2,}".}}
16
+ re .match (r"\".*?\"" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^\"]*".}}
17
+ re .match (r".*?\w" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "\W*".}}
18
+ re .match (r".*?\W" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "\w*".}}
19
+ re .match (r"\[.*?\]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^\]]*".}}
20
+ re .match (r".+?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc]+".}}
21
21
re .match (r"(?-U:\s)*?\S" , input )
22
- re .match (r"(?U:\s)*?\S" , input , re .ASCII ) # Noncompliant {{Replace this use of a reluctant quantifier with "[\s\S]*+ ".}}
22
+ re .match (r"(?U:\s)*?\S" , input , re .ASCII ) # Noncompliant {{Replace this use of a reluctant quantifier with "[\s\S]*".}}
23
23
re .match (r"(?U:a|\s)*?\S" , input )
24
24
re .match (r"\S*?\s" , input )
25
25
re .match (r"\S*?(?-U:\s)" , input )
26
- re .match (r"\S*?(?U:\s)" , input , re .ASCII ) # Noncompliant {{Replace this use of a reluctant quantifier with "[\S\s]*+ ".}}
27
- re .match (r"\S*?(?U)\s" , input , re .ASCII ) # Noncompliant {{Replace this use of a reluctant quantifier with "[\S\s]*+ ".}}
26
+ re .match (r"\S*?(?U:\s)" , input , re .ASCII ) # Noncompliant {{Replace this use of a reluctant quantifier with "[\S\s]*".}}
27
+ re .match (r"\S*?(?U)\s" , input , re .ASCII ) # Noncompliant {{Replace this use of a reluctant quantifier with "[\S\s]*".}}
28
28
29
29
# coverage
30
30
re .match (r"(?:(?m))*?a" , input )
31
31
re .match (r"(?:(?m:.))*?(?:(?m))" , input )
32
32
33
33
# This replacement might not be equivalent in case of full match, but is equivalent in case of split
34
- re .match (r".+?[^abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[abc]++ ".}}
34
+ re .match (r".+?[^abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[abc]+".}}
35
35
36
- re .match (r".+?\x{1F4A9}" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^\x{1F4A9}]++ ".}}
37
- re .match (r"<abc.*?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]*+ ".}}
38
- re .match (r"<.+?>|otherstuff" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]++ ".}}
39
- re .match (r"(<.+?>)*" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]++ ".}}
36
+ re .match (r".+?\x{1F4A9}" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^\x{1F4A9}]+".}}
37
+ re .match (r"<abc.*?>" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]*".}}
38
+ re .match (r"<.+?>|otherstuff" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]+".}}
39
+ re .match (r"(<.+?>)*" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^>]+".}}
40
40
41
- re .match (r"\S+?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\s]++ ".}}
42
- re .match (r"\D+?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\d]++ ".}}
43
- re .match (r"\w+?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\W]++ ".}}
41
+ re .match (r"\S+?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\s]+".}}
42
+ re .match (r"\D+?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\d]+".}}
43
+ re .match (r"\w+?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\W]+".}}
44
44
45
- re .match (r"\S*?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\s]*+ ".}}
46
- re .match (r"\D*?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\d]*+ ".}}
47
- re .match (r"\w*?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\W]*+ ".}}
45
+ re .match (r"\S*?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\s]*".}}
46
+ re .match (r"\D*?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\d]*".}}
47
+ re .match (r"\w*?[abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[^abc\W]*".}}
48
48
49
- re .match (r"\S+?[^abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[abc\S]++ ".}}
50
- re .match (r"\s+?[^abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[abc\s]++ ".}}
49
+ re .match (r"\S+?[^abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[abc\S]+".}}
50
+ re .match (r"\s+?[^abc]" , input ) # Noncompliant {{Replace this use of a reluctant quantifier with "[abc\s]+".}}
51
51
52
52
53
53
def compliant (input ):
@@ -70,6 +70,7 @@ def compliant(input):
70
70
re .match (r"\S*?(?U:\s)" , input )
71
71
re .match (r"\S*?(?U)\s" , input )
72
72
73
+
73
74
def no_intersection (input ):
74
75
re .match (r"<\d+?>" , input )
75
76
re .match (r"<\s+?>" , input )
0 commit comments