Skip to content

Commit

Permalink
ConsoleInteraction: Remove nothing_done()
Browse files Browse the repository at this point in the history
Replace occurrences of nothing_done() with it's definition.

Fixes coala#4523
  • Loading branch information
roshnet committed Apr 4, 2019
1 parent acb2341 commit 75e279c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
7 changes: 2 additions & 5 deletions coalib/coala_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def run_coala(console_printer=None,
print_results=do_nothing,
acquire_settings=fail_acquire_settings,
print_section_beginning=do_nothing,
nothing_done=do_nothing,
autoapply=True,
force_show_patch=False,
arg_parser=None,
Expand All @@ -84,9 +83,6 @@ def run_coala(console_printer=None,
:param print_section_beginning: A callback that will be called with a
section name string whenever analysis of a
new section is started.
:param nothing_done: A callback that will be called with only a
log printer that shall indicate that
nothing was done.
:param autoapply: Set this to false to not autoapply any
actions. If you set this to `False`,
`force_show_patch` will be ignored.
Expand Down Expand Up @@ -213,7 +209,8 @@ def run_coala(console_printer=None,
if CounterHandler.get_num_calls_for_level('ERROR') > 0:
exitcode = 1
elif did_nothing:
nothing_done(None)
logging.warning('No existent section was targeted or enabled.'
'Nothing to do.')
exitcode = 2
elif yielded_unfixed_results:
exitcode = 1
Expand Down
3 changes: 1 addition & 2 deletions coalib/coala_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def mode_normal(console_printer, log_printer, args, debug=False):

from coalib.coala_main import run_coala
from coalib.output.ConsoleInteraction import (
acquire_settings, nothing_done,
acquire_settings,
print_results, print_section_beginning)

partial_print_sec_beg = functools.partial(
Expand All @@ -23,7 +23,6 @@ def mode_normal(console_printer, log_printer, args, debug=False):
print_results=print_results,
acquire_settings=acquire_settings,
print_section_beginning=partial_print_sec_beg,
nothing_done=nothing_done,
console_printer=console_printer,
args=args,
debug=debug)
Expand Down
11 changes: 0 additions & 11 deletions coalib/output/ConsoleInteraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,6 @@ def print_section_beginning(console_printer, section):
name=section.name))


def nothing_done(log_printer=None):
"""
Will be called after processing a coafile when nothing had to be done,
i.e. no section was enabled/targeted.
:param log_printer: A LogPrinter object.
"""
logging.warning('No existent section was targeted or enabled. Nothing to '
'do.')


def acquire_actions_and_apply(console_printer,
section,
file_diff_dict,
Expand Down
5 changes: 3 additions & 2 deletions tests/output/ConsoleInteractionTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from coala_utils.ContextManagers import (
make_temp, retrieve_stdout, simulate_console_inputs)
from coalib.output.ConsoleInteraction import (
acquire_actions_and_apply, acquire_settings, get_action_info, nothing_done,
acquire_actions_and_apply, acquire_settings, get_action_info,
print_affected_files, print_result, print_results,
print_results_formatted, print_results_no_input, print_section_beginning,
show_bear, show_bears, ask_for_action_and_apply, print_diffs_info,
Expand Down Expand Up @@ -634,7 +634,8 @@ def test_print_section_beginning(self):

def test_nothing_done(self):
with LogCapture() as capture:
nothing_done(self.log_printer)
logging.warning('No existent section was targeted or enabled. '
'Nothing to do.')
capture.check(
('root', 'WARNING', 'No existent section was targeted or enabled. '
'Nothing to do.')
Expand Down

0 comments on commit 75e279c

Please sign in to comment.