Skip to content

Commit

Permalink
A7-1-1: Do not report for function parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
lcartey committed Nov 22, 2023
1 parent b72ba4f commit b142501
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 76 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion cpp/autosar/test/rules/A7-1-1/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
void f1(int *p) { // COMPLIANT
*p += 2;
}
void f2(int *p) { // NON_COMPLIANT
void f2(int *p) { // COMPLIANT - we ignore parameters for this rule
int l4 = 1; // NON_COMPLIANT
int *p1 = p; // NON_COMPLIANT
}
Expand Down
17 changes: 0 additions & 17 deletions cpp/common/src/codingstandards/cpp/exclusions/cpp/Const.qll
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import codingstandards.cpp.exclusions.RuleMetadata

newtype ConstQuery =
TRemoveConstOrVolatileQualificationAutosarQuery() or
TDeclarationUnmodifiedParamMissingConstSpecifierQuery() or
TDeclarationUnmodifiedObjectMissingConstSpecifierQuery() or
TVariableMissingConstexprQuery() or
TFunctionMissingConstexprQuery() or
Expand All @@ -28,15 +27,6 @@ predicate isConstQueryMetadata(Query query, string queryId, string ruleId, strin
ruleId = "A5-2-3" and
category = "required"
or
query =
// `Query` instance for the `declarationUnmodifiedParamMissingConstSpecifier` query
ConstPackage::declarationUnmodifiedParamMissingConstSpecifierQuery() and
queryId =
// `@id` for the `declarationUnmodifiedParamMissingConstSpecifier` query
"cpp/autosar/declaration-unmodified-param-missing-const-specifier" and
ruleId = "A7-1-1" and
category = "required"
or
query =
// `Query` instance for the `declarationUnmodifiedObjectMissingConstSpecifier` query
ConstPackage::declarationUnmodifiedObjectMissingConstSpecifierQuery() and
Expand Down Expand Up @@ -145,13 +135,6 @@ module ConstPackage {
TQueryCPP(TConstPackageQuery(TRemoveConstOrVolatileQualificationAutosarQuery()))
}

Query declarationUnmodifiedParamMissingConstSpecifierQuery() {
//autogenerate `Query` type
result =
// `Query` type for `declarationUnmodifiedParamMissingConstSpecifier` query
TQueryCPP(TConstPackageQuery(TDeclarationUnmodifiedParamMissingConstSpecifierQuery()))
}

Query declarationUnmodifiedObjectMissingConstSpecifierQuery() {
//autogenerate `Query` type
result =
Expand Down
18 changes: 4 additions & 14 deletions rule_packages/cpp/Const.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@
"obligation": "required"
},
"queries": [
{
"description": "`Constexpr`/`const` specifiers prevent unintentional data modification for parameters intended as immutable.",
"kind": "problem",
"name": "Constexpr or const specifiers shall be used for immutable parameter usage",
"precision": "high",
"severity": "warning",
"short_name": "DeclarationUnmodifiedParamMissingConstSpecifier",
"tags": [
"correctness",
"maintainability",
"readability"
]
},
{
"description": "`Constexpr`/`const` specifiers prevent unintentional data modification for data intended as immutable.",
"kind": "problem",
Expand All @@ -57,7 +44,10 @@
"correctness",
"maintainability",
"readability"
]
],
"implementation_scope": {
"description": "We exclude function parameters from this rule in line with the rule intention as described in the C++ Core Guidelines Con.1 which excludes function parameters."
}
}
],
"title": "Constexpr or const specifiers shall be used for immutable data declaration."
Expand Down

0 comments on commit b142501

Please sign in to comment.