diff --git a/change_notes/2023-07-11-lambda-expr-without-param-list.md b/change_notes/2023-07-11-lambda-expr-without-param-list.md new file mode 100644 index 0000000000..4a5b4cf5ad --- /dev/null +++ b/change_notes/2023-07-11-lambda-expr-without-param-list.md @@ -0,0 +1 @@ + - Only consider lambdas that have zero arguments, since any lambda with non-zero arguments will have an explicit argument list. diff --git a/cpp/autosar/src/rules/A5-1-3/LambdaExpressionWithoutParameterList.ql b/cpp/autosar/src/rules/A5-1-3/LambdaExpressionWithoutParameterList.ql index 4583f8675e..db39a62d8e 100644 --- a/cpp/autosar/src/rules/A5-1-3/LambdaExpressionWithoutParameterList.ql +++ b/cpp/autosar/src/rules/A5-1-3/LambdaExpressionWithoutParameterList.ql @@ -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.