Skip to content

Commit

Permalink
Merge pull request #169 from Xiaoven/fix_167
Browse files Browse the repository at this point in the history
fix #167: support character '[' and ']'
  • Loading branch information
zhouyinn committed Apr 6, 2021
2 parents 4f416e5 + f3ce76b commit 9b6556f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion patterns/detect/find_self_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self):
self.pattern_1 = regex.compile(
r'(\b\w[\w.]*(?P<aux1>\((?:[^()]++|(?&aux1))*\))*)\s*(==|!=|>=|<=|>|<)\s*([\w.]+(?&aux1)*)')
self.pattern_2 = regex.compile(
r'((?:"|\b\w|(?P<aux1>\((?:[^()]++|(?&aux1))*\)))(?:[\w\.$"]|(?&aux1))*?)\s*\.\s*(?:equals|compareTo|endsWith|startsWith|contains|equalsIgnoreCase|compareToIgnoreCase)((?&aux1))')
r'((?:"|\b\w|(?P<aux1>\((?:[^()]++|(?&aux1))*\)))(?:[\w\.$"\[\]]|(?&aux1))*?)\s*\.\s*(?:equals|compareTo|endsWith|startsWith|contains|equalsIgnoreCase|compareToIgnoreCase)((?&aux1))')
Detector.__init__(self)

def match(self, context):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_find_self_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
'return ((TaskNodeModel) obj).id.equals(id);', 0, 0),
(False, 'SA_SELF_COMPARISON', 'Fake_14.java',
'"abc".equals("abc");', 1, 1),
(False, 'SA_SELF_COMPARISON', 'asmsupport/ClassReader.java',
'if (attrs[i].type.equals(type)) {}', 0, 0),
]


Expand Down

0 comments on commit 9b6556f

Please sign in to comment.