diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2021-03-17 08:02:01 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-25 00:44:22 +0000 |
commit | 3022c66b2af7049f4096cc7117f94f5194c5e1e2 (patch) | |
tree | 43906732591de4f2046563d3822d621be8b25216 /buildscripts/linter | |
parent | 609d174c95fdfbc0193e1d7e8804ef20a04f99e1 (diff) | |
download | mongo-3022c66b2af7049f4096cc7117f94f5194c5e1e2.tar.gz |
SERVER-55281 lint for newline violations
Diffstat (limited to 'buildscripts/linter')
-rw-r--r-- | buildscripts/linter/simplecpplint.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/buildscripts/linter/simplecpplint.py b/buildscripts/linter/simplecpplint.py index 3acf5a9d19f..11f7056d8bc 100644 --- a/buildscripts/linter/simplecpplint.py +++ b/buildscripts/linter/simplecpplint.py @@ -128,6 +128,7 @@ class Linter: start_line = self._check_for_server_side_public_license() + self._check_newlines() self._check_and_strip_comments() for linenum in range(start_line, len(self.clean_lines)): @@ -150,6 +151,13 @@ class Linter: return self._error_count + def _check_newlines(self): + """Check that each source file ends with a newline character.""" + if self.raw_lines and self.raw_lines[-1][-1:] != '\n': + self._error( + len(self.raw_lines), 'mongo/final_newline', + 'Files must end with a newline character.') + def _check_and_strip_comments(self): in_multi_line_comment = False |