Skip to content

Commit

Permalink
Add green mode incompatible bears list
Browse files Browse the repository at this point in the history
* Constants.py: Add a list GREEN_MODE_INCOMPATIBLE_BEAR_LIST.
* Bears.py: Remove bears from REQUIRED_BEAR_LIST that are present
            in GREEN_MODE_INCOMPATIBLE_BEAR_LIST when running
            green_mode.
Add tests for the same.
  • Loading branch information
ishanSrt committed Aug 12, 2018
1 parent ffaff5c commit f26b264
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions coala_quickstart/Constants.py
Expand Up @@ -13,6 +13,11 @@
# This includes the bears from IMPORTANT_BEAR_LIST
GREEN_MODE_COMPATIBLE_BEAR_LIST = {}

# This takes precedence over the other two bear lists.
GREEN_MODE_INCOMPATIBLE_BEAR_LIST = {
'FilenameBear',
}

ALL_CAPABILITIES = {
'Code Simplification',
'Commented Code',
Expand Down
11 changes: 10 additions & 1 deletion coala_quickstart/generation/Bears.py
Expand Up @@ -62,9 +62,18 @@ def filter_relevant_bears(used_languages,

if args.green_mode:
from coala_quickstart.Constants import (
GREEN_MODE_COMPATIBLE_BEAR_LIST)
GREEN_MODE_COMPATIBLE_BEAR_LIST,
GREEN_MODE_INCOMPATIBLE_BEAR_LIST,
)
REQUIRED_BEAR_LIST = concatenate(IMPORTANT_BEAR_LIST,
GREEN_MODE_COMPATIBLE_BEAR_LIST)
NEW_REQUIRED_BEAR_LIST = {}
for lang in REQUIRED_BEAR_LIST:
NEW_REQUIRED_BEAR_LIST[lang] = set()
for bear in REQUIRED_BEAR_LIST[lang]:
if bear not in GREEN_MODE_INCOMPATIBLE_BEAR_LIST:
NEW_REQUIRED_BEAR_LIST[lang].add(bear)
REQUIRED_BEAR_LIST = NEW_REQUIRED_BEAR_LIST

# Initialize selected_bears with REQUIRED_BEAR_LIST
for lang, lang_bears in candidate_bears.items():
Expand Down
7 changes: 6 additions & 1 deletion tests/generation/BearsTest.py
Expand Up @@ -12,7 +12,10 @@
from coala_quickstart.coala_quickstart import main
from coala_quickstart.coala_quickstart import _get_arg_parser
from coala_quickstart.Constants import (
IMPORTANT_BEAR_LIST, ALL_CAPABILITIES)
ALL_CAPABILITIES,
GREEN_MODE_INCOMPATIBLE_BEAR_LIST,
IMPORTANT_BEAR_LIST,
)
from coala_quickstart.generation.InfoCollector import collect_info
from tests.TestUtilities import bear_test_module, generate_files

Expand Down Expand Up @@ -158,6 +161,8 @@ def test_filter_relevant_bears_green_mode(self):
for key in ['Python', 'C', 'All']:
bear_obj_dict[key] = set()
for bear in IMPORTANT_BEAR_LIST[key]:
if bear in GREEN_MODE_INCOMPATIBLE_BEAR_LIST:
continue
bear_obj_dict[key].update([x for x in bear_objs if (
x.__name__ == bear)])

Expand Down

0 comments on commit f26b264

Please sign in to comment.