Example #1
0
 def test_sample(self):
     self.assertEqual(get_code_complexity(_GLOBAL, 1), 2)
     self.out.seek(0)
     res = self.out.read().strip().split('\n')
     wanted = ["stdin:5:1: W901 'a' is too complex (4)",
               "stdin:2:1: W901 'Loop 2' is too complex (2)"]
     self.assertEqual(res, wanted)
Example #2
0
 def test_sample(self):
     self.assertEqual(get_code_complexity(_GLOBAL, 1), 2)
     self.out.seek(0)
     res = self.out.read().strip().split('\n')
     wanted = ["stdin:5:1: 'a' is too complex (3)",
               'stdin:Loop 2 is too complex (1)']
     self.assertEqual(res, wanted)
Example #3
0
def check_code(code, ignore=(), complexity=-1):
    warning = flakey.check(code, '<stdin>')
    _set_alt(warning)
    warnings = flakey.print_messages(warning, ignore=ignore, code=code)
    warnings += pep8style.input_file('-', lines=code.split('\n'))
    if complexity > -1:
        warnings += mccabe.get_code_complexity(code, complexity)
    return warnings
Example #4
0
 def test_sample(self):
     self.assertEqual(get_code_complexity(_GLOBAL, 1), 2)
     self.out.seek(0)
     res = self.out.read().strip().split('\n')
     wanted = [
         "stdin:5:1: 'a' is too complex (3)",
         'stdin:Loop 2 is too complex (1)'
     ]
     self.assertEqual(res, wanted)
Example #5
0
def check_code(code, complexity=-1):
    warnings = pyflakes.check(code, '<stdin>')
    if complexity > -1:
        warnings += mccabe.get_code_complexity(code, complexity)
    return warnings
Example #6
0
def check_code(code, complexity=-1):
    warnings = pyflakes.check(code, 'stdin')
    warnings += pep8style.input_file(StringIO(code))
    if complexity > -1:
        warnings += mccabe.get_code_complexity(code, complexity)
    return warnings
Example #7
0
def check_code(code, complexity=-1):
    warnings = pyflakes.check(code, 'stdin')
    warnings += pep8style.input_file(StringIO(code))
    if complexity > -1:
        warnings += mccabe.get_code_complexity(code, complexity)
    return warnings
Example #8
0
def check_code(code, complexity=-1):
    warnings = pyflakes.check(code, '<stdin>')
    if complexity > -1:
        warnings += mccabe.get_code_complexity(code, complexity)
    return warnings
Example #9
0
def check_code(code, ignore=(), complexity=-1):
    warnings = pyflakes.check(code, ignore, "stdin")
    warnings += pep8style.input_file(None, lines=code.split("\n"))
    if complexity > -1:
        warnings += mccabe.get_code_complexity(code, complexity)
    return warnings