lint: Ban lines longer than 140 characters without #ignorelongline.

This commit is contained in:
Tim Abbott 2016-08-19 12:03:09 -07:00
parent e1e384acc0
commit 2e2dee3396
2 changed files with 4 additions and 3 deletions

View File

@ -92,7 +92,7 @@ def different_paragraph(line, next_line):
len(line) < len(words[0])) len(line) < len(words[0]))
# Linewrapping algorithm based on: # Linewrapping algorithm based on:
# http://gcbenison.wordpress.com/2011/07/03/a-program-to-intelligently-remove-carriage-returns-so-you-can-paste-text-without-having-it-look-awful/ # http://gcbenison.wordpress.com/2011/07/03/a-program-to-intelligently-remove-carriage-returns-so-you-can-paste-text-without-having-it-look-awful/ #ignorelongline
def unwrap_lines(body): def unwrap_lines(body):
lines = body.split("\n") lines = body.split("\n")
result = "" result = ""

View File

@ -139,7 +139,8 @@ def build_custom_checkers(by_lang):
print("Exception with %s at %s line %s" % (rule['pattern'], fn, i+1)) print("Exception with %s at %s line %s" % (rule['pattern'], fn, i+1))
traceback.print_exc() traceback.print_exc()
if (max_length is not None and len(line) > max_length and if (max_length is not None and len(line) > max_length and
'# type' not in line and 'test' not in fn and 'example' not in fn): '# type' not in line and 'test' not in fn and 'example' not in fn and
"#ignorelongline" not in line):
print("Line too long (%s) at %s line %s: %s" % (len(line), fn, i+1, line_newline_stripped)) print("Line too long (%s) at %s line %s: %s" % (len(line), fn, i+1, line_newline_stripped))
lastLine = line lastLine = line
if lineFlag and '\n' not in lastLine: if lineFlag and '\n' not in lastLine:
@ -329,7 +330,7 @@ def build_custom_checkers(by_lang):
failed = False failed = False
for fn in by_lang['py']: for fn in by_lang['py']:
if custom_check_file(fn, python_rules, max_length=180): if custom_check_file(fn, python_rules, max_length=140):
failed = True failed = True
return failed return failed