Changes after review

This commit is contained in:
LukeCz 2016-09-26 19:40:47 -05:00
parent 7197a244ea
commit 8920b13221
2 changed files with 12 additions and 5 deletions

7
cpplint/cpplint.py vendored
View File

@ -550,7 +550,7 @@ _valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh'])
# Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc. # Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc.
# This is set by --headers flag. # This is set by --headers flag.
_hpp_headers = None _hpp_headers = set(['h'])
# {str, bool}: a map from error categories to booleans which indicate if the # {str, bool}: a map from error categories to booleans which indicate if the
# category should be suppressed for every line. # category should be suppressed for every line.
@ -566,10 +566,7 @@ def ProcessHppHeadersOption(val):
PrintUsage('Header extensions must be comma seperated list.') PrintUsage('Header extensions must be comma seperated list.')
def IsHeaderExtension(file_extension): def IsHeaderExtension(file_extension):
if _hpp_headers and file_extension in _hpp_headers: return file_extension in _hpp_headers
return True
else:
return file_extension == 'h'
def ParseNolintSuppressions(filename, raw_line, linenum, error): def ParseNolintSuppressions(filename, raw_line, linenum, error):
"""Updates the global list of line error-suppressions. """Updates the global list of line error-suppressions.

View File

@ -3778,6 +3778,7 @@ class CpplintTest(CpplintTestBase):
old_error_categories = cpplint._ERROR_CATEGORIES old_error_categories = cpplint._ERROR_CATEGORIES
old_output_format = cpplint._cpplint_state.output_format old_output_format = cpplint._cpplint_state.output_format
old_verbose_level = cpplint._cpplint_state.verbose_level old_verbose_level = cpplint._cpplint_state.verbose_level
old_headers = cpplint._hpp_headers
old_filters = cpplint._cpplint_state.filters old_filters = cpplint._cpplint_state.filters
old_line_length = cpplint._line_length old_line_length = cpplint._line_length
old_valid_extensions = cpplint._valid_extensions old_valid_extensions = cpplint._valid_extensions
@ -3795,6 +3796,7 @@ class CpplintTest(CpplintTestBase):
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--filter=foo']) self.assertRaises(SystemExit, cpplint.ParseArguments, ['--filter=foo'])
self.assertRaises(SystemExit, cpplint.ParseArguments, self.assertRaises(SystemExit, cpplint.ParseArguments,
['--filter=+a,b,-c']) ['--filter=+a,b,-c'])
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--headers'])
self.assertEquals(['foo.cc'], cpplint.ParseArguments(['foo.cc'])) self.assertEquals(['foo.cc'], cpplint.ParseArguments(['foo.cc']))
self.assertEquals(old_output_format, cpplint._cpplint_state.output_format) self.assertEquals(old_output_format, cpplint._cpplint_state.output_format)
@ -3837,6 +3839,13 @@ class CpplintTest(CpplintTestBase):
self.assertEqual(['foo.h'], self.assertEqual(['foo.h'],
cpplint.ParseArguments(['--extensions=hpp,cpp,cpp', 'foo.h'])) cpplint.ParseArguments(['--extensions=hpp,cpp,cpp', 'foo.h']))
self.assertEqual(set(['hpp', 'cpp']), cpplint._valid_extensions) self.assertEqual(set(['hpp', 'cpp']), cpplint._valid_extensions)
self.assertEqual(set(['h']), cpplint._hpp_headers) # Default value
self.assertEqual(['foo.h'],
cpplint.ParseArguments(['--extensions=cpp,cpp', '--headers=hpp,h', 'foo.h']))
self.assertEqual(set(['hpp', 'h']), cpplint._hpp_headers)
self.assertEqual(set(['hpp', 'h', 'cpp']), cpplint._valid_extensions)
finally: finally:
cpplint._USAGE = old_usage cpplint._USAGE = old_usage
cpplint._ERROR_CATEGORIES = old_error_categories cpplint._ERROR_CATEGORIES = old_error_categories
@ -3845,6 +3854,7 @@ class CpplintTest(CpplintTestBase):
cpplint._cpplint_state.filters = old_filters cpplint._cpplint_state.filters = old_filters
cpplint._line_length = old_line_length cpplint._line_length = old_line_length
cpplint._valid_extensions = old_valid_extensions cpplint._valid_extensions = old_valid_extensions
cpplint._hpp_headers = old_headers
def testLineLength(self): def testLineLength(self):
old_line_length = cpplint._line_length old_line_length = cpplint._line_length