Skip to content

Commit 13e6f04

Browse files
committed
parser-cov: treat <unknown>: as empty file name
The JSON-based output formats do not have problems with empty strings. Related: https://issues.redhat.com/browse/OSH-496
1 parent 52465d9 commit 13e6f04

File tree

5 files changed

+2281
-7
lines changed

5 files changed

+2281
-7
lines changed

src/lib/parser-cov.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,19 @@ EToken ErrFileLexer::readNext()
184184
return T_UNKNOWN;
185185
}
186186

187-
// read file name, event, and msg
188-
evt_.fileName = sm[/* file */ 1];
189-
evt_.event = sm[/* event */ 4];
190-
evt_.msg = sm[/* msg */ 5];
187+
// read file name
188+
evt_.fileName = sm[/* file */ 1];
189+
if (evt_.fileName == "<unknown>")
190+
evt_.fileName.clear();
191191

192-
// parse line number
192+
// parse line/col
193193
evt_.line = parseInt(sm[/* line */ 2]);
194-
195-
// parse column number
196194
evt_.column = parseInt(sm[/* col */ 3]);
197195

196+
// read event and msg
197+
evt_.event = sm[/* event */ 4];
198+
evt_.msg = sm[/* msg */ 5];
199+
198200
return T_EVENT;
199201
}
200202

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--mode=json
Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
Error: SHELLCHECK_WARNING (CWE-252):
2+
./contrib/guide/get_started/00-cleanup.sh:6:1: warning[SC2164]: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
3+
4+
Error: SHELLCHECK_WARNING (CWE-277):
5+
./contrib/guide/get_started/12-datadir-create.sh:4:7: warning[SC2174]: When used with -p, -m only applies to the deepest directory.
6+
7+
Error: SHELLCHECK_WARNING:
8+
./contrib/scripts/resetgnome:14:13: note[SC2006]: Use $(...) notation instead of legacy backticked `...`.
9+
10+
Error: SHELLCHECK_WARNING:
11+
./contrib/scripts/resetgnome:15:25: note[SC2086]: Double quote to prevent globbing and word splitting.
12+
13+
Error: SHELLCHECK_WARNING:
14+
./contrib/scripts/resetgnome:17:10: note[SC2006]: Use $(...) notation instead of legacy backticked `...`.
15+
16+
Error: SHELLCHECK_WARNING:
17+
./contrib/scripts/resetgnome:18:14: note[SC2086]: Double quote to prevent globbing and word splitting.
18+
19+
Error: SHELLCHECK_WARNING:
20+
./contrib/scripts/resetgnome:20:7: note[SC2086]: Double quote to prevent globbing and word splitting.
21+
22+
Error: SHELLCHECK_WARNING:
23+
./contrib/scripts/resetgnome:20:44: note[SC2086]: Double quote to prevent globbing and word splitting.
24+
25+
Error: SHELLCHECK_WARNING:
26+
./contrib/scripts/resetgnome:20:57: note[SC2086]: Double quote to prevent globbing and word splitting.
27+
28+
Error: SHELLCHECK_WARNING (CWE-398):
29+
./contrib/template/.bash_profile:2:25: warning[SC1090]: ShellCheck can't follow non-constant source. Use a directive to specify location.
30+
31+
Error: SHELLCHECK_WARNING:
32+
./contrib/template/.bashrc:21:3: note[SC1091]: Not following: /soft/rko-modules/tcl/init/bash was not specified as input (see shellcheck -x).
33+
34+
Error: SHELLCHECK_WARNING:
35+
./doc/example/compiler-etc-dependencies/example-sessions/bar-defaults.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
36+
37+
Error: SHELLCHECK_WARNING:
38+
./doc/example/compiler-etc-dependencies/example-sessions/bar-loads.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
39+
40+
Error: SHELLCHECK_WARNING:
41+
./doc/example/compiler-etc-dependencies/example-sessions/bar-switch.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
42+
43+
Error: SHELLCHECK_WARNING:
44+
./doc/example/compiler-etc-dependencies/example-sessions/common_code.sh:6:6: note[SC2268]: Avoid x-prefix in comparisons as it no longer serves a purpose.
45+
46+
Error: SHELLCHECK_WARNING:
47+
./doc/example/compiler-etc-dependencies/example-sessions/common_code.sh:11:6: note[SC2268]: Avoid x-prefix in comparisons as it no longer serves a purpose.
48+
49+
Error: SHELLCHECK_WARNING (CWE-569):
50+
./doc/example/compiler-etc-dependencies/example-sessions/common_code.sh:34:7: warning[SC2124]: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
51+
52+
Error: SHELLCHECK_WARNING (CWE-563):
53+
./doc/example/compiler-etc-dependencies/example-sessions/common_code.sh:45:2: warning[SC2034]: GCCGNU appears unused. Verify use (or export if used externally).
54+
55+
Error: SHELLCHECK_WARNING (CWE-563):
56+
./doc/example/compiler-etc-dependencies/example-sessions/common_code.sh:60:3: warning[SC2034]: AUTOFLAG appears unused. Verify use (or export if used externally).
57+
58+
Error: SHELLCHECK_WARNING:
59+
./doc/example/compiler-etc-dependencies/example-sessions/foo-avail1.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
60+
61+
Error: SHELLCHECK_WARNING:
62+
./doc/example/compiler-etc-dependencies/example-sessions/foo-avail2.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
63+
64+
Error: SHELLCHECK_WARNING:
65+
./doc/example/compiler-etc-dependencies/example-sessions/foo-defaults.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
66+
67+
Error: SHELLCHECK_WARNING:
68+
./doc/example/compiler-etc-dependencies/example-sessions/foo-loads.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
69+
70+
Error: SHELLCHECK_WARNING:
71+
./doc/example/compiler-etc-dependencies/example-sessions/foo-switch.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
72+
73+
Error: SHELLCHECK_WARNING:
74+
./doc/example/compiler-etc-dependencies/example-sessions/modavail.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
75+
76+
Error: SHELLCHECK_WARNING:
77+
./doc/example/compiler-etc-dependencies/example-sessions/modversion.sh:3:8: note[SC2086]: Double quote to prevent globbing and word splitting.
78+
79+
Error: SHELLCHECK_WARNING (CWE-569):
80+
./doc/example/compiler-etc-dependencies/example-sessions/ompi-switch.sh.m431:4:7: warning[SC2124]: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
81+
82+
Error: SHELLCHECK_WARNING (CWE-571):
83+
./doc/example/source-script-in-modulefile/bar-2.1/bar-setup.sh:2:8: warning[SC2155]: Declare and assign separately to avoid masking return values.
84+
85+
Error: SHELLCHECK_WARNING (CWE-670):
86+
./doc/example/source-script-in-modulefile/bar-2.1/bar-setup.sh:2:23: warning[SC2128]: Expanding an array without an index only gives the first element.
87+
88+
Error: SHELLCHECK_WARNING (CWE-571):
89+
./doc/example/source-script-in-modulefile/foo-1.2/foo-setup.sh:3:8: warning[SC2155]: Declare and assign separately to avoid masking return values.
90+
91+
Error: SHELLCHECK_WARNING (CWE-670):
92+
./doc/example/source-script-in-modulefile/foo-1.2/foo-setup.sh:3:23: warning[SC2128]: Expanding an array without an index only gives the first element.
93+
94+
Error: SHELLCHECK_WARNING (CWE-477):
95+
./init/bash.in:27:47: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
96+
97+
Error: SHELLCHECK_WARNING (CWE-569):
98+
./init/bash.in:32:31: warning[SC2089]: Quotes/backslashes will be treated literally. Use an array.
99+
100+
Error: SHELLCHECK_WARNING (CWE-569):
101+
./init/bash.in:41:9: warning[SC2090]: Quotes/backslashes in this variable will not be respected.
102+
103+
Error: SHELLCHECK_WARNING (CWE-569):
104+
./init/bash_completion.in:10:15: error[SC1035]: You are missing a required space here.
105+
106+
Error: SHELLCHECK_WARNING (CWE-477):
107+
./init/bash_completion.in:10:27: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
108+
109+
Error: SHELLCHECK_WARNING (CWE-477):
110+
./init/bash_completion.in:22:20: warning[SC2166]: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
111+
112+
Error: SHELLCHECK_WARNING (CWE-140):
113+
./init/bash_completion.in:52:25: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
114+
115+
Error: SHELLCHECK_WARNING (CWE-140):
116+
./init/bash_completion.in:68:27: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
117+
118+
Error: SHELLCHECK_WARNING (CWE-140):
119+
./init/bash_completion.in:69:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
120+
121+
Error: SHELLCHECK_WARNING (CWE-140):
122+
./init/bash_completion.in:70:25: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
123+
124+
Error: SHELLCHECK_WARNING (CWE-140):
125+
./init/bash_completion.in:72:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
126+
127+
Error: SHELLCHECK_WARNING (CWE-140):
128+
./init/bash_completion.in:74:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
129+
130+
Error: SHELLCHECK_WARNING (CWE-140):
131+
./init/bash_completion.in:75:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
132+
133+
Error: SHELLCHECK_WARNING (CWE-140):
134+
./init/bash_completion.in:76:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
135+
136+
Error: SHELLCHECK_WARNING (CWE-140):
137+
./init/bash_completion.in:89:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
138+
139+
Error: SHELLCHECK_WARNING (CWE-140):
140+
./init/bash_completion.in:90:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
141+
142+
Error: SHELLCHECK_WARNING (CWE-140):
143+
./init/bash_completion.in:94:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
144+
145+
Error: SHELLCHECK_WARNING (CWE-140):
146+
./init/bash_completion.in:96:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
147+
148+
Error: SHELLCHECK_WARNING (CWE-398):
149+
./init/bash_completion.in:105:21: warning[SC2178]: Variable was used as an array but is now assigned a string.
150+
151+
Error: SHELLCHECK_WARNING (CWE-398):
152+
./init/bash_completion.in:106:21: warning[SC2178]: Variable was used as an array but is now assigned a string.
153+
154+
Error: SHELLCHECK_WARNING (CWE-140):
155+
./init/bash_completion.in:108:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
156+
157+
Error: SHELLCHECK_WARNING (CWE-140):
158+
./init/bash_completion.in:109:33: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
159+
160+
Error: SHELLCHECK_WARNING (CWE-829):
161+
./init/bash_completion.in:116:4: warning[SC2091]: Remove surrounding $() to avoid executing output (or use eval if intentional).
162+
163+
Error: SHELLCHECK_WARNING (CWE-563):
164+
./init/bash_completion.in:118:34: warning[SC2034]: cmds appears unused. Verify use (or export if used externally).
165+
166+
Error: SHELLCHECK_WARNING (CWE-563):
167+
./init/bash_completion.in:118:39: warning[SC2034]: opts appears unused. Verify use (or export if used externally).
168+
169+
Error: SHELLCHECK_WARNING (CWE-140):
170+
./init/bash_completion.in:127:31: warning[SC2207]: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
171+
172+
Error: SHELLCHECK_WARNING (CWE-398):
173+
./init/bash_completion.in:164:25: warning[SC2178]: Variable was used as an array but is now assigned a string.
174+
175+
Error: SHELLCHECK_WARNING (CWE-398):
176+
./init/bash_completion.in:165:25: warning[SC2178]: Variable was used as an array but is now assigned a string.
177+
178+
Error: SHELLCHECK_WARNING (CWE-477):
179+
./init/ksh.in:27:47: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
180+
181+
Error: SHELLCHECK_WARNING (CWE-569):
182+
./init/ksh.in:32:31: warning[SC2089]: Quotes/backslashes will be treated literally. Use an array.
183+
184+
Error: SHELLCHECK_WARNING (CWE-569):
185+
./init/ksh.in:41:9: warning[SC2090]: Quotes/backslashes in this variable will not be respected.
186+
187+
Error: SHELLCHECK_WARNING (CWE-156):
188+
./init/profile.sh.in:10:23: warning[SC2046]: Quote this to prevent word splitting.
189+
190+
Error: SHELLCHECK_WARNING (CWE-398):
191+
./init/profile.sh.in:14:6: warning[SC1090]: ShellCheck can't follow non-constant source. Use a directive to specify location.
192+
193+
Error: SHELLCHECK_WARNING:
194+
./init/profile.sh.in:16:6: note[SC1091]: Not following: @initdir@/sh was not specified as input (see shellcheck -x).
195+
196+
Error: SHELLCHECK_WARNING (CWE-477):
197+
./init/sh.in:27:47: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
198+
199+
Error: SHELLCHECK_WARNING (CWE-569):
200+
./init/sh.in:32:31: warning[SC2089]: Quotes/backslashes will be treated literally. Rewrite using set/"$@" or functions.
201+
202+
Error: SHELLCHECK_WARNING (CWE-569):
203+
./init/sh.in:41:11: warning[SC2090]: Quotes/backslashes in this variable will not be respected.
204+
205+
Error: SHELLCHECK_WARNING:
206+
./init/sh.in:59:14: warning[SC3045]: In POSIX sh, export -f is undefined.
207+
208+
Error: SHELLCHECK_WARNING:
209+
./init/sh.in:60:14: warning[SC3045]: In POSIX sh, export -f is undefined.
210+
211+
Error: SHELLCHECK_WARNING:
212+
./init/sh.in:61:20: warning[SC3045]: In POSIX sh, type -t is undefined.
213+
214+
Error: SHELLCHECK_WARNING:
215+
./init/sh.in:62:17: warning[SC3045]: In POSIX sh, export -f is undefined.
216+
217+
Error: SHELLCHECK_WARNING:
218+
./script/add.modules.in:22:9: note[SC2016]: Expressions don't expand in single quotes, use double quotes for that.
219+
220+
Error: SHELLCHECK_WARNING:
221+
./script/add.modules.in:61:1: note[SC2162]: read without -r will mangle backslashes.
222+
223+
Error: SHELLCHECK_WARNING:
224+
./script/add.modules.in:63:6: note[SC2268]: Avoid x-prefix in comparisons as it no longer serves a purpose.
225+
226+
Error: SHELLCHECK_WARNING:
227+
./script/add.modules.in:102:9: note[SC2268]: Avoid x-prefix in comparisons as it no longer serves a purpose.
228+
229+
Error: SHELLCHECK_WARNING:
230+
./script/add.modules.in:107:10: note[SC2268]: Avoid x-prefix in comparisons as it no longer serves a purpose.
231+
232+
Error: SHELLCHECK_WARNING:
233+
./script/add.modules.in:127:12: note[SC2268]: Avoid x-prefix in comparisons as it no longer serves a purpose.
234+
235+
Error: SHELLCHECK_WARNING:
236+
./script/add.modules.in:148:11: note[SC2268]: Avoid x-prefix in comparisons as it no longer serves a purpose.
237+
238+
Error: SHELLCHECK_WARNING:
239+
./script/add.modules.in:153:10: note[SC2268]: Avoid x-prefix in comparisons as it no longer serves a purpose.
240+
241+
Error: SHELLCHECK_WARNING:
242+
./script/add.modules.in:164:12: note[SC2268]: Avoid x-prefix in comparisons as it no longer serves a purpose.
243+
244+
Error: SHELLCHECK_WARNING (CWE-252):
245+
./script/add.modules.in:190:1: warning[SC2164]: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
246+
247+
Error: SHELLCHECK_WARNING (CWE-156):
248+
./script/add.modules.in:199:7: warning[SC2046]: Quote this to prevent word splitting.
249+
250+
Error: SHELLCHECK_WARNING:
251+
./script/add.modules.in:199:7: note[SC2006]: Use $(...) notation instead of legacy backticked `...`.
252+
253+
Error: SHELLCHECK_WARNING:
254+
./script/commit-msg:49:6: note[SC2181]: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
255+
256+
Error: SHELLCHECK_WARNING (CWE-477):
257+
./script/envml:83:15: warning[SC2166]: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
258+
259+
Error: SHELLCHECK_WARNING (CWE-477):
260+
./script/envml:83:31: warning[SC2166]: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
261+
262+
Error: SHELLCHECK_WARNING (CWE-88):
263+
./script/envml:89:12: error[SC2068]: Double quote array expansions to avoid re-splitting elements.
264+
265+
Error: SHELLCHECK_WARNING (CWE-563):
266+
./script/envml:127:17: warning[SC2034]: module appears unused. Verify use (or export if used externally).
267+
268+
Error: SHELLCHECK_WARNING (CWE-156):
269+
./script/mkroot:75:37: warning[SC2046]: Quote this to prevent word splitting.
270+
271+
Error: SHELLCHECK_WARNING:
272+
./script/mkroot:75:37: note[SC2006]: Use $(...) notation instead of legacy backticked `...`.
273+
274+
Error: SHELLCHECK_WARNING:
275+
./script/mkroot:75:38: note[SC2012]: Use find instead of ls to better handle non-alphanumeric filenames.
276+
277+
Error: SHELLCHECK_WARNING (CWE-156):
278+
./script/mkroot:77:38: warning[SC2046]: Quote this to prevent word splitting.
279+
280+
Error: SHELLCHECK_WARNING:
281+
./script/mkroot:77:38: note[SC2006]: Use $(...) notation instead of legacy backticked `...`.
282+
283+
Error: SHELLCHECK_WARNING:
284+
./script/mkroot:77:39: note[SC2012]: Use find instead of ls to better handle non-alphanumeric filenames.
285+
286+
Error: SHELLCHECK_WARNING (CWE-156):
287+
./script/mkroot:88:30: warning[SC2046]: Quote this to prevent word splitting.
288+
289+
Error: SHELLCHECK_WARNING:
290+
./script/mkroot:88:30: note[SC2006]: Use $(...) notation instead of legacy backticked `...`.
291+
292+
Error: SHELLCHECK_WARNING:
293+
./script/mkroot:88:31: note[SC2012]: Use find instead of ls to better handle non-alphanumeric filenames.
294+
295+
Error: SHELLCHECK_WARNING:
296+
./script/mt:35:6: note[SC2181]: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
297+
298+
Error: SHELLCHECK_WARNING (CWE-456):
299+
./script/mt:38:4: warning[SC2209]: Use var=$(command) to assign output (or quote to assign string).
300+
301+
Error: SHELLCHECK_WARNING (CWE-456):
302+
./script/mt:42:1: warning[SC2209]: Use var=$(command) to assign output (or quote to assign string).
303+
304+
Error: SHELLCHECK_WARNING (CWE-88):
305+
./script/mt:63:13: error[SC2068]: Double quote array expansions to avoid re-splitting elements.
306+
307+
Error: SHELLCHECK_WARNING (CWE-88):
308+
./script/mt:63:34: error[SC2068]: Double quote array expansions to avoid re-splitting elements.
309+
310+
Error: SHELLCHECK_WARNING (CWE-140):
311+
./script/mt:70:32: warning[SC2206]: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
312+
313+
Error: SHELLCHECK_WARNING (CWE-140):
314+
./script/mt:70:43: warning[SC2206]: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
315+
316+
Error: SHELLCHECK_WARNING (CWE-140):
317+
./script/mt:72:32: warning[SC2206]: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
318+
319+
Error: SHELLCHECK_WARNING (CWE-140):
320+
./script/mt:72:43: warning[SC2206]: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
321+
322+
Error: SHELLCHECK_WARNING:
323+
./script/mt:83:45: warning[SC2076]: Remove quotes from right-hand side of =~ to match as a regex rather than literally.
324+
325+
Error: SHELLCHECK_WARNING (CWE-140):
326+
./script/mt:84:26: warning[SC2206]: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
327+
328+
Error: SHELLCHECK_WARNING:
329+
./script/pre-commit:45:6: note[SC2181]: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
330+
331+
Error: SHELLCHECK_WARNING:
332+
./script/pre-commit:47:9: note[SC2181]: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
333+
334+
Error: SHELLCHECK_WARNING:
335+
./script/pre-commit:56:6: note[SC2181]: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
336+
337+
Error: SHELLCHECK_WARNING:
338+
./script/pre-commit:80:6: note[SC2181]: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
339+
340+
Error: SHELLCHECK_WARNING:
341+
<unknown>: error[too-many]: 115 occurrences of note[SC2086] exceeded the specified limit 16
342+
./doc/example/compiler-etc-dependencies/example-sessions/ompi-defaults.sh:3:8: note: 99 occurrences of note[SC2086] were discarded because of this
343+
344+
Error: SHELLCHECK_WARNING (CWE-140):
345+
<unknown>: error[too-many]: 29 occurrences of warning[SC2207] exceeded the specified limit 16
346+
./init/bash_completion.in:128:37: note: 13 occurrences of warning[SC2207] were discarded because of this

0 commit comments

Comments
 (0)