Use pylint for CRLF checking.

This commit is contained in:
Florian Bruhin 2014-08-06 21:56:10 +02:00
parent 2b058b36ea
commit be21296b38
2 changed files with 31 additions and 5 deletions

View File

@ -0,0 +1,28 @@
"""Checker for CRLF in files."""
from pylint.interfaces import IRawChecker
from pylint.checkers import BaseChecker
class CrlfChecker(BaseChecker):
"""Check for CRLF in files."""
__implements__ = IRawChecker
name = 'crlf'
msgs = {'W9001': ('Uses CRLFs', 'crlf', None)}
options = ()
priority = -1
def process_module(self, node):
"""Process the module."""
for (lineno, line) in enumerate(node.file_stream):
if b'\r\n' in line:
self.add_message('crlf', line=lineno)
return
def register(linter):
"""Register the checker."""
linter.register_checker(CrlfChecker(linter))

View File

@ -68,7 +68,8 @@ options = {
'other': {
'pylint': ['--output-format=colorized', '--reports=no',
'--rcfile=.pylintrc',
'--load-plugins=pylint_checkers.config'],
'--load-plugins=pylint_checkers.config,'
'pylint_checkers.crlf'],
'flake8': ['--config=.flake8'],
},
}
@ -198,10 +199,7 @@ def _check_file(fn):
ok = True
with open(fn, 'rb') as f:
for line in f:
if b'\r\n' in line:
print("Found CRLF in {}".format(fn))
ok = False
elif any(line.decode('UTF-8').startswith(c * 7) for c in "<>=|"):
if any(line.decode('UTF-8').startswith(c * 7) for c in "<>=|"):
print("Found conflict marker in {}".format(fn))
ok = False
elif b'set_trace()' in line and not (