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

False positive in "Statements should be on separate lines" #1615

Closed
hagmanen opened this issue Dec 7, 2018 · 1 comment
Closed

False positive in "Statements should be on separate lines" #1615

hagmanen opened this issue Dec 7, 2018 · 1 comment
Assignees
Labels

Comments

@hagmanen
Copy link

hagmanen commented Dec 7, 2018

Following line will cause error.

ScopeGuard guard([&](){ close(); });

With lambda expressions it should be allowed to have two ; on a line.

Found this on google: https://rules.sonarsource.com/c/RSPEC-122. Don't know how that relates to this community.

@guwirth
Copy link
Collaborator

guwirth commented Dec 7, 2018

@hagmanen thanks for your feedback.

First of all it's a matter of taste: I would write the code

ScopeGuard guard([&]() {
   close();
});

This is also much easier to read and debug.

Think the outcome of the rule is not wrong: There are two statements in a line? The code inside a lamba are also statements?

Third remark: I recommend not to use these build-in static code analysis checks. We will deprecate and remove them. It's better to use an external tool and forward the resulting report, see also #1613.

@guwirth guwirth self-assigned this Dec 7, 2018
@guwirth guwirth closed this as completed Dec 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants