summaryrefslogtreecommitdiff
path: root/checkers
diff options
context:
space:
mode:
authorTorsten Marek <tmarek@google.com>2013-06-22 15:47:17 +0200
committerTorsten Marek <tmarek@google.com>2013-06-22 15:47:17 +0200
commit551d5eef34cced941b4d72f46200d19b2cd2b23f (patch)
treebb690fa36bf9f4d767c0a9d84744f7a2b8fe6f42 /checkers
parent1cef99d4fda3d9816fd777de2efc2e49dc51c0a6 (diff)
downloadpylint-551d5eef34cced941b4d72f46200d19b2cd2b23f.tar.gz
Added new warning no-final-newline.
Diffstat (limited to 'checkers')
-rw-r--r--checkers/format.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/checkers/format.py b/checkers/format.py
index 8fa1dc6..e0fd4e6 100644
--- a/checkers/format.py
+++ b/checkers/format.py
@@ -46,6 +46,9 @@ MSGS = {
'trailing-whitespace',
'Used when there is whitespace between the end of a line and the '
'newline.'),
+ 'C0304': ('Final newline missing',
+ 'missing-final-newline',
+ 'Used when the last line in a file is missing a newline.'),
'W0311': ('Bad indentation. Found %s %s, expected %s',
'bad-indentation',
'Used when an unexpected number of indentation\'s tabulations or '
@@ -337,15 +340,18 @@ class FormatChecker(BaseTokenChecker):
ignore_long_line = self.config.ignore_long_lines
for line in lines.splitlines(True):
- stripped_line = line.rstrip()
- if line != stripped_line + '\n':
- self.add_message('C0303', line=i)
- # Don't count excess whitespace in the line length.
- line = stripped_line
+ if not line.endswith('\n'):
+ self.add_message('C0304', line=i)
+ else:
+ stripped_line = line.rstrip()
+ if line != stripped_line + '\n':
+ self.add_message('C0303', line=i)
+ # Don't count excess whitespace in the line length.
+ line = stripped_line
mobj = OPTION_RGX.search(line)
if mobj and mobj.group(1).split('=', 1)[0].strip() == 'disable':
line = line.split('#')[0].rstrip()
-
+
if len(line) > max_chars and not ignore_long_line.search(line):
self.add_message('C0301', line=i, args=(len(line), max_chars))
i += 1