diff options
| author | Tarek Ziade <tarek@ziade.org> | 2011-11-29 13:40:40 +0100 |
|---|---|---|
| committer | Tarek Ziade <tarek@ziade.org> | 2011-11-29 13:40:40 +0100 |
| commit | a6e22978380eefad24bfd4aea7efc974d7129dbb (patch) | |
| tree | c0fd1fdd6ff584da4ac00061de91b99847dc2b42 /flake8/run.py | |
| parent | d0dc42f37a1c145ffa6617069f167a8ac264ef12 (diff) | |
| download | flake8-1.0.tar.gz | |
made complexity an option (deactivated by default)1.0
Diffstat (limited to 'flake8/run.py')
| -rw-r--r-- | flake8/run.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/flake8/run.py b/flake8/run.py index ddc0ea1..d3a803c 100644 --- a/flake8/run.py +++ b/flake8/run.py @@ -12,16 +12,18 @@ from flake8 import pyflakes from flake8 import mccabe -def check_file(path, complexity=10): +def check_file(path, complexity=-1): warnings = pyflakes.checkPath(path) warnings += pep8.input_file(path) - warnings += mccabe.get_module_complexity(path, complexity) + if complexity > -1: + warnings += mccabe.get_module_complexity(path, complexity) return warnings -def check_code(code, complexity=10): +def check_code(code, complexity=-1): warnings = pyflakes.check(code, '<stdin>') - warnings += mccabe.get_code_complexity(code, complexity) + if complexity > -1: + warnings += mccabe.get_code_complexity(code, complexity) return warnings @@ -43,13 +45,14 @@ def _get_python_files(paths): def main(): options, args = pep8.process_options() + complexity = options.max_complexity warnings = 0 if args: for path in _get_python_files(args): - warnings += check_file(path) + warnings += check_file(path, complexity) else: stdin = sys.stdin.read() - warnings += check_code(stdin) + warnings += check_code(stdin, complexity) raise SystemExit(warnings > 0) @@ -84,10 +87,11 @@ def hg_hook(ui, repo, **kwargs): pep8.options.physical_checks = pep8.find_checks('physical_line') pep8.options.logical_checks = pep8.find_checks('logical_line') pep8.args = [] - + complexity = ui.configint('flake8', 'complexity', default=-1) warnings = 0 + for file_ in _get_files(repo, **kwargs): - warnings += check_file(file_) + warnings += check_file(file_, complexity) strict = ui.configbool('flake8', 'strict', default=True) |
