Skip to content
This repository has been archived by the owner on Jan 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5 from richardxia/add_coffeelint_checker
Browse files Browse the repository at this point in the history
Add coffeelint checker
  • Loading branch information
jenanwise committed Jan 27, 2014
2 parents 57b7e64 + 7e4716e commit 4fc0b5c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
29 changes: 29 additions & 0 deletions codequality/checkers.py
@@ -1,6 +1,8 @@
from subprocess import PIPE
from subprocess import Popen
import csv
import re
import StringIO


checkers = {}
Expand Down Expand Up @@ -167,3 +169,30 @@ def get_version(cls):
return ''
else:
return out.splitlines()[0].strip()


@register(filetypes=('coffee',))
class CoffeeLintChecker(Checker):
"""
Checker integration with the coffeelint tool.
"""
tool = 'coffeelint'

def check(self, paths):
if not paths:
return ()

cmd_pieces = [self.tool, '--csv'] # Use CSV output
cmd_pieces.extend(paths)
process = Popen(cmd_pieces, stdout=PIPE, stderr=PIPE)
out, err = process.communicate()
output_rows = csv.DictReader(StringIO.StringIO(out))
return [
{
'filename': row['path'],
'lineno': int(row['lineNumber']),
'colno': '',
'msg': row['message'],
}
for row in output_rows
]
6 changes: 3 additions & 3 deletions codequality/main.py
Expand Up @@ -141,7 +141,7 @@ def _relevant_checkers(self, path):
TODO: currently this is based off the file extension. We would like to
honor magic bits as well, so that python binaries, shell scripts, etc
but we're not guarunteed that `path` currently exists on the filesystem
but we're not guaranteed that `path` currently exists on the filesystem
-- e.g. when version control for historical revs is used.
"""
_, ext = os.path.splitext(path)
Expand All @@ -153,10 +153,10 @@ def _resolve_paths(self, *paths):
Resolve paths into a set of filenames (no directories) to check.
External tools will handle directories as arguments differently, so for
consistancy we just want to pass them filenames.
consistency we just want to pass them filenames.
This method will recursively walk all directories and filter out
any paths that mach self.options.ignores.
any paths that match self.options.ignores.
"""
result = set()
for path in paths:
Expand Down

0 comments on commit 4fc0b5c

Please sign in to comment.