Skip to content

Commit 0628e50

Browse files
authored
Merge branch 'main' into lcartey/rule-11-4-improvements
2 parents 80985df + a989829 commit 0628e50

File tree

8 files changed

+58
-6
lines changed

8 files changed

+58
-6
lines changed

.github/actions/check-permissions/action.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@ runs:
1616
steps:
1717
- uses: actions/github-script@v7
1818
id: check-permission
19+
env:
20+
INPUT_MINIMUM-PERMISSION: ${{ inputs.minimum-permission }}
1921
with:
2022
script: |
2123
// Valid permissions are none, read, write, admin (legacy base permissions)
2224
const permissionsRanking = ["none", "read", "write", "admin"];
2325
26+
// Note: core.getInput doesn't work by default in a composite action - in this case
27+
// it would try to fetch the input to the github-script instead of the action
28+
// itself. Instead, we set the appropriate magic env var with the actions input.
29+
// See: https://github.com/actions/runner/issues/665
2430
const minimumPermission = core.getInput('minimum-permission');
2531
if (!permissionsRanking.includes(minimumPermission)) {
2632
core.setFailed(`Invalid minimum permission: ${minimumPermission}`);
@@ -30,14 +36,14 @@ runs:
3036
const { data : { permission : actorPermission } } = await github.rest.repos.getCollaboratorPermissionLevel({
3137
owner: context.repo.owner,
3238
repo: context.repo.repo,
33-
username: tools.context.actor
39+
username: context.actor
3440
});
3541
3642
// Confirm whether the actor permission is at least the selected permission
3743
const hasPermission = permissionsRanking.indexOf(minimumPermission) <= permissionsRanking.indexOf(actorPermission) ? "1" : "";
3844
core.setOutput('has-permission', hasPermission);
3945
if (!hasPermission) {
40-
core.info(`Current actor (${tools.context.actor}) does not have the minimum required permission '${minimumPermission}' (has '${actorPermission}')`);
46+
core.info(`Current actor (${context.actor}) does not have the minimum required permission '${minimumPermission}' (has '${actorPermission}')`);
4147
} else {
42-
core.info(`Current actor (${tools.context.actor}) has the minimum required permission '${minimumPermission}' (has '${actorPermission}')`);
43-
}
48+
core.info(`Current actor (${context.actor}) has the minimum required permission '${minimumPermission}' (has '${actorPermission}')`);
49+
}

.github/workflows/dispatch-matrix-check.yml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
dispatch-matrix-check:
1212
runs-on: ubuntu-22.04
1313
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
1417
- name: Check permission
1518
id: check-write-permission
1619
uses: ./.github/actions/check-permissions

.github/workflows/dispatch-matrix-test-on-comment.yml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
dispatch-matrix-check:
99
runs-on: ubuntu-22.04
1010
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
1114
- name: Check permission
1215
id: check-write-permission
1316
uses: ./.github/actions/check-permissions

.github/workflows/dispatch-release-performance-check.yml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
dispatch-matrix-check:
99
runs-on: ubuntu-22.04
1010
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
1114
- name: Check permission
1215
id: check-write-permission
1316
uses: ./.github/actions/check-permissions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A2-7-3` - `UndocumentedUserDefinedType.ql`:
2+
- Fixes #606. Fix false positive relating to friend functions in template classes.

cpp/autosar/src/rules/A2-7-3/UndocumentedUserDefinedType.ql

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ class DocumentableDeclaration extends Declaration {
7777
// Exclude instantiated template functions, which cannot reasonably be documented.
7878
not this.(Function).isFromTemplateInstantiation(_) and
7979
// Exclude anonymous lambda functions.
80-
not exists(LambdaExpression lc | lc.getLambdaFunction() = this)
80+
not exists(LambdaExpression lc | lc.getLambdaFunction() = this) and
81+
//Exclude friend functions (because they have 2 entries in the database), and only one shows documented truly
82+
not exists(FriendDecl d |
83+
d.getFriend().(Function).getDefinition() = this.getADeclarationEntry()
84+
)
8185
or
8286
this instanceof MemberVariable and
8387
declarationType = "member variable" and

cpp/autosar/test/rules/A2-7-3/UndocumentedUserDefinedType.expected

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
| test.cpp:101:6:101:6 | definition of e | Declaration entry for function e is missing documentation. |
1010
| test.cpp:108:1:108:30 | definition of message_to_string_undocumented | Declaration entry for function message_to_string_undocumented is missing documentation. |
1111
| test.cpp:180:21:180:24 | definition of kBar | Declaration entry for member variable kBar is missing documentation. |
12+
| test.cpp:227:14:227:17 | definition of foo3 | Declaration entry for function foo3 is missing documentation. |

cpp/autosar/test/rules/A2-7-3/test.cpp

+31-1
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,34 @@ void testFunctionScope() {
195195
void fNestedTest(); // COMPLIANT - in function scope
196196
};
197197
};
198-
}
198+
}
199+
200+
/// Test documentation
201+
template <typename T> class ClassG { // COMPLIANT
202+
private:
203+
/// Test documentation
204+
int x; // COMPLIANT
205+
206+
public:
207+
/// Test documentation
208+
friend int foo(ClassG<T> g) { return g.x; } // COMPLIANT
209+
};
210+
211+
/// Test documentation
212+
void test() { // COMPLIANT
213+
ClassG<int> g;
214+
foo(g);
215+
}
216+
217+
/// Test documentation
218+
class ClassG2 { // COMPLIANT
219+
public:
220+
/// Test documentation
221+
friend int foo2() { return 1; } // COMPLIANT
222+
};
223+
224+
/// Test documentation
225+
class ClassG3 { // COMPLIANT
226+
public:
227+
friend int foo3() { return 1; } // NON_COMPLIANT
228+
};

0 commit comments

Comments
 (0)