diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 149b48c6ee..4e84461019 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -1,3 +1,11 @@ +coala-bears 0.10.2 +================== + +Bugfixes: + +- KeywordBear doesn't report false results when unsetting it. Previously, + it used to match every alphabet instead of matching nothing. + coala-bears 0.10.1 ================== diff --git a/bears/general/KeywordBear.py b/bears/general/KeywordBear.py index bb81ae6e61..7dc40fa751 100644 --- a/bears/general/KeywordBear.py +++ b/bears/general/KeywordBear.py @@ -96,13 +96,14 @@ def run(self, ''' comments = list(_get_comments(dependency_results)) - simple_keywords_regex = re.compile( - '(' + '|'.join(re.escape(key) for key in keywords) + ')', - re.IGNORECASE) - - message = "The line contains the keyword '{}'." - yield from self.check_keywords(filename, file, comments, - simple_keywords_regex, message) + if keywords: + simple_keywords_regex = re.compile( + '(' + '|'.join(re.escape(key) for key in keywords) + ')', + re.IGNORECASE) + + message = "The line contains the keyword '{}'." + yield from self.check_keywords(filename, file, comments, + simple_keywords_regex, message) if regex_keyword is not '': regex = re.compile(regex_keyword) diff --git a/tests/general/KeywordBearTest.py b/tests/general/KeywordBearTest.py index 1389a41073..a8f33c37fd 100644 --- a/tests/general/KeywordBearTest.py +++ b/tests/general/KeywordBearTest.py @@ -239,3 +239,12 @@ def test_wrong_language(self): self.assertIn(log.output[0], 'ERROR:root:coalang specification' ' for anything not found.') + + def test_empty_keywords_list(self): + self.section.append(Setting('keywords', '')) + + text = ['bears = KeywordBear\n'] + + with execute_bear(self.uut, filename='F', file=text, + dependency_results=self.dep_results) as result: + self.assertEqual(len(result), 0)