Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeywordBear: Handle empty keywords #1695

Merged
merged 2 commits into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
coala-bears 0.10.2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume since we are backporting we are making a release, hence added the release notes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and again I raise a conflict for myself :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erm I mean add to 0.11 0.10 neds to be assessed (probably needed too)

==================

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
==================

Expand Down
15 changes: 8 additions & 7 deletions bears/general/KeywordBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions tests/general/KeywordBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)