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

A7-1-1: Do not report for function parameters #445

Merged
merged 5 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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
Loading