Skip to content

Commit 8f77d0e

Browse files
committed
gcc-parser: recognize raw shellcheck format, too
Reported-By: Jan Macku
1 parent 63779a8 commit 8f77d0e

8 files changed

+43
-0
lines changed

gcc-parser.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ class BasicGccParser {
379379
reCppcheck_("^([A-Za-z_]+): (.*)$"),
380380
reClang_("^clang.*$"),
381381
reProspector_(RE_EVENT_PROSPECTOR),
382+
reShellCheckMsg_("^.* \\[SC[0-9]+\\]$"),
382383
reSmatchMsg_("^" RE_FNC_SMATCH ": .*$"),
383384
reTool_("^(.*) <--\\[([^\\]]+)\\]$"),
384385
hasKeyEvent_(false),
@@ -399,6 +400,7 @@ class BasicGccParser {
399400
const boost::regex reCppcheck_;
400401
const boost::regex reClang_;
401402
const boost::regex reProspector_;
403+
const boost::regex reShellCheckMsg_;
402404
const boost::regex reSmatchMsg_;
403405
const boost::regex reTool_;
404406
bool hasKeyEvent_;
@@ -474,6 +476,8 @@ bool BasicGccParser::exportAndReset(Defect *pDef) {
474476
}
475477
else if (boost::regex_match(keyEvt.event, reProspector_))
476478
def.checker = "PROSPECTOR_WARNING";
479+
else if (boost::regex_match(keyEvt.msg, reShellCheckMsg_))
480+
def.checker = "SHELLCHECK_WARNING";
477481
else if (boost::regex_match(keyEvt.msg, reSmatchMsg_))
478482
def.checker = "SMATCH_WARNING";
479483
else

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ test_csdiff(diff-misc 05)
206206
test_csdiff(diff-misc 06)
207207
test_csdiff(diff-misc 07)
208208
test_csdiff(diff-misc 08)
209+
test_csdiff(diff-misc 09-shellcheck-raw)
209210

210211
# cstrans-df-run tests
211212
tests_cstrans_df_run(0001)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Error: SHELLCHECK_WARNING:
2+
./network-scripts/ifdown:77:21: note: Double quote to prevent globbing and word splitting. [SC2086]
3+
4+
Error: SHELLCHECK_WARNING:
5+
./network-scripts/ifdown:77:31: note: Double quote to prevent globbing and word splitting. [SC2086]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Error: SHELLCHECK_WARNING:
2+
./network-scripts/ifdown:77:21: note: Double quote to prevent globbing and word splitting. [SC2086]
3+
4+
Error: SHELLCHECK_WARNING:
5+
./network-scripts/ifdown:77:31: note: Double quote to prevent globbing and word splitting. [SC2086]

tests/diff-misc/09-shellcheck-raw-fix-z.err

Whitespace-only changes.

tests/diff-misc/09-shellcheck-raw-fix.err

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
./network-scripts/ifdown:5:3: note: Not following: /etc/init.d/functions was not specified as input (see shellcheck -x). [SC1091]
2+
./network-scripts/ifdown:7:1: warning: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. [SC2164]
3+
./network-scripts/ifdown:8:3: note: Not following: ./network-functions was not specified as input (see shellcheck -x). [SC1091]
4+
./network-scripts/ifdown:10:24: note: Not following: ../network was not specified as input (see shellcheck -x). [SC1091]
5+
./network-scripts/ifdown:29:33: note: Double quote to prevent globbing and word splitting. [SC2086]
6+
./network-scripts/ifdown:30:39: note: Double quote to prevent globbing and word splitting. [SC2086]
7+
./network-scripts/ifdown:39:14: note: Double quote to prevent globbing and word splitting. [SC2086]
8+
./network-scripts/ifdown:45:50: warning: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. [SC2166]
9+
./network-scripts/ifdown:50:7: warning: _use_nm is referenced but not assigned. [SC2154]
10+
./network-scripts/ifdown:51:21: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. [SC2166]
11+
./network-scripts/ifdown:64:28: note: Double quote to prevent globbing and word splitting. [SC2086]
12+
./network-scripts/ifdown:69:11: note: Double quote to prevent globbing and word splitting. [SC2086]
13+
./network-scripts/ifdown:73:11: note: Double quote to prevent globbing and word splitting. [SC2086]
14+
./network-scripts/ifdown:77:21: note: Double quote to prevent globbing and word splitting. [SC2086]
15+
./network-scripts/ifdown:77:31: note: Double quote to prevent globbing and word splitting. [SC2086]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
./network-scripts/ifdown:5:3: note: Not following: /etc/init.d/functions was not specified as input (see shellcheck -x). [SC1091]
2+
./network-scripts/ifdown:7:1: warning: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. [SC2164]
3+
./network-scripts/ifdown:8:3: note: Not following: ./network-functions was not specified as input (see shellcheck -x). [SC1091]
4+
./network-scripts/ifdown:10:24: note: Not following: ../network was not specified as input (see shellcheck -x). [SC1091]
5+
./network-scripts/ifdown:29:33: note: Double quote to prevent globbing and word splitting. [SC2086]
6+
./network-scripts/ifdown:30:39: note: Double quote to prevent globbing and word splitting. [SC2086]
7+
./network-scripts/ifdown:45:50: warning: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. [SC2166]
8+
./network-scripts/ifdown:50:7: warning: _use_nm is referenced but not assigned. [SC2154]
9+
./network-scripts/ifdown:51:21: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. [SC2166]
10+
./network-scripts/ifdown:69:11: note: Double quote to prevent globbing and word splitting. [SC2086]
11+
./network-scripts/ifdown:73:11: note: Double quote to prevent globbing and word splitting. [SC2086]
12+
./network-scripts/ifdown:77:21: note: Double quote to prevent globbing and word splitting. [SC2086]
13+
./network-scripts/ifdown:77:31: note: Double quote to prevent globbing and word splitting. [SC2086]

0 commit comments

Comments
 (0)