From 98f84ec7a9976037eb9255b31748bdbd1bfe0bf8 Mon Sep 17 00:00:00 2001 From: Ivan Kolodyazhny Date: Sat, 8 Feb 2020 18:10:42 +0200 Subject: [PATCH] Do not consider issue text in `__eq__` method 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. --- bandit/core/issue.py | 5 ++--- tests/unit/core/test_issue.py | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/bandit/core/issue.py b/bandit/core/issue.py index 61394dbbd..8f7a42566 100644 --- a/bandit/core/issue.py +++ b/bandit/core/issue.py @@ -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) diff --git a/tests/unit/core/test_issue.py b/tests/unit/core/test_issue.py index 4d4fab6b2..9899b35fb 100644 --- a/tests/unit/core/test_issue.py +++ b/tests/unit/core/test_issue.py @@ -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)