Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
58 changes: 58 additions & 0 deletions .github/workflows/extra-rule-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: ⚙️ Extra Rule Validation

on:
push:
branches:
- main
- "rc/**"
- next
pull_request:
branches:
- main
- "rc/**"
- next


jobs:
validate-rules-csv:
name: Validate Rules CSV
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Check Rules
shell: pwsh
run: scripts/util/Get-DuplicateRules.ps1 -Language 'all' -CIMode


validate-shared-rules-test-structure:
name: Validate Rules Test Structure
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Ensure CPP Shared Rules Have Valid Structure
shell: pwsh
run: scripts/util/Test-SharedImplementationsHaveTestCases.ps1 -Language cpp -CIMode

- name: Ensure C Shared Rules Have Valid Structure
shell: pwsh
run: scripts/util/Test-SharedImplementationsHaveTestCases.ps1 -Language c -CIMode


- uses: actions/upload-artifact@v3
if: failure()
with:
name: missing-test-report.csv
path: MissingTestReport*.csv

- uses: actions/upload-artifact@v3
if: failure()
with:
name: test-report.csv
path: TestReport*.csv
if-no-files-found: error


28 changes: 0 additions & 28 deletions .github/workflows/validate-rules-csv.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 number Diff line number Diff line change
@@ -0,0 +1,2 @@
// GENERATED FILE - DO NOT MODIFY
import codingstandards.cpp.rules.differentidentifiersnottypographicallyunambiguous.DifferentIdentifiersNotTypographicallyUnambiguous
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
// CHANGES SHOULD BE REFLECTED THERE AS WELL.
int case1_foo;
int case1_FOO; // NON_COMPLIANT
int case1_fOo; // NON_COMPLIANT

int case2_foo;
int case2_f_o_o; // NON_COMPLIANT

int case3_fOO;
int case3_fO0; // NON_COMPLIANT

int case4_II;
int case4_I1; // NON_COMPLIANT
int case4_Il; // NON_COMPLIANT

int case5_S;
int case5_5; // NON_COMPLIANT

int case6_Z;
int case6_2; // NON_COMPLIANT

int case7_n;
int case7_h; // NON_COMPLIANT

int case8_B;
int case8_8; // NON_COMPLIANT

int case9_rn;
int case9_m; // NON_COMPLIANT
int case9_rh; // NON_COMPLIANT

int case10_xrnrnx;
int case10_xmmx; // NON_COMPLIANT
int case10_xmrnx; // NON_COMPLIANT
int case10_xrnmx; // NON_COMPLIANT
int case10_xrnrhx; // NON_COMPLIANT
int case10_xrhrhx; // NON_COMPLIANT
int case10_xmrhx; // NON_COMPLIANT
int case10_xrhmx; // NON_COMPLIANT

int case11_o, case11_O; // NON_COMPLIANT

int case12_BBb;
int case12_8bB; // NON_COMPLIANT

// Transitive rules are compliant

// m -> rn -> rh
int case13_m;
int case13_rh; // COMPLIANT

// b -> B -> 8
int case14_b;
int case14_8; // COMPLIANT

// z -> Z -> 2
int case15_z;
int case15_2; // COMPLIANT

// s -> S -> 5
int case16_s;
int case16_5; // COMPLIANT

// o -> O -> 0
int case17_o;
int case17_0;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| test.c:5:47:5:50 | call to rand | Use of banned function rand. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// GENERATED FILE - DO NOT MODIFY
import codingstandards.cpp.rules.donotuserandforgeneratingpseudorandomnumbers.DoNotUseRandForGeneratingPseudorandomNumbers
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
// CHANGES SHOULD BE REFLECTED THERE AS WELL.
#include <stdlib.h>

void test_use_of_rand() { int random_number = rand() % 10; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| test.c:11:1:11:22 | #define MACROFIVE(X) #X | Macro definition uses the # or ## operator. |
| test.c:13:1:13:26 | #define MACROSIX(X,Y) X ## Y | Macro definition uses the # or ## operator. |
| test.c:15:1:15:29 | #define MACROSEVEN "##'" #"#" | Macro definition uses the # or ## operator. |
| test.c:17:1:17:28 | #define MACROEIGHT '##' #"#" | Macro definition uses the # or ## operator. |
2 changes: 2 additions & 0 deletions c/common/test/rules/hashoperatorsused/HashOperatorsUsed.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// GENERATED FILE - DO NOT MODIFY
import codingstandards.cpp.rules.hashoperatorsused.HashOperatorsUsed
21 changes: 21 additions & 0 deletions c/common/test/rules/hashoperatorsused/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
// CHANGES SHOULD BE REFLECTED THERE AS WELL.
#define MACROONE 1 // COMPLIANT

#define MACROTWO '#' // COMPLIANT

#define MACROTHREE "##" // COMPLIANT

#define MACROFOUR "##" + "#" // COMPLIANT

#define MACROFIVE(X) #X // NON_COMPLIANT

#define MACROSIX(X, Y) X##Y // NON_COMPLIANT

#define MACROSEVEN "##'" #"#" // NON_COMPLIANT

#define MACROEIGHT '##' #"#" // NON_COMPLIANT

#define MACRONINE "##\"\"" + "#" // COMPLIANT

#define MACROTEN "##\"\"'" + "#" // COMPLIANT
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| 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 |
| test.c:18:27:18:28 | { ... } | Function test_return_f3 should return a value of type int but does not return a value here |
| 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 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// GENERATED FILE - DO NOT MODIFY
import codingstandards.cpp.rules.nonvoidfunctiondoesnotreturn.NonVoidFunctionDoesNotReturn
27 changes: 27 additions & 0 deletions c/common/test/rules/nonvoidfunctiondoesnotreturn/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
// CHANGES SHOULD BE REFLECTED THERE AS WELL.
#include <stdlib.h>
int test_return_f1(int i) { // NON_COMPLIANT
if (i > 100) {
return i;
}
}

int test_return_f2(int i) { // COMPLIANT
if (i > 0) {
return i;
} else {
return -i;
}
}

int test_return_f3(int i) {} // NON_COMPLIANT

int test_return_f5(int i) { // NON_COMPLIANT
if (i > 0) {
return i;
}
if (i < 0) {
return -i;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
| test.c:39:1:39:39 | // int myFunction() { return myValue; } | This comment appears to contain commented-out code. |
| test.c:41:1:41:45 | // int myFunction() const { return myValue; } | This comment appears to contain commented-out code. |
| test.c:43:1:43:54 | // int myFunction() const noexcept { return myValue; } | This comment appears to contain commented-out code. |
| test.c:45:1:45:18 | // #define MYMACRO | This comment appears to contain commented-out code. |
| test.c:47:1:47:23 | // #include "include.h" | This comment appears to contain commented-out code. |
| test.c:49:1:53:2 | /*\n#ifdef\nvoid myFunction();\n#endif\n*/ | This comment appears to contain commented-out code. |
| test.c:61:1:61:24 | // #if(defined(MYMACRO)) | This comment appears to contain commented-out code. |
| test.c:65:1:65:15 | // #pragma once | This comment appears to contain commented-out code. |
| test.c:67:1:67:17 | // # pragma once | This comment appears to contain commented-out code. |
| test.c:69:1:69:19 | /*#error"myerror"*/ | This comment appears to contain commented-out code. |
| test.c:93:1:97:2 | /*\n#ifdef MYMACRO\n // ...\n#endif // #ifdef MYMACRO\n*/ | This comment appears to contain commented-out code. |
| test.c:108:21:108:43 | // #include "config2.h" | This comment appears to contain commented-out code. |
| test.c:114:16:114:35 | /* #ifdef MYMACRO */ | This comment appears to contain commented-out code. |
| test.c:118:1:118:24 | // commented_out_code(); | This comment appears to contain commented-out code. |
| test.c:121:2:121:25 | // commented_out_code(); | This comment appears to contain commented-out code. |
| test.c:124:1:124:22 | // commented out code; | This comment appears to contain commented-out code. |
| test.c:126:1:129:8 | // some; | This comment appears to contain commented-out code. |
| test.c:131:1:135:8 | // also; | This comment appears to contain commented-out code. |
| test.c:143:1:148:2 | /*\n some;\n commented;\n out;\n code;\n*/ | This comment appears to contain commented-out code. |
| 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. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// GENERATED FILE - DO NOT MODIFY
import codingstandards.cpp.rules.sectionsofcodeshallnotbecommentedout.SectionsOfCodeShallNotBeCommentedOut
Empty file.
Loading