Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uptools: lint for inline headers #21521
Conversation
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot
added
the
tools
label
Jun 25, 2018
ryzokuken
requested a review
from
bnoordhuis
Jun 25, 2018
This comment has been minimized.
This comment has been minimized.
|
Okay, wait, this doesn't even work. Let me push a few fixes. |
ryzokuken
changed the title
Lint for inline headers
[WIP] Lint for inline headers
Jun 25, 2018
This comment has been minimized.
This comment has been minimized.
|
@bnoordhuis this actually works now. I've added a temporary |
This comment has been minimized.
This comment has been minimized.
targos
added
the
python
label
Jun 25, 2018
trivikr
added
the
work in progress (WIP)
label
Jun 25, 2018
bnoordhuis
reviewed
Jun 25, 2018
| 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 |
This comment has been minimized.
This comment has been minimized.
bnoordhuis
Jun 25, 2018
Member
More succinct of way of doing it:
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()) # compute intersection
for name in bad_headers:
# lineno = all_headers[name]It's also slightly more idiomatic vis-a-vis other include checks.
This comment has been minimized.
This comment has been minimized.
ryzokuken
Jun 26, 2018
Author
Member
@bnoordhuis okay, will try this. That said, I'm more interested at this point to find out what's wrong with my solution? It might not be idiomatic, but it should work. Why does error not work?
This comment has been minimized.
This comment has been minimized.
bnoordhuis
Jun 26, 2018
Member
Oh, is that your question? :-)
I assume you're testing it from the command line like this: python tools/cpplint.py src/*.cc?
Look for _DEFAULT_FILTERS: build/include is off by default. Pass --filter=build/include to test it, or --filter=+build/include to enable it in addition to the other rules.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bnoordhuis this works. Let me know if it looks okay and I'll squash the changes together. |
ryzokuken
changed the title
[WIP] Lint for inline headers
tools: lint for inline headers
Jun 27, 2018
ryzokuken
added
author ready
and removed
work in progress (WIP)
author ready
labels
Jun 27, 2018
This comment has been minimized.
This comment has been minimized.
|
/cc @nodejs/python |
bnoordhuis
approved these changes
Jun 27, 2018
|
|
||
| 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) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jasnell
approved these changes
Jun 29, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
CI passed, landing this. |
This comment has been minimized.
This comment has been minimized.
|
Landed in fc81e80 |
ryzokuken commentedJun 25, 2018
•
edited
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes/cc @bnoordhuis
Had been reading the cpplint file today and hacked this up. LMK how this looks to you.