Skip to content

Commit 6f6478b

Browse files
committed
csparser: make the reTrailLoc_ regex stricter
... so that it does not trigger on similar constructions in code snippets contained in comments. The following defecet detected by Pylint on calamari-server-1.3.4-1.el7cp caused a major problem to csparser: Error: PROSPECTOR_WARNING: /opt/calamari/venv/lib/python2.7/site-packages/graphite/thirdparty/pyparsing.py:795:24: W0613[pylint]: Unused argument 's' # 793| return f(f.__call__.__self__, s,l,t) # 794| if numargs == 2: # 795|-> def tmp(s,l,t): # 796| return f(l,t) # 797| elif numargs == 1:
1 parent ba22dde commit 6f6478b

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

csparser.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class LineReader {
3535
LineReader(std::istream &input):
3636
input_(input),
3737
lineNo_(0),
38-
reTrailLoc_("[0-9>]:$"),
38+
reTrailLoc_("^(path:|/).*(:[0-9]+|<.*>):$"),
3939
rePathPref_("^path:"),
4040
reUnkownLoc_("^<unknown>")
4141
{

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ test_csgrep(csgrep "36-csgrep-json" )
146146
test_csgrep(csgrep "37-csgrep-json" )
147147
test_csgrep(csgrep "38-csparser-remediation" )
148148
test_csgrep(csgrep "39-csparser-remediation" )
149+
test_csgrep(csgrep "40-csparser-code-snippet" )
149150
test_csparser(csparser-5.8 00)
150151
test_csparser(csparser-5.8 01)
151152
test_csparser(csparser-5.8 02)

tests/csgrep/40-csparser-code-snippet-args.txt

Whitespace-only changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Error: PROSPECTOR_WARNING:
2+
/opt/calamari/venv/lib/python2.7/site-packages/graphite/thirdparty/pyparsing.py:724:30: W0212[pylint]: Access to a protected member _originalParseMethod of a client class
3+
# 722| else:
4+
# 723| if hasattr(self._parse,"_originalParseMethod"):
5+
# 724|-> self._parse = self._parse._originalParseMethod
6+
# 725| return self
7+
# 726|
8+
9+
Error: PROSPECTOR_WARNING:
10+
/opt/calamari/venv/lib/python2.7/site-packages/graphite/thirdparty/pyparsing.py:795:24: W0613[pylint]: Unused argument 's'
11+
# 793| return f(f.__call__.__self__, s,l,t)
12+
# 794| if numargs == 2:
13+
# 795|-> def tmp(s,l,t):
14+
# 796| return f(l,t)
15+
# 797| elif numargs == 1:
16+
17+
Error: PROSPECTOR_WARNING:
18+
/opt/calamari/venv/lib/python2.7/site-packages/graphite/thirdparty/pyparsing.py:798:24: W0613[pylint]: Unused argument 's'
19+
# 796| return f(l,t)
20+
# 797| elif numargs == 1:
21+
# 798|-> def tmp(s,l,t):
22+
# 799| return f(t)
23+
# 800| else: #~ numargs == 0:
24+
25+
Error: PROSPECTOR_WARNING:
26+
/opt/calamari/venv/lib/python2.7/site-packages/graphite/thirdparty/pyparsing.py:798:26: W0613[pylint]: Unused argument 'l'
27+
# 796| return f(l,t)
28+
# 797| elif numargs == 1:
29+
# 798|-> def tmp(s,l,t):
30+
# 799| return f(t)
31+
# 800| else: #~ numargs == 0:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Error: PROSPECTOR_WARNING:
2+
/opt/calamari/venv/lib/python2.7/site-packages/graphite/thirdparty/pyparsing.py:724:30: W0212[pylint]: Access to a protected member _originalParseMethod of a client class
3+
# 722| else:
4+
# 723| if hasattr(self._parse,"_originalParseMethod"):
5+
# 724|-> self._parse = self._parse._originalParseMethod
6+
# 725| return self
7+
# 726|
8+
9+
Error: PROSPECTOR_WARNING:
10+
/opt/calamari/venv/lib/python2.7/site-packages/graphite/thirdparty/pyparsing.py:795:24: W0613[pylint]: Unused argument 's'
11+
# 793| return f(f.__call__.__self__, s,l,t)
12+
# 794| if numargs == 2:
13+
# 795|-> def tmp(s,l,t):
14+
# 796| return f(l,t)
15+
# 797| elif numargs == 1:
16+
17+
Error: PROSPECTOR_WARNING:
18+
/opt/calamari/venv/lib/python2.7/site-packages/graphite/thirdparty/pyparsing.py:798:24: W0613[pylint]: Unused argument 's'
19+
# 796| return f(l,t)
20+
# 797| elif numargs == 1:
21+
# 798|-> def tmp(s,l,t):
22+
# 799| return f(t)
23+
# 800| else: #~ numargs == 0:
24+
25+
Error: PROSPECTOR_WARNING:
26+
/opt/calamari/venv/lib/python2.7/site-packages/graphite/thirdparty/pyparsing.py:798:26: W0613[pylint]: Unused argument 'l'
27+
# 796| return f(l,t)
28+
# 797| elif numargs == 1:
29+
# 798|-> def tmp(s,l,t):
30+
# 799| return f(t)
31+
# 800| else: #~ numargs == 0:

0 commit comments

Comments
 (0)