def linterate(args, conduit, revision, error_revisions, error_filter): if not args.silent: print revision.id, revision.title try: errors = None if os.path.isdir('right'): errors = phlsys_cppcheck.run('right') errors = error_filter.filter_ignored(revision, errors) if errors: if args.silent: print revision.id, revision.title print phlsys_cppcheck.summarize_results(errors) print revision.uri error_revisions.append(str(revision.id)) if not args.non_interactive and phlsys_choice.yes_or_no('comment'): print "commenting.." for e in errors: first_line = min(e.line_numbers) last_line = max(e.line_numbers) line_range = last_line - first_line if line_range > 10: for line in e.line_numbers: phlcon_differential.create_inline_comment( conduit, revision.id, e.path, line, e.message) else: phlcon_differential.create_inline_comment( conduit, revision.id, e.path, first_line, e.message, line_count=line_range) # XXX: only leave draft inline comments for now, so the user # may review them in context and manually finish the # comment # # message = "LINTERATOR SEE POSSIBLE ERROR" # phlcon_differential.create_comment( # conduit, revision.id, message, attach_inlines=True) print except phlsys_subprocess.CalledProcessError as e: if not args.silent: print ' ', e
def test_A_Breathing(self): output = """\ <?xml version="1.0" encoding="UTF-8"?> <results version="2"> <cppcheck version="1.58"/> <errors> <error id="nullPointer" severity="error" msg="Possible null pointer \ dereference: s - otherwise it is redundant to check it against null." \ verbose="Possible null pointer dereference: s - otherwise it is redundant \ to check it against null."> <location file="hello_world_bad.cpp" line="11"/> <location file="hello_world_bad.cpp" line="10"/> </error> <error id="nullPointer" severity="error" msg="Null pointer dereference" \ verbose="Null pointer dereference"> <location file="hello_world_bad.cpp" line="7"/> </error> </errors> </results>""" expected = [ ('error', 'nullPointer', 'hello_world_bad.cpp', [11, 10], 'Possible null pointer dereference: s - otherwise it is ' 'redundant to check it against null.'), ('error', 'nullPointer', 'hello_world_bad.cpp', [7], 'Null pointer dereference'), ] expected = [phlsys_cppcheck.Result(*x) for x in expected] self.assertEqual(phlsys_cppcheck.parse_output(output), expected) self.assertIsInstance(phlsys_cppcheck.summarize_results(expected), str)
def linterate(args, conduit, revision, error_revisions, error_filter): if not args.silent: print(revision.id, revision.title) try: errors = None if os.path.isdir('right'): errors = phlsys_cppcheck.run('right') errors = error_filter.filter_ignored(revision, errors) if errors: if args.silent: print(revision.id, revision.title) print(phlsys_cppcheck.summarize_results(errors)) print(revision.uri) error_revisions.append(str(revision.id)) if not args.non_interactive and phlsys_choice.yes_or_no('comment'): print("commenting..") for e in errors: first_line = min(e.line_numbers) last_line = max(e.line_numbers) line_range = last_line - first_line if line_range > 10: for line in e.line_numbers: phlcon_differential.create_inline_comment( conduit, revision.id, e.path, line, e.message) else: phlcon_differential.create_inline_comment( conduit, revision.id, e.path, first_line, e.message, line_count=line_range) # XXX: only leave draft inline comments for now, so the user # may review them in context and manually finish the # comment # # message = "LINTERATOR SEE POSSIBLE ERROR" # phlcon_differential.create_comment( # conduit, revision.id, message, attach_inlines=True) print() except phlsys_subprocess.CalledProcessError as e: if not args.silent: print(' ', e)
def test_A_Breathing(self): output = """\ <?xml version="1.0" encoding="UTF-8"?> <results version="2"> <cppcheck version="1.58"/> <errors> <error id="nullPointer" severity="error" msg="Possible null pointer \ dereference: s - otherwise it is redundant to check it against null." \ verbose="Possible null pointer dereference: s - otherwise it is redundant \ to check it against null."> <location file="hello_world_bad.cpp" line="11"/> <location file="hello_world_bad.cpp" line="10"/> </error> <error id="nullPointer" severity="error" msg="Null pointer dereference" \ verbose="Null pointer dereference"> <location file="hello_world_bad.cpp" line="7"/> </error> </errors> </results>""" expected = [ ('error', 'nullPointer', 'hello_world_bad.cpp', [11, 10], 'Possible null pointer dereference: s - otherwise it is ' 'redundant to check it against null.'), ('error', 'nullPointer', 'hello_world_bad.cpp', [7], 'Null pointer dereference'), ] expected = [phlsys_cppcheck.Result(*x) for x in expected] self.assertEqual( phlsys_cppcheck.parse_output(output), expected) self.assertIsInstance( phlsys_cppcheck.summarize_results(expected), str)