Skip to content

Commit 8920b13

Browse files
committed
Changes after review
1 parent 7197a24 commit 8920b13

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

cpplint/cpplint.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@
550550

551551
# Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc.
552552
# This is set by --headers flag.
553-
_hpp_headers = None
553+
_hpp_headers = set(['h'])
554554

555555
# {str, bool}: a map from error categories to booleans which indicate if the
556556
# category should be suppressed for every line.
@@ -566,10 +566,7 @@ def ProcessHppHeadersOption(val):
566566
PrintUsage('Header extensions must be comma seperated list.')
567567

568568
def IsHeaderExtension(file_extension):
569-
if _hpp_headers and file_extension in _hpp_headers:
570-
return True
571-
else:
572-
return file_extension == 'h'
569+
return file_extension in _hpp_headers
573570

574571
def ParseNolintSuppressions(filename, raw_line, linenum, error):
575572
"""Updates the global list of line error-suppressions.

cpplint/cpplint_unittest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3778,6 +3778,7 @@ def testParseArguments(self):
37783778
old_error_categories = cpplint._ERROR_CATEGORIES
37793779
old_output_format = cpplint._cpplint_state.output_format
37803780
old_verbose_level = cpplint._cpplint_state.verbose_level
3781+
old_headers = cpplint._hpp_headers
37813782
old_filters = cpplint._cpplint_state.filters
37823783
old_line_length = cpplint._line_length
37833784
old_valid_extensions = cpplint._valid_extensions
@@ -3795,6 +3796,7 @@ def testParseArguments(self):
37953796
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--filter=foo'])
37963797
self.assertRaises(SystemExit, cpplint.ParseArguments,
37973798
['--filter=+a,b,-c'])
3799+
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--headers'])
37983800

37993801
self.assertEquals(['foo.cc'], cpplint.ParseArguments(['foo.cc']))
38003802
self.assertEquals(old_output_format, cpplint._cpplint_state.output_format)
@@ -3837,6 +3839,13 @@ def testParseArguments(self):
38373839
self.assertEqual(['foo.h'],
38383840
cpplint.ParseArguments(['--extensions=hpp,cpp,cpp', 'foo.h']))
38393841
self.assertEqual(set(['hpp', 'cpp']), cpplint._valid_extensions)
3842+
3843+
self.assertEqual(set(['h']), cpplint._hpp_headers) # Default value
3844+
self.assertEqual(['foo.h'],
3845+
cpplint.ParseArguments(['--extensions=cpp,cpp', '--headers=hpp,h', 'foo.h']))
3846+
self.assertEqual(set(['hpp', 'h']), cpplint._hpp_headers)
3847+
self.assertEqual(set(['hpp', 'h', 'cpp']), cpplint._valid_extensions)
3848+
38403849
finally:
38413850
cpplint._USAGE = old_usage
38423851
cpplint._ERROR_CATEGORIES = old_error_categories
@@ -3845,6 +3854,7 @@ def testParseArguments(self):
38453854
cpplint._cpplint_state.filters = old_filters
38463855
cpplint._line_length = old_line_length
38473856
cpplint._valid_extensions = old_valid_extensions
3857+
cpplint._hpp_headers = old_headers
38483858

38493859
def testLineLength(self):
38503860
old_line_length = cpplint._line_length

0 commit comments

Comments
 (0)