Skip to content

Commit

Permalink
Merge branch 'main' into fix-issue-755
Browse files Browse the repository at this point in the history
  • Loading branch information
lcartey authored Nov 21, 2024
2 parents 9163881 + 9dc1ca4 commit 50fe082
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 24 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/code-scanning-pack-gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ jobs:
- name: Determine ref for external help files
id: determine-ref
run: |
if [[ $GITHUB_EVENT_NAME == "pull_request" || $GITHUB_EVENT_NAME == "merge_group" ]]; then
echo "EXTERNAL_HELP_REF=$GITHUB_HEAD_REF" >> "$GITHUB_ENV"
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then
EXTERNAL_HELP_REF="${{ github.event.pull_request.base.ref }}"
elif [[ $GITHUB_EVENT_NAME == "merge_group" ]]; then
EXTERNAL_HELP_REF="${{ github.event.merge_group.base_ref }}"
else
echo "EXTERNAL_HELP_REF=$GITHUB_REF" >> "$GITHUB_ENV"
EXTERNAL_HELP_REF="$GITHUB_REF"
fi
echo "EXTERNAL_HELP_REF=$EXTERNAL_HELP_REF" >> "$GITHUB_ENV"
echo "Using ref $EXTERNAL_HELP_REF for external help files."
- name: Checkout external help files
continue-on-error: true
id: checkout-external-help-files
uses: actions/checkout@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions change_notes/2024-10-30-fix-issue-629.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `A7-1-7` - `IdentifierDeclarationAndInitializationNotOnSeparateLines.ql`
- Fixes #629. Adds brackets, excluding expressions statements in macros.
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,28 @@ import codingstandards.cpp.autosar
class UniqueLineStmt extends Locatable {
UniqueLineStmt() {
not isAffectedByMacro() and
exists(Declaration d |
this = d.getADeclarationEntry() and
not d instanceof Parameter and
not d instanceof TemplateParameter and
// TODO - Needs to be enhanced to solve issues with
// templated inner classes.
not d instanceof Function and
not d.isFromTemplateInstantiation(_) and
not d.(Variable).isCompilerGenerated() and
not exists(RangeBasedForStmt f | f.getADeclaration() = d) and
not exists(DeclStmt declStmt, ForStmt f |
f.getInitialization() = declStmt and
declStmt.getADeclaration() = d
) and
not exists(LambdaCapture lc | lc.getField().getADeclarationEntry() = this)
(
exists(Declaration d |
this = d.getADeclarationEntry() and
not d instanceof Parameter and
not d instanceof TemplateParameter and
// TODO - Needs to be enhanced to solve issues with
// templated inner classes.
not d instanceof Function and
not d.isFromTemplateInstantiation(_) and
not d.(Variable).isCompilerGenerated() and
not exists(RangeBasedForStmt f | f.getADeclaration() = d) and
not exists(DeclStmt declStmt, ForStmt f |
f.getInitialization() = declStmt and
declStmt.getADeclaration() = d
) and
not exists(LambdaCapture lc | lc.getField().getADeclarationEntry() = this)
)
or
this instanceof ExprStmt and
not exists(ForStmt f | f.getInitialization().getAChild*() = this) and
not exists(LambdaExpression l | l.getLambdaFunction().getBlock().getAChild*() = this)
)
or
this instanceof ExprStmt and
not exists(ForStmt f | f.getInitialization().getAChild*() = this) and
not exists(LambdaExpression l | l.getLambdaFunction().getBlock().getAChild*() = this)
}
}

Expand Down
12 changes: 11 additions & 1 deletion cpp/autosar/test/rules/A7-1-7/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,14 @@ void example_function() { f1(); } // COMPLIANT

// clang-format off
typedef struct x { int y; } z; //COMPLIANT - for struct typedef and struct var //NON_COMPLIANT - for struct all on one line
// clang-format on
// clang-format on

#define foo(x, y) \
x++; \
y++;

void test_foo() {
int a = 1;
int b = 1;
foo(a, b); // COMPLIANT
}

0 comments on commit 50fe082

Please sign in to comment.