Skip to content

Commit

Permalink
Merge pull request #348 from rak3-sh/rp/a5-1-3-false-positives-fix
Browse files Browse the repository at this point in the history
Fix for A5-1-3 false positives
  • Loading branch information
lcartey authored Aug 30, 2023
2 parents 9c7da19 + 4297f0a commit efe6b63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions change_notes/2023-07-11-lambda-expr-without-param-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `A5-1-3` - Only consider lambdas that have zero arguments, since any lambda with non-zero arguments will have an explicit argument list.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ where
not isExcluded(lambda, LambdasPackage::lambdaExpressionWithoutParameterListQuery()) and
lambdaFunction = lambda.getLambdaFunction() and
not lambdaFunction.isAffectedByMacro() and
// If it has a parameter, then it will have an
// explicit parameter list. Therefore, proceed to check only if the lambda
// does not have any parameters.
not exists (lambdaFunction.getAParameter()) and
// The extractor doesn't store the syntactic information whether the parameter list
// is enclosed in parenthesis. Therefore we cannot determine if the parameter list is
// explicitly specified when the parameter list is empty.
Expand Down
9 changes: 8 additions & 1 deletion cpp/autosar/test/rules/A5-1-3/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,11 @@ void test() {
l1 += 1;
};
// clang-format on
}
}

#define PARAM_MACRO [](int i) { i; };

int test_lambda_in_macro() {
PARAM_MACRO // COMPLIANT
return 0;
}

0 comments on commit efe6b63

Please sign in to comment.