-
Notifications
You must be signed in to change notification settings - Fork 38.7k
lint: Add linter to error on #include <*.cpp> #13301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
With @practicalswift #13288 (comment) Current failures, via travis: |
|
Concept ACK |
|
ACK 177dc4277722c2e3d5c34bab4de3951055510a88 Very nice! :-) Love these small regression tests that make sure we'll never have to think about a given class of otherwise recurring mistakes/issues ever again. Tiny nit: Could be added to existing |
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
contrib/devtools/lint-include-cpp.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
#!/usr/bin/env bash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, every bash invocation is via #!/bin/bash. I'm seeing arguments for using bin/env for compatibility across more systems, e.g. OpenBSD, and some concerns about potential security issues if malicious code corrupts the path. Not sure how to value those.
contrib/devtools/lint-include-cpp.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these glob portable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@promag They are expanded by git and not the shell, but even if they were handled by bash they would have be portable, no? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@promag They are expanded by git
👍
but even if they were handled by bash they would have be portable, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provided it's run from the project root (which is how it's run on Travis), it should get all cpp/h files - it's just the top level that is missed by ** in some cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I now understand what you meant. What about changing it from "**/*.cpp" "**/*.h" to "*.cpp" "*.h"? That will work regardless of where it is run from.
|
Sorry to be skeptical here, but does this really happen enough to merit adding yet another linter? |
|
@laanwj Generally, I'm in favor of more lints as implementing practice in code means that it need not be propagated / enforced by humans - particularly when the difference is easily overlooked by humans and easily detected by code. This case has been violated twice, and overlooked twice by reviewers, so an automatic check seems helpful, if we agree that it should not be violated. On that point, I agree with MarcoFalke: "Including a cpp file seems extremely wrong." That said, I'm not clear how to value the cost of |
|
Can this be combined with the other include linter, so we don't have too many "duplicate" files? |
I wouldn't mind separate files as it would allow: find contrib/devtools -name "lint-*.sh" ! -name lint-all.sh | parallel -u bash :::However flake8 takes most of the time so no gain for now (hint: |
|
Should it just check if the included file is |
|
ACK 2f2a784c7ba189628dfc5d9dbd10d1861ebaadbd |
I agree. I don't think I have a problem with it in principle. I think linters should be used to avoid sneaky problems that might result in bugs. For example one I really like is #13041, which catches potential locale-dependency bugs. Including a |
|
@laanwj Adding some data: there seems to have been a total of twelve This issue has been independently introduced twice in the code base in two separate PR:s during the last twelve months alone. The PRs (#10408, #11748) were reviewed by very skilled developers before merge. Thus it empirically seems like an extra pair of very attentive eyes in the form of Travis would be helpful in making sure this 10000-pound elephant doesn't sneak into the code base again :-) |
|
@laanwj Regarding the potential maintenance need for the linting shell scripts: I volunteer to maintain all the linter scripts in the repo if that is of any help. In the event of a linter causing problems just ping me in and I'll fix it quickly! :-) |
Even on the desirability there is an alternative perspective, FWIW: at one of my previous employers we maintained a huge system, and including the Not saying that we should do that here, but it's all too easy to be blanket against something if it offends your aesthetic sensibilities.
Heh :)
Okay! Thanks. |
I highly doubt that a single |
|
Oh, I see this was already combined into the existing file. utACK, but needs rebase. |
Files should depend on one another by interface, not by implementation. This checks for quoted includes as well. With practicalswift
ken2812221
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 9d6c9db
|
Rebased for #13385 |
9d6c9db lint: Add linter to error on #include <*.cpp> (Ben Woosley) Pull request description: Files should depend on one another by interface, not by implementation. This checks for quoted includes as well. Tree-SHA512: d36d468f48d538077f5f927b9561729fd7d76319f6b2e2cc10414a9f243588194e90ca1d85eca65019f9259268f555d25106eaaa56da28c58fa8d5837b469661
9d6c9db lint: Add linter to error on #include <*.cpp> (Ben Woosley) Pull request description: Files should depend on one another by interface, not by implementation. This checks for quoted includes as well. Tree-SHA512: d36d468f48d538077f5f927b9561729fd7d76319f6b2e2cc10414a9f243588194e90ca1d85eca65019f9259268f555d25106eaaa56da28c58fa8d5837b469661
Files should depend on one another by interface, not by implementation.
This checks for quoted includes as well.