Example #1
0
 def test_should_use_clang_format_for_warning(self):
     fun = FunctionInfo("foo", 100)
     fun.cyclomatic_complexity = 16
     fileStat = FileInformation("FILENAME", 1, [fun])
     option = Mock(CCN=15)
     print_warnings(option, [fileStat])
     self.assertIn("FILENAME:100: warning: foo has 16 CCN and 0 params (0 NLOC, 0 tokens)\n", sys.stdout.stream)
Example #2
0
 def test_sort_warning(self):
     self.option.sorting = ['cyclomatic_complexity']
     self.foo.cyclomatic_complexity = 10
     bar = FunctionInfo("bar", '', 100)
     bar.cyclomatic_complexity = 15
     print_warnings(self.option, self.scheme, [self.foo, bar])
     self.assertEqual('bar', self.scheme.function_info.call_args_list[0][0][0].name)
Example #3
0
 def test_should_use_clang_format_with_function_end_line_number_for_warning(self):
     fun = FunctionInfo("foo", 100)
     fun.end_line = 100
     fun.cyclomatic_complexity = 16
     fileStat = FileInformation("FILENAME", 1, [fun])
     option = Mock(display_fn_end_line = True)
     print_warnings(option, [(fun, "FILENAME")])
     self.assertIn("FILENAME:100-100: warning: foo has 16 CCN and 0 params (0 NLOC, 1 tokens)\n", sys.stdout.stream)
Example #4
0
 def test_sort_warning(self, print_function_info):
     option = Mock(display_fn_end_line = False, extensions = get_extensions([]))
     option.sorting = ['cyclomatic_complexity']
     foo = FunctionInfo("foo", 100)
     foo.cyclomatic_complexity = 10
     bar = FunctionInfo("bar", 100)
     bar.cyclomatic_complexity = 15
     print_warnings(option, [(foo, "FILENAME"),(bar, "FILENAME")])
     self.assertEqual('bar', print_function_info.call_args_list[0][0][0].name)
Example #5
0
 def test_should_have_header_when_warning_only_is_off(self):
     option = Mock(warnings_only=False, CCN=15, extensions = [])
     print_warnings(option, [])
     self.assertIn("Warnings (CCN > 15)", sys.stdout.stream)
Example #6
0
 def test_should_use_clang_format_for_warning(self):
     option = Mock(display_fn_end_line = False)
     print_warnings(option, [(FunctionInfo("foo", 100), "FILENAME")])
     self.assertIn("FILENAME:100: warning: foo has 1 CCN and 0 params (0 NLOC, 1 tokens)\n", sys.stdout.stream)
Example #7
0
 def test_should_not_have_header_when_warning_only_is_on(self):
     option = Mock(warnings_only=True, CCN=15)
     print_warnings(option, [])
     self.assertNotIn("Warnings (CCN > 15)", sys.stdout.stream)
Example #8
0
 def test_should_say_no_warning_when_warning_only_is_off(self):
     option = Mock(warnings_only=False, CCN=15)
     print_warnings(option, [])
     self.assertIn("No warning found. Excellent!\n", sys.stdout.stream)
Example #9
0
 def test_sort_warning_with_generator(self):
     self.option.sorting = ['cyclomatic_complexity']
     print_warnings(self.option, self.scheme, (x for x in []))
Example #10
0
 def test_should_have_header_when_warning_only_is_off(self):
     print_warnings(self.option, self.scheme, [])
     self.assertIn("cyclomatic_complexity > 15", sys.stdout.stream)
Example #11
0
 def test_should_have_header_when_warning_only_is_off(self):
     print_warnings(self.option, self.scheme, [])
     self.assertIn("cyclomatic_complexity > 15", sys.stdout.stream)
Example #12
0
 def test_sort_warning_with_generator(self):
     self.option.sorting = ['cyclomatic_complexity']
     print_warnings(self.option, self.scheme, (x for x in []))
Example #13
0
 def test_should_use_clang_format_for_warning(self):
     self.option = Mock(display_fn_end_line = False, extensions = get_extensions([]))
     print_warnings(self.option, self.scheme, [self.foo])
     self.assertIn("FILENAME:100: warning: foo has 1 CCN and 0 params (1 NLOC, 1 tokens)\n", sys.stdout.stream)
Example #14
0
 def test_should_not_have_header_when_warning_only_is_on(self):
     self.option = Mock(warnings_only=True, CCN=15, arguments=100, length=1000)
     print_warnings(self.option, self.scheme, [])
     self.assertNotIn("Warnings (CCN > 15 or arguments > 100 or length > 1000)", sys.stdout.stream)
Example #15
0
 def test_no_news_is_good_news(self):
     self.option.warnings_only = True
     print_warnings(self.option, self.scheme, [])
     self.assertEqual('', sys.stdout.stream)
Example #16
0
 def test_should_have_header_when_warning_only_is_off(self):
     print_warnings(self.option, self.scheme, [])
     self.assertIn("Warnings (CCN > 15 or arguments > 100 or length > 1000)", sys.stdout.stream)
Example #17
0
 def test_sort_warning_with_generator(self):
     option = Mock(display_fn_end_line = False, extensions = get_extensions([]))
     option.sorting = ['cyclomatic_complexity']
     print_warnings(option, (x for x in []))