Skip to content

Commit 7d20e9c

Browse files
authored
Merge pull request #164 from jsinglet/jsinglet/automation-check-shared-rules
Upgrades to Automation for Shared Rule Checking
2 parents 7072866 + e8b3f1e commit 7d20e9c

File tree

37 files changed

+632
-90
lines changed

37 files changed

+632
-90
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: ⚙️ Extra Rule Validation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "rc/**"
8+
- next
9+
pull_request:
10+
branches:
11+
- main
12+
- "rc/**"
13+
- next
14+
15+
16+
jobs:
17+
validate-rules-csv:
18+
name: Validate Rules CSV
19+
runs-on: ubuntu-22.04
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
24+
- name: Check Rules
25+
shell: pwsh
26+
run: scripts/util/Get-DuplicateRules.ps1 -Language 'all' -CIMode
27+
28+
29+
validate-shared-rules-test-structure:
30+
name: Validate Rules Test Structure
31+
runs-on: ubuntu-22.04
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v2
35+
36+
- name: Ensure CPP Shared Rules Have Valid Structure
37+
shell: pwsh
38+
run: scripts/util/Test-SharedImplementationsHaveTestCases.ps1 -Language cpp -CIMode
39+
40+
- name: Ensure C Shared Rules Have Valid Structure
41+
shell: pwsh
42+
run: scripts/util/Test-SharedImplementationsHaveTestCases.ps1 -Language c -CIMode
43+
44+
45+
- uses: actions/upload-artifact@v3
46+
if: failure()
47+
with:
48+
name: missing-test-report.csv
49+
path: MissingTestReport*.csv
50+
51+
- uses: actions/upload-artifact@v3
52+
if: failure()
53+
with:
54+
name: test-report.csv
55+
path: TestReport*.csv
56+
if-no-files-found: error
57+
58+

.github/workflows/validate-rules-csv.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
| test.c:4:5:4:13 | case1_FOO | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:4:5:4:13 | case1_FOO | case1_FOO | test.c:3:5:3:13 | case1_foo | case1_foo |
2+
| test.c:4:5:4:13 | case1_FOO | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:4:5:4:13 | case1_FOO | case1_FOO | test.c:5:5:5:13 | case1_fOo | case1_fOo |
3+
| test.c:5:5:5:13 | case1_fOo | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:5:5:5:13 | case1_fOo | case1_fOo | test.c:3:5:3:13 | case1_foo | case1_foo |
4+
| test.c:8:5:8:15 | case2_f_o_o | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:8:5:8:15 | case2_f_o_o | case2_f_o_o | test.c:7:5:7:13 | case2_foo | case2_foo |
5+
| test.c:11:5:11:13 | case3_fO0 | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:11:5:11:13 | case3_fO0 | case3_fO0 | test.c:10:5:10:13 | case3_fOO | case3_fOO |
6+
| test.c:13:5:13:12 | case4_II | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:13:5:13:12 | case4_II | case4_II | test.c:15:5:15:12 | case4_Il | case4_Il |
7+
| test.c:14:5:14:12 | case4_I1 | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:14:5:14:12 | case4_I1 | case4_I1 | test.c:13:5:13:12 | case4_II | case4_II |
8+
| test.c:14:5:14:12 | case4_I1 | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:14:5:14:12 | case4_I1 | case4_I1 | test.c:15:5:15:12 | case4_Il | case4_Il |
9+
| test.c:18:5:18:11 | case5_5 | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:18:5:18:11 | case5_5 | case5_5 | test.c:17:5:17:11 | case5_S | case5_S |
10+
| test.c:21:5:21:11 | case6_2 | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:21:5:21:11 | case6_2 | case6_2 | test.c:20:5:20:11 | case6_Z | case6_Z |
11+
| test.c:24:5:24:11 | case7_h | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:24:5:24:11 | case7_h | case7_h | test.c:23:5:23:11 | case7_n | case7_n |
12+
| test.c:27:5:27:11 | case8_8 | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:27:5:27:11 | case8_8 | case8_8 | test.c:26:5:26:11 | case8_B | case8_B |
13+
| test.c:30:5:30:11 | case9_m | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:30:5:30:11 | case9_m | case9_m | test.c:29:5:29:12 | case9_rn | case9_rn |
14+
| test.c:31:5:31:12 | case9_rh | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:31:5:31:12 | case9_rh | case9_rh | test.c:29:5:29:12 | case9_rn | case9_rn |
15+
| test.c:34:5:34:15 | case10_xmmx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:34:5:34:15 | case10_xmmx | case10_xmmx | test.c:33:5:33:17 | case10_xrnrnx | case10_xrnrnx |
16+
| test.c:34:5:34:15 | case10_xmmx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:34:5:34:15 | case10_xmmx | case10_xmmx | test.c:35:5:35:16 | case10_xmrnx | case10_xmrnx |
17+
| test.c:34:5:34:15 | case10_xmmx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:34:5:34:15 | case10_xmmx | case10_xmmx | test.c:36:5:36:16 | case10_xrnmx | case10_xrnmx |
18+
| test.c:35:5:35:16 | case10_xmrnx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:35:5:35:16 | case10_xmrnx | case10_xmrnx | test.c:33:5:33:17 | case10_xrnrnx | case10_xrnrnx |
19+
| test.c:35:5:35:16 | case10_xmrnx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:35:5:35:16 | case10_xmrnx | case10_xmrnx | test.c:36:5:36:16 | case10_xrnmx | case10_xrnmx |
20+
| test.c:35:5:35:16 | case10_xmrnx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:35:5:35:16 | case10_xmrnx | case10_xmrnx | test.c:37:5:37:17 | case10_xrnrhx | case10_xrnrhx |
21+
| test.c:36:5:36:16 | case10_xrnmx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:36:5:36:16 | case10_xrnmx | case10_xrnmx | test.c:33:5:33:17 | case10_xrnrnx | case10_xrnrnx |
22+
| test.c:37:5:37:17 | case10_xrnrhx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:37:5:37:17 | case10_xrnrhx | case10_xrnrhx | test.c:33:5:33:17 | case10_xrnrnx | case10_xrnrnx |
23+
| test.c:38:5:38:17 | case10_xrhrhx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:38:5:38:17 | case10_xrhrhx | case10_xrhrhx | test.c:33:5:33:17 | case10_xrnrnx | case10_xrnrnx |
24+
| test.c:38:5:38:17 | case10_xrhrhx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:38:5:38:17 | case10_xrhrhx | case10_xrhrhx | test.c:37:5:37:17 | case10_xrnrhx | case10_xrnrhx |
25+
| test.c:39:5:39:16 | case10_xmrhx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:39:5:39:16 | case10_xmrhx | case10_xmrhx | test.c:33:5:33:17 | case10_xrnrnx | case10_xrnrnx |
26+
| test.c:39:5:39:16 | case10_xmrhx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:39:5:39:16 | case10_xmrhx | case10_xmrhx | test.c:35:5:35:16 | case10_xmrnx | case10_xmrnx |
27+
| test.c:39:5:39:16 | case10_xmrhx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:39:5:39:16 | case10_xmrhx | case10_xmrhx | test.c:37:5:37:17 | case10_xrnrhx | case10_xrnrhx |
28+
| test.c:40:5:40:16 | case10_xrhmx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:40:5:40:16 | case10_xrhmx | case10_xrhmx | test.c:33:5:33:17 | case10_xrnrnx | case10_xrnrnx |
29+
| test.c:40:5:40:16 | case10_xrhmx | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:40:5:40:16 | case10_xrhmx | case10_xrhmx | test.c:36:5:36:16 | case10_xrnmx | case10_xrnmx |
30+
| test.c:42:15:42:22 | case11_O | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:42:15:42:22 | case11_O | case11_O | test.c:42:5:42:12 | case11_o | case11_o |
31+
| test.c:45:5:45:14 | case12_8bB | The identifier $@ is not typographically unambiguous from the identifier $@ | test.c:45:5:45:14 | case12_8bB | case12_8bB | test.c:44:5:44:14 | case12_BBb | case12_BBb |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// GENERATED FILE - DO NOT MODIFY
2+
import codingstandards.cpp.rules.differentidentifiersnottypographicallyunambiguous.DifferentIdentifiersNotTypographicallyUnambiguous
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
2+
// CHANGES SHOULD BE REFLECTED THERE AS WELL.
3+
int case1_foo;
4+
int case1_FOO; // NON_COMPLIANT
5+
int case1_fOo; // NON_COMPLIANT
6+
7+
int case2_foo;
8+
int case2_f_o_o; // NON_COMPLIANT
9+
10+
int case3_fOO;
11+
int case3_fO0; // NON_COMPLIANT
12+
13+
int case4_II;
14+
int case4_I1; // NON_COMPLIANT
15+
int case4_Il; // NON_COMPLIANT
16+
17+
int case5_S;
18+
int case5_5; // NON_COMPLIANT
19+
20+
int case6_Z;
21+
int case6_2; // NON_COMPLIANT
22+
23+
int case7_n;
24+
int case7_h; // NON_COMPLIANT
25+
26+
int case8_B;
27+
int case8_8; // NON_COMPLIANT
28+
29+
int case9_rn;
30+
int case9_m; // NON_COMPLIANT
31+
int case9_rh; // NON_COMPLIANT
32+
33+
int case10_xrnrnx;
34+
int case10_xmmx; // NON_COMPLIANT
35+
int case10_xmrnx; // NON_COMPLIANT
36+
int case10_xrnmx; // NON_COMPLIANT
37+
int case10_xrnrhx; // NON_COMPLIANT
38+
int case10_xrhrhx; // NON_COMPLIANT
39+
int case10_xmrhx; // NON_COMPLIANT
40+
int case10_xrhmx; // NON_COMPLIANT
41+
42+
int case11_o, case11_O; // NON_COMPLIANT
43+
44+
int case12_BBb;
45+
int case12_8bB; // NON_COMPLIANT
46+
47+
// Transitive rules are compliant
48+
49+
// m -> rn -> rh
50+
int case13_m;
51+
int case13_rh; // COMPLIANT
52+
53+
// b -> B -> 8
54+
int case14_b;
55+
int case14_8; // COMPLIANT
56+
57+
// z -> Z -> 2
58+
int case15_z;
59+
int case15_2; // COMPLIANT
60+
61+
// s -> S -> 5
62+
int case16_s;
63+
int case16_5; // COMPLIANT
64+
65+
// o -> O -> 0
66+
int case17_o;
67+
int case17_0;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.c:5:47:5:50 | call to rand | Use of banned function rand. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// GENERATED FILE - DO NOT MODIFY
2+
import codingstandards.cpp.rules.donotuserandforgeneratingpseudorandomnumbers.DoNotUseRandForGeneratingPseudorandomNumbers
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
2+
// CHANGES SHOULD BE REFLECTED THERE AS WELL.
3+
#include <stdlib.h>
4+
5+
void test_use_of_rand() { int random_number = rand() % 10; }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| test.c:11:1:11:22 | #define MACROFIVE(X) #X | Macro definition uses the # or ## operator. |
2+
| test.c:13:1:13:26 | #define MACROSIX(X,Y) X ## Y | Macro definition uses the # or ## operator. |
3+
| test.c:15:1:15:29 | #define MACROSEVEN "##'" #"#" | Macro definition uses the # or ## operator. |
4+
| test.c:17:1:17:28 | #define MACROEIGHT '##' #"#" | Macro definition uses the # or ## operator. |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// GENERATED FILE - DO NOT MODIFY
2+
import codingstandards.cpp.rules.hashoperatorsused.HashOperatorsUsed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
2+
// CHANGES SHOULD BE REFLECTED THERE AS WELL.
3+
#define MACROONE 1 // COMPLIANT
4+
5+
#define MACROTWO '#' // COMPLIANT
6+
7+
#define MACROTHREE "##" // COMPLIANT
8+
9+
#define MACROFOUR "##" + "#" // COMPLIANT
10+
11+
#define MACROFIVE(X) #X // NON_COMPLIANT
12+
13+
#define MACROSIX(X, Y) X##Y // NON_COMPLIANT
14+
15+
#define MACROSEVEN "##'" #"#" // NON_COMPLIANT
16+
17+
#define MACROEIGHT '##' #"#" // NON_COMPLIANT
18+
19+
#define MACRONINE "##\"\"" + "#" // COMPLIANT
20+
21+
#define MACROTEN "##\"\"'" + "#" // COMPLIANT
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| test.c:8:1:8:1 | return ... | Function test_return_f1 should return a value of type int but does not return a value here |
2+
| test.c:18:27:18:28 | { ... } | Function test_return_f3 should return a value of type int but does not return a value here |
3+
| test.c:27:1:27:1 | return ... | Function test_return_f5 should return a value of type int but does not return a value here |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// GENERATED FILE - DO NOT MODIFY
2+
import codingstandards.cpp.rules.nonvoidfunctiondoesnotreturn.NonVoidFunctionDoesNotReturn
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
2+
// CHANGES SHOULD BE REFLECTED THERE AS WELL.
3+
#include <stdlib.h>
4+
int test_return_f1(int i) { // NON_COMPLIANT
5+
if (i > 100) {
6+
return i;
7+
}
8+
}
9+
10+
int test_return_f2(int i) { // COMPLIANT
11+
if (i > 0) {
12+
return i;
13+
} else {
14+
return -i;
15+
}
16+
}
17+
18+
int test_return_f3(int i) {} // NON_COMPLIANT
19+
20+
int test_return_f5(int i) { // NON_COMPLIANT
21+
if (i > 0) {
22+
return i;
23+
}
24+
if (i < 0) {
25+
return -i;
26+
}
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| test.c:39:1:39:39 | // int myFunction() { return myValue; } | This comment appears to contain commented-out code. |
2+
| test.c:41:1:41:45 | // int myFunction() const { return myValue; } | This comment appears to contain commented-out code. |
3+
| test.c:43:1:43:54 | // int myFunction() const noexcept { return myValue; } | This comment appears to contain commented-out code. |
4+
| test.c:45:1:45:18 | // #define MYMACRO | This comment appears to contain commented-out code. |
5+
| test.c:47:1:47:23 | // #include "include.h" | This comment appears to contain commented-out code. |
6+
| test.c:49:1:53:2 | /*\n#ifdef\nvoid myFunction();\n#endif\n*/ | This comment appears to contain commented-out code. |
7+
| test.c:61:1:61:24 | // #if(defined(MYMACRO)) | This comment appears to contain commented-out code. |
8+
| test.c:65:1:65:15 | // #pragma once | This comment appears to contain commented-out code. |
9+
| test.c:67:1:67:17 | // # pragma once | This comment appears to contain commented-out code. |
10+
| test.c:69:1:69:19 | /*#error"myerror"*/ | This comment appears to contain commented-out code. |
11+
| test.c:93:1:97:2 | /*\n#ifdef MYMACRO\n // ...\n#endif // #ifdef MYMACRO\n*/ | This comment appears to contain commented-out code. |
12+
| test.c:108:21:108:43 | // #include "config2.h" | This comment appears to contain commented-out code. |
13+
| test.c:114:16:114:35 | /* #ifdef MYMACRO */ | This comment appears to contain commented-out code. |
14+
| test.c:118:1:118:24 | // commented_out_code(); | This comment appears to contain commented-out code. |
15+
| test.c:121:2:121:25 | // commented_out_code(); | This comment appears to contain commented-out code. |
16+
| test.c:124:1:124:22 | // commented out code; | This comment appears to contain commented-out code. |
17+
| test.c:126:1:129:8 | // some; | This comment appears to contain commented-out code. |
18+
| test.c:131:1:135:8 | // also; | This comment appears to contain commented-out code. |
19+
| test.c:143:1:148:2 | /*\n some;\n commented;\n out;\n code;\n*/ | This comment appears to contain commented-out code. |
20+
| test.c:150:1:156:2 | /*\n also;\n this\n is;\n commented-out\n code;\n*/ | This comment appears to contain commented-out code. |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// GENERATED FILE - DO NOT MODIFY
2+
import codingstandards.cpp.rules.sectionsofcodeshallnotbecommentedout.SectionsOfCodeShallNotBeCommentedOut

c/common/test/rules/sectionsofcodeshallnotbecommentedout/config.h

Whitespace-only changes.

0 commit comments

Comments
 (0)