Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeCz committed Sep 27, 2016
1 parent 7197a24 commit 8920b13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cpplint/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@

# Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc.
# 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
# category should be suppressed for every line.
Expand All @@ -566,10 +566,7 @@ def ProcessHppHeadersOption(val):
PrintUsage('Header extensions must be comma seperated list.')

def IsHeaderExtension(file_extension):
if _hpp_headers and file_extension in _hpp_headers:
return True
else:
return file_extension == 'h'
return file_extension in _hpp_headers

def ParseNolintSuppressions(filename, raw_line, linenum, error):
"""Updates the global list of line error-suppressions.
Expand Down
10 changes: 10 additions & 0 deletions cpplint/cpplint_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3778,6 +3778,7 @@ def testParseArguments(self):
old_error_categories = cpplint._ERROR_CATEGORIES
old_output_format = cpplint._cpplint_state.output_format
old_verbose_level = cpplint._cpplint_state.verbose_level
old_headers = cpplint._hpp_headers
old_filters = cpplint._cpplint_state.filters
old_line_length = cpplint._line_length
old_valid_extensions = cpplint._valid_extensions
Expand All @@ -3795,6 +3796,7 @@ def testParseArguments(self):
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--filter=foo'])
self.assertRaises(SystemExit, cpplint.ParseArguments,
['--filter=+a,b,-c'])
self.assertRaises(SystemExit, cpplint.ParseArguments, ['--headers'])

self.assertEquals(['foo.cc'], cpplint.ParseArguments(['foo.cc']))
self.assertEquals(old_output_format, cpplint._cpplint_state.output_format)
Expand Down Expand Up @@ -3837,6 +3839,13 @@ def testParseArguments(self):
self.assertEqual(['foo.h'],
cpplint.ParseArguments(['--extensions=hpp,cpp,cpp', 'foo.h']))
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:
cpplint._USAGE = old_usage
cpplint._ERROR_CATEGORIES = old_error_categories
Expand All @@ -3845,6 +3854,7 @@ def testParseArguments(self):
cpplint._cpplint_state.filters = old_filters
cpplint._line_length = old_line_length
cpplint._valid_extensions = old_valid_extensions
cpplint._hpp_headers = old_headers

def testLineLength(self):
old_line_length = cpplint._line_length
Expand Down

0 comments on commit 8920b13

Please sign in to comment.