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

gsoc: Merge Severity line output #4626

Merged
merged 2 commits into from Aug 14, 2017
Jump to file or symbol
Failed to load files and symbols.
+29 −46
Diff settings

Always

Just for now

Next

Merge Severity line output

Merge Severity line with "**** <bear> [Section: <section] ****"
Delete the empty lines before and after it.

Closes #4623
  • Loading branch information...
Nosferatul committed Aug 7, 2017
commit 2bd16a5d44d93edc211da3faf4cb17e93296cd70
@@ -288,16 +288,20 @@ def print_result(console_printer,
return
if hasattr(section, 'name'):
console_printer.print('\n**** {bear} [Section: {section}] ****\n'
.format(bear=result.origin, section=section.name),
console_printer.print('**** {bear} [Section: {section} | Severity: '
'{severity}] ****'
.format(bear=result.origin,
section=section.name,
severity=RESULT_SEVERITY.__str__(
result.severity)),
color=RESULT_SEVERITY_COLORS[result.severity])
else:
console_printer.print('\n**** {bear} [Section: {section}] ****\n'
.format(bear=result.origin, section='<empty>'),
console_printer.print('**** {bear} [Section {section} | Severity '
'{severity}] ****'
.format(bear=result.origin, section='<empty>',
severity=RESULT_SEVERITY.__str__(
result.severity)),
color=RESULT_SEVERITY_COLORS[result.severity])
console_printer.print(format_lines('[Severity: {sev}]'.format(
sev=RESULT_SEVERITY.__str__(result.severity)), '!'),
color=RESULT_SEVERITY_COLORS[result.severity])
lexer = TextLexer()
result.message = highlight_text(no_color, result.message,
lexer, BackgroundMessageStyle)
@@ -648,10 +648,7 @@ def test_print_result_no_input(self):
self.assertEqual(stdout.getvalue(),
"""
Project wide:
**** origin [Section: someSection] ****
! ! [Severity: NORMAL]
**** origin [Section: someSection | Severity: NORMAL] ****
! ! {}\n""".format(highlight_text(self.no_color,
'message', style=BackgroundMessageStyle)))
@@ -681,8 +678,8 @@ def test_print_results_project_wide(self):
{},
self.console_printer)
self.assertEqual(
'\nProject wide:\n\n**** origin [Section: ] ****\n\n! ! ' +
'[Severity: NORMAL]\n! ! {1}\n'.format(
'\nProject wide:\n**** origin [Section: | Severity: NORMAL] '
'****\n! ! {1}\n'.format(
STR_PROJECT_WIDE,
highlight_text(self.no_color,
'message', style=BackgroundMessageStyle)),
@@ -703,10 +700,7 @@ def test_print_results_for_file(self):
self.assertEqual("""
filename
[ ]2 {0}
**** SpaceConsistencyBear [Section: ] ****
! ! [Severity: NORMAL]
**** SpaceConsistencyBear [Section: | Severity: NORMAL] ****
! ! {1}\n""".format(highlight_text(self.no_color, 'line 2', self.lexer),
highlight_text(self.no_color,
'Trailing whitespace found',
@@ -731,10 +725,7 @@ def test_print_results_for_file(self):
self.assertEqual("""
filename
[ ]5 {0}
**** SpaceConsistencyBear [Section: ] ****
! ! [Severity: NORMAL]
**** SpaceConsistencyBear [Section: | Severity: NORMAL] ****
! ! {1}\n""".format(highlight_text(self.no_color, 'line 5', self.lexer),
highlight_text(self.no_color,
'Trailing whitespace found',
@@ -764,18 +755,12 @@ def test_print_results_sorting(self):
self.assertEqual("""
file
[ ]2 {0}
**** SpaceConsistencyBear [Section: ] ****
! ! [Severity: NORMAL]
**** SpaceConsistencyBear [Section: | Severity: NORMAL] ****
! ! Trailing whitespace found
file
[ ]5 {2}
**** SpaceConsistencyBear [Section: ] ****
! ! [Severity: NORMAL]
**** SpaceConsistencyBear [Section: | Severity: NORMAL] ****
! ! {1}\n""".format(highlight_text(self.no_color, '\t', self.lexer),
highlight_text(self.no_color,
'Trailing whitespace found',
@@ -812,10 +797,7 @@ def test_print_results_multiple_ranges(self):
[ ]5 li{0}{3}
[ ]6 li{0}{4}
[ ]7 li{0}{5}
**** ClangCloneDetectionBear [Section: ] ****
! ! [Severity: NORMAL]
**** ClangCloneDetectionBear [Section: | Severity: NORMAL] ****
! ! {6}\n""".format(highlight_text(self.no_color, 'ne', self.lexer,
BackgroundSourceRangeStyle),
highlight_text(self.no_color, ' 1', self.lexer),
@@ -838,15 +820,15 @@ def test_print_results_missing_file(self):
{},
{},
self.console_printer)
self.assertEqual('\n' + STR_PROJECT_WIDE + '\n\n'
'**** t [Section: ] ****' + '\n\n'
'! ! [Severity: NORMAL]\n'
self.assertEqual('\n' + STR_PROJECT_WIDE + '\n'
'**** t [Section: | Severity: NORMAL] ****'
'\n'
'! ! msg\n'
# Second results file isn't there, no context is
# printed, only a warning log message which we
# don't catch
'\n**** t [Section: ] ****' + '\n\n'
'! ! [Severity: NORMAL]\n'
'**** t [Section: | Severity: NORMAL] ****'
'\n'
'! ! {0}\n'.format(
highlight_text(self.no_color, 'msg',
style=BackgroundMessageStyle)),
@@ -864,17 +846,15 @@ def test_print_results_missing_line(self):
self.console_printer)
self.assertEqual(
'\nfile\n'
'[ ]5 {0}\n'
'[ ]5 {0}'
'\n'
'**** t [Section: ] ****\n\n'
'! ! [Severity: NORMAL]\n'
'**** t [Section: | Severity: NORMAL] ****\n'
'! ! {1}\n'
'\n'
'file\n'
'! !6 {2}'
'\n\n'
'**** t [Section: ] ****\n\n'
'! ! [Severity: NORMAL]\n'
'\n'
'**** t [Section: | Severity: NORMAL] ****\n'
'! ! {1}\n'.format(
highlight_text(self.no_color,
'line 5', self.lexer),
@@ -895,8 +875,7 @@ def test_print_results_without_line(self):
self.assertEqual(
'\n'
'file\n'
'\n**** t [Section: ] ****\n\n'
'! ! [Severity: NORMAL]\n'
'**** t [Section: | Severity: NORMAL] ****\n'
'! ! {}\n'.format(highlight_text(
self.no_color, 'msg', style=BackgroundMessageStyle)),
stdout.getvalue())
ProTip! Use n and p to navigate between commits in a pull request.