Skip to content
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

cpplint: Fails to warn about many brackets #40

Closed
alexhenning opened this issue Aug 14, 2015 · 4 comments
Closed

cpplint: Fails to warn about many brackets #40

alexhenning opened this issue Aug 14, 2015 · 4 comments

Comments

@alexhenning
Copy link
Contributor

The current brace check overlooks many instances of the braces being on the same line. This is due to the fact that in line 99 it suppresses any warnings where there is an = sign on the line. However, this occurs in many common cases:

if (i == 0) {
for (int i = 0; i < 10; i++) {
while (i == 0) {

I think the best fix is to check if the { is preceded by a ) in which case it is likely one of the above. I don't think that would occur with a brace initializer.

@mikepurvis Thoughts?

@mikepurvis
Copy link
Member

That sounds reasonable.

@alexhenning
Copy link
Contributor Author

Alright, I'll make a pull request with the change later today.

@mikepurvis
Copy link
Member

Another way would be changing the whitelist to be the specific string "= {" rather than the much broader "= appears anywhere in the line".

alexhenning pushed a commit to alexhenning/roslint that referenced this issue Aug 14, 2015
Fixes issue ros#40 where there were no warnings for the following common
statements:

```
if (i == 0) {
for (int i = 0; i < 10; i++) {
while (i == 0) {
```
@alexhenning
Copy link
Contributor Author

I think that method still runs into problems when an initializer is used in a for loop. I don't think that's common and it's an improvement over the current state, but I think my solution in #41 doesn't have that drawback. Let me know what you think, I can switch it if you'd prefer.

mikepurvis added a commit that referenced this issue Aug 15, 2015
Fixes #40. Warns if `{` not on its own line
hycwuy added a commit to hycwuy/roslint that referenced this issue Sep 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants