-
Notifications
You must be signed in to change notification settings - Fork 60
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
A5-2-6
: Exclude cases with the same binary operator
#231
Comments
A5-2-6
: Do not consider ->
and .
as binary opratorsA5-2-6
: Do not consider ->
and .
as binary operators
Reviewing the query, the description above is not accurate. The query already only reports |
A5-2-6
: Do not consider ->
and .
as binary operatorsA5-2-6
: Consider excluding cases with the same binary operator
Issue body updated: the problem has been identified as related to (a) confusion caused by the alert message about where the brackets should apply and (b) an over-zealous rule. |
A5-2-6
: Consider excluding cases with the same binary operatorA5-2-6
: Exclude cases with the same binary operator
I would like to report a similar over-zealous case when using the same comparison operator: (a == 0) && (b == 0) // True negative, OK
(a == 0) && (b == 0) && ( c == 0) // Triggers A5-2-6 warning (zealous)
((a == 0) && (b == 0)) && ( c == 0) // Needs to do this to avoid A5-2-6 warning, which alters readability of code AUTOSAR C++14 is not really clear for this specific case. |
This will be addressed by: #753 |
Affected rules
A5-2-6
Description
It's not well defined by the standard, but I think it's reasonable to exclude->
and.
when considering whether an operand of a logical operator is binary.Update: We thought the query was incorrectly reporting
->
and.
as binary operators. However, the problem was a confusion over this example:foo->bar() && foo->baz() && foo->bang()
Where the query is reporting that this should be bracketed like so:
(foo->bar() && foo->baz()) && foo->bang()
This is a grey area in the rule itself - technically the title implies we should report this case. However, the rationale states:
Which I think argues against asking for the developers to add unnecessary brackets in this case.
Proposed next steps:
Example
foo->bar() && foo->baz() && foo->bang()
The text was updated successfully, but these errors were encountered: