Skip to content

Commit

Permalink
Do not consider issue text in __eq__ method
Browse files Browse the repository at this point in the history
Issue text is not supposed to be consistent between banndit versions. It
was changed few times in the past. That's why we don't need to match text too
between issues.

This issue is only valid if we compare old bandit baseline generated
with the old version with a new one generated using the last bandit.
  • Loading branch information
e0ne committed Feb 8, 2020
1 parent 7a2ef1b commit 98f84ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
5 changes: 2 additions & 3 deletions bandit/core/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ def __str__(self):
self.confidence, self.fname, self.lineno)

def __eq__(self, other):
# if the issue text, severity, confidence, and filename match, it's
# if the issue severity, confidence, and filename match, it's
# the same issue from our perspective
match_types = ['text', 'severity', 'confidence', 'fname', 'test',
'test_id']
match_types = ['severity', 'confidence', 'fname', 'test', 'test_id']
return all(getattr(self, field) == getattr(other, field)
for field in match_types)

Expand Down
3 changes: 0 additions & 3 deletions tests/unit/core/test_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ def test_matches_issue(self):
# confidence doesn't match
self.assertNotEqual(issue_a, issue_c)

# text doesn't match
self.assertNotEqual(issue_a, issue_d)

# filename doesn't match
self.assertNotEqual(issue_a, issue_e)

Expand Down

0 comments on commit 98f84ec

Please sign in to comment.