Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use cleaner code
  • Loading branch information
ryzokuken committed Jun 26, 2018
commit f0316ce32319882dd2815748b6f9506ed8fdaae2
23 changes: 9 additions & 14 deletions tools/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1898,20 +1898,15 @@ def CheckForBadCharacters(filename, lines, error):
def CheckInlineHeader(filename, include_state, error):
"""Logs an error if both a header and its inline variant are included."""

# Iterate over all headers, looking for any inline headers
for section_list in include_state.include_list:
for header in section_list:
# Proceed further for only inline headers
m = Match(r'^(.+)-inl.h$', header[0])
if m:
name = '%s.h' % m.group(1)
# Look for the corresponding header
for sl in include_state.include_list:
for h in section_list:
if h[0] == name:
err = '%s includes both %s and %s' % (filename, header[0], h[0])
error(filename, h[1], 'build/include', 5, err)
print err
all_headers = dict(item for sublist in include_state.include_list
for item in sublist)
bad_headers = set('%s.h' % name[:-6] for name in all_headers.keys()
if name.endswith('-inl.h'))
bad_headers &= set(all_headers.keys())

for name in bad_headers:
err = '%s includes both %s and %s-inl.h' % (filename, name, name)
error(filename, all_headers[name], 'build/include', 5, err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe assign line = all_headers[name] for clarity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Will do.



def CheckForNewlineAtEOF(filename, lines, error):
Expand Down