diff options
author | Lars Wirzenius <liw@liw.fi> | 2014-07-06 15:41:34 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2014-07-06 15:41:34 +0100 |
commit | 3d2d6eb8d9e2de8144bfe53fe35bce2253fde34f (patch) | |
tree | 0e157ea686b2784a1d82ea5d097238f81d1438d5 /nitpicker | |
parent | 17973dc2561b4a4581c66f959def497472574be2 (diff) | |
download | obnam-3d2d6eb8d9e2de8144bfe53fe35bce2253fde34f.tar.gz |
Nitpick only about long lines with whitespace
Whitespace-less lines can't be broken into shorter lines,
so there's no point in complaining about them. As an example,
a line might contain a long URL, and that shouldn't be broken.
Diffstat (limited to 'nitpicker')
-rwxr-xr-x | nitpicker | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -36,6 +36,8 @@ class LongLine(obnamlib.ObnamError): class SourceCodeNitpicker(cliapp.Application): + max_line_length = 79 + def setup(self): self.errors = False @@ -56,11 +58,17 @@ class SourceCodeNitpicker(cliapp.Application): def check_for_long_line(self, filename, line): expanded = line.expandtabs() - if len(expanded) > 79: + if self.line_is_long(expanded) and self.line_can_be_broken(line): self.error( filename, self.lineno, LongLine(line=line, length=len(expanded))) + def line_is_long(self, line): + return len(line) > self.max_line_length + + def line_can_be_broken(self, line): + return len(line.split()) > 1 + def error(self, filename, lineno, error): self.output.write( '%s:%s: %s\n' % (filename, lineno, str(error))) |