Created
January 5, 2017 01:02
-
-
Save grantmcconnaughey/fc59963886b8dd8131a632911dd7cbff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lint_entire_project(self, local_repo_path): | |
"""Runs quality checks on the local repo and returns the output as a string.""" | |
self.state = BUILD_RUNNING | |
self.save() | |
process = subprocess.Popen(['flake8', local_repo_path], | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
shell=False) | |
stdout, stderr = process.communicate() | |
return stdout | |
def parse_results(self, local_repo_path, raw_results): | |
"""Parses flake8 output into a dict of files with issues.""" | |
results = raw_results.replace(local_repo_path, '') | |
file_issues = collections.defaultdict(list) | |
regex = re.compile(r'^(?P<path>.*):(?P<line>\d+):(?P<column>\d+): (?P<code>\w\d+) (?P<message>.*)$') | |
for line in results.strip().splitlines(): | |
clean_line = line.strip() | |
match = regex.match(clean_line) | |
if not match: | |
continue | |
path = match.group('path') | |
result = { | |
'line': int(match.group('line')), | |
'column': int(match.group('column')), | |
'code': match.group('code'), | |
'message': match.group('message') | |
} | |
violations[path].append(result) | |
return violations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment