Skip to content

Commit 76ba8d9

Browse files
authored
(Chore): Fix repo tests (#1027)
Additional cleanup as follow-up to #1032. Mostly aligning snapshots to match the test versions for cleanliness. Other notes: - Semgrep problem with no issues being reported
1 parent 4b79374 commit 76ba8d9

14 files changed

+296
-554
lines changed

linters/cfnlint/test_data/cfnlint_v1.35.3_basic.check.shot renamed to linters/cfnlint/test_data/cfnlint_v1.35.1_basic.check.shot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
// trunk-upgrade-validation:RELEASE
23

34
exports[`Testing linter cfnlint test basic 1`] = `
45
{
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
// trunk-upgrade-validation:RELEASE
3+
4+
exports[`Testing linter pmd test CUSTOM 1`] = `
5+
{
6+
"issues": [
7+
{
8+
"code": "ApexDoc",
9+
"column": "8",
10+
"file": "test_data/apex.in.cls",
11+
"issueClass": "ISSUE_CLASS_EXISTING",
12+
"level": "LEVEL_MEDIUM",
13+
"line": "1",
14+
"linter": "pmd",
15+
"message": "Missing ApexDoc comment",
16+
"ranges": [
17+
{
18+
"filePath": "test_data/apex.in.cls",
19+
"length": "69",
20+
"offset": "7",
21+
},
22+
],
23+
"targetType": "apex",
24+
},
25+
{
26+
"code": "AvoidGlobalModifier",
27+
"column": "8",
28+
"file": "test_data/apex.in.cls",
29+
"issueClass": "ISSUE_CLASS_EXISTING",
30+
"level": "LEVEL_MEDIUM",
31+
"line": "1",
32+
"linter": "pmd",
33+
"message": "Avoid using global modifier",
34+
"ranges": [
35+
{
36+
"filePath": "test_data/apex.in.cls",
37+
"length": "69",
38+
"offset": "7",
39+
},
40+
],
41+
"targetType": "apex",
42+
},
43+
{
44+
"code": "ApexDoc",
45+
"column": "8",
46+
"file": "test_data/apex.in.cls",
47+
"issueClass": "ISSUE_CLASS_EXISTING",
48+
"level": "LEVEL_MEDIUM",
49+
"line": "2",
50+
"linter": "pmd",
51+
"message": "Missing ApexDoc comment",
52+
"ranges": [
53+
{
54+
"filePath": "test_data/apex.in.cls",
55+
"length": "41",
56+
"offset": "33",
57+
},
58+
],
59+
"targetType": "apex",
60+
},
61+
{
62+
"code": "NoPackage",
63+
"column": "1",
64+
"file": "test_data/hello.in.java",
65+
"issueClass": "ISSUE_CLASS_EXISTING",
66+
"level": "LEVEL_MEDIUM",
67+
"line": "3",
68+
"linter": "pmd",
69+
"message": "All classes, interfaces, enums and annotations must belong to a named package",
70+
"ranges": [
71+
{
72+
"filePath": "test_data/hello.in.java",
73+
"length": "5",
74+
"offset": "23",
75+
},
76+
],
77+
"targetType": "java",
78+
},
79+
{
80+
"code": "UseUtilityClass",
81+
"column": "1",
82+
"file": "test_data/hello.in.java",
83+
"issueClass": "ISSUE_CLASS_EXISTING",
84+
"level": "LEVEL_MEDIUM",
85+
"line": "3",
86+
"linter": "pmd",
87+
"message": "This utility class has a non-private constructor",
88+
"ranges": [
89+
{
90+
"filePath": "test_data/hello.in.java",
91+
"length": "5",
92+
"offset": "23",
93+
},
94+
],
95+
"targetType": "java",
96+
},
97+
],
98+
"lintActions": [
99+
{
100+
"command": "lint-apex",
101+
"fileGroupName": "apex",
102+
"linter": "pmd",
103+
"paths": [
104+
"test_data/apex.in.cls",
105+
],
106+
"verb": "TRUNK_VERB_CHECK",
107+
},
108+
{
109+
"command": "lint-apex",
110+
"fileGroupName": "apex",
111+
"linter": "pmd",
112+
"paths": [
113+
"test_data/apex.in.cls",
114+
],
115+
"upstream": true,
116+
"verb": "TRUNK_VERB_CHECK",
117+
},
118+
{
119+
"command": "lint-java",
120+
"fileGroupName": "java",
121+
"linter": "pmd",
122+
"paths": [
123+
"test_data/hello.in.java",
124+
],
125+
"verb": "TRUNK_VERB_CHECK",
126+
},
127+
{
128+
"command": "lint-java",
129+
"fileGroupName": "java",
130+
"linter": "pmd",
131+
"paths": [
132+
"test_data/hello.in.java",
133+
],
134+
"upstream": true,
135+
"verb": "TRUNK_VERB_CHECK",
136+
},
137+
],
138+
"taskFailures": [],
139+
"unformattedFiles": [],
140+
}
141+
`;

linters/semgrep/plugin.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ lint:
3434
environment:
3535
- name: PATH
3636
list: ["${env.PATH}"]
37-
known_good_version: 1.122.0
38-
known_bad_versions: [1.5.1, 1.117.0] # Does not work on MacOS
37+
known_good_version: 1.33.2
38+
known_bad_versions: [1.5.1] # Does not work on MacOS
3939
version_command:
4040
parse_regex: ${semver}
4141
run: semgrep --version

linters/semgrep/semgrep.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
import { customLinterCheckTest } from "tests";
2+
import { type TrunkLintDriver } from "tests/driver";
23
import { skipOS, TEST_DATA } from "tests/utils";
34

5+
// NOTE(Tyler): As of semgrep 1.117.0 the first (and only the first) semgrep run may end up excluding the --include paths
6+
const preCheck = (driver: TrunkLintDriver) => {
7+
const trunkYamlPath = ".trunk/trunk.yaml";
8+
const currentContents = driver.readFile(trunkYamlPath);
9+
const lintRegex = /\nlint:/;
10+
const newContents = currentContents.replace(
11+
lintRegex,
12+
`
13+
lint:
14+
definitions:
15+
- name: semgrep
16+
commands:
17+
- name: check
18+
run: semgrep --config=auto --sarif --output=\${tmpfile} --include=* --include=\${target}
19+
20+
`,
21+
);
22+
driver.writeFile(trunkYamlPath, newContents);
23+
};
24+
425
// Note semgrep runs can take a while since they require downloading rulesets each time.
526
customLinterCheckTest({
627
linterName: "semgrep",
28+
preCheck,
729
args: `${TEST_DATA} --cache=false`,
830
skipTestIf: skipOS(["win32"]),
931
});

linters/semgrep/test_data/semgrep_v1.122.0_CUSTOM.check.shot

Lines changed: 0 additions & 125 deletions
This file was deleted.

linters/sourcery/sourcery.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { customLinterCheckTest } from "tests";
44
import { TrunkLintDriver } from "tests/driver";
55
import { REPO_ROOT, skipCPUOS, TEST_DATA } from "tests/utils";
66

7-
// // You must login in order to use sourcery
7+
// You must login in order to use sourcery
88
const preCheck = (driver: TrunkLintDriver) => {
99
driver.moveFile(path.join(TEST_DATA, "_plugin.yaml"), path.join(TEST_DATA, "plugin.yaml"));
1010

linters/sourcery/test_data/sourcery_v1.2.0_CUSTOM.check.shot

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)