Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpplint parser does not recognize any violations from cpplint report #68

Closed
shyingsheng opened this issue Apr 19, 2019 · 12 comments
Closed

Comments

@shyingsheng
Copy link

Hi,

I use Violations Comments to GitLab plugin with cpplint. But the plugin find 0 violations.

cpplint.xml is located directly in the workspace with below content:
17:24:17 src/utility/utility.h:15: Tab found; better to use spaces [whitespace/tab] [1]
17:24:17 src/utility/utility.h:17: Tab found; better to use spaces [whitespace/tab] [1]
17:24:17 src/utility/utility.h:30: Tab found; better to use spaces [whitespace/tab] [1]

below is the ViolationConfig
17:24:18 gitLabUrl: http://gitlab.xxxx.domain
17:24:18 projectId: 33938
17:24:18 mergeRequestIid: 163
17:24:18 apiToken: true
17:24:18 apiTokenCredentialsId: false
17:24:18 ignoreCertificateErrors: true
17:24:18 apiTokenPrivate: true
17:24:18 authMethodHeader: true
17:24:18 createCommentWithAllSingleFileComments: true
17:24:18 createSingleFileComments: false
17:24:18 commentOnlyChangedContent: true
17:24:18 maxNumberOfViolations:99999
17:24:18 minSeverity: INFO
17:24:18 keepOldComments: true
17:24:18 shouldSetWip: true
17:24:18 commentTemplate:
17:24:18 proxyUri:
17:24:18 proxyUser: no
17:24:18 proxyPassword: no
17:24:18 CPPLINT with pattern .*cpplint.xml$
17:24:18 Running Violation Comments To GitLab
17:24:18 Merge request: 163
17:24:18 Workspace: F:\Jenkins\workspace\static_check
17:24:18 Found 0 violations from ViolationConfig [pattern=.*cpplint.xml$, parser=CPPLINT, reporter=CPPLint].

One more thing, I tried Pylint, which can works correctly and can comments successfully to GitLab. So there should be no proxy, connection issue itself.

I googled from the internet, but cannot find any valuable to fix it.
Any idea what the problem might be? Or anything I configured wrong?

@tomasbjerre
Copy link
Owner

There are working example reports here: https://github.com/tomasbjerre/violations-lib/tree/master/src/test/resources/cpplint

It looks like it is the time at the start 17:24:17 that is the problem. How do you create that cpplint.xml file?

@shyingsheng
Copy link
Author

shyingsheng commented Apr 22, 2019

Sorry,I click "Close and comment" button in mistake. So I reopened it.
"cpplint.exe --exclude=src//.rc --exclude=src//.sln src/**/.* > cpplint.xml || exit 0"
I am using the above command to create "cpplint.xml" report. Maybe the problem is related to how to create the result file, so could you please share me the correct command?
BTW, thanks very much for your reply.

@tomasbjerre
Copy link
Owner

I install it like this:
pip install cpplint

Use it like:

$ ~/.local/bin/cpplint test.cpp 
test.cpp:0:  No copyright message found.  You should have a line: "Copyright [year] <Copyright Owner>"  [legal/copyright] [5]
test.cpp:5:  Do not use namespace using-directives.  Use using-declarations instead.  [build/namespaces] [5]
test.cpp:11:  Missing space before ( in while(  [whitespace/parens] [5]
Done processing test.cpp
Total errors found: 3

This command was run at the cpp-file here:
https://github.com/tomasbjerre/violations-test/tree/master/cpp

@shyingsheng
Copy link
Author

Today I had some tries.
If I use cpplint to check one file, everything works well.
cpplint.exe --extensions=cpp,h src/imageeditor/uicontrol/layertext.h 2>cpplint.xml

But if I use cpplint.exe --extensions=cpp,h src/**/*.* 2>cpplint.xml, the problem will happen, Found 0 violations from ViolationConfig [pattern=.*cpplint.xml$, parser=CPPLINT, reporter=CPPLint].
Do you know how to check all the source code from a folder, including all the subfolders?

@tomasbjerre
Copy link
Owner

If I run that I get the same result as I previously posted:

16:35 $ ~/.local/bin/cpplint --extensions=cpp,h **/*.* 
Ignoring build/flake8_2.txt; not a valid file name (cpp, h)
Done processing build/flake8_2.txt
Ignoring build/googleErrorProne.log; not a valid file name (cpp, h)
Done processing build/googleErrorProne.log
cpp/test.cpp:0:  No copyright message found.  You should have a line: "Copyright [year] <Copyright Owner>"  [legal/copyright] [5]
cpp/test.cpp:5:  Do not use namespace using-directives.  Use using-declarations instead.  [build/namespaces] [5]
cpp/test.cpp:11:  Missing space before ( in while(  [whitespace/parens] [5]
Done processing cpp/test.cpp
Ignoring perl/example.pl; not a valid file name (cpp, h)
Done processing perl/example.pl
Ignoring web/css-file2.css; not a valid file name (cpp, h)
Done processing web/css-file2.css
Ignoring web/css-file.css; not a valid file name (cpp, h)
Done processing web/css-file.css
Ignoring web/js-file2.js; not a valid file name (cpp, h)
Done processing web/js-file2.js
Ignoring web/js-file.js; not a valid file name (cpp, h)
Done processing web/js-file.js
Ignoring xml/myxml.xml; not a valid file name (cpp, h)
Done processing xml/myxml.xml
Ignoring xml/other.xml; not a valid file name (cpp, h)
Done processing xml/other.xml
Total errors found: 3

tomasbjerre added a commit that referenced this issue Apr 23, 2019
tomasbjerre added a commit that referenced this issue Apr 23, 2019
@shyingsheng
Copy link
Author

11:08:09 Done processing src/utility/basictypes.h
11:08:09 Done processing src/utility/dllmain.cpp
11:08:09 Done processing src/utility/errorcode.h
11:08:09 Done processing src/utility/get_svn_log.py
11:08:09 Done processing src/utility/rand_util.cpp
11:08:09 Done processing src/utility/rand_util.h
11:08:09 Done processing src/utility/resource.h
11:08:09 Done processing src/utility/stdafx.cpp
11:08:09 Done processing src/utility/stdafx.h
11:08:09 Done processing src/utility/targetver.h
11:08:09 Done processing src/utility/utility.def
11:08:09 Done processing src/utility/utility.h
11:08:09 Total errors found: 36633

Here is my report, seems there is no problem on create cpplint.xml.
But it cannot be recognized by "Violation Comments to GitLab"

11:08:10 gitLabUrl: http://gitlab.xxxxx.domain
11:08:10 projectId: 33938
11:08:10 mergeRequestIid: 191
11:08:10 apiToken: true
11:08:10 apiTokenCredentialsId: false
11:08:10 ignoreCertificateErrors: true
11:08:10 apiTokenPrivate: true
11:08:10 authMethodHeader: true
11:08:10 createCommentWithAllSingleFileComments: true
11:08:10 createSingleFileComments: false
11:08:10 commentOnlyChangedContent: true
11:08:10 maxNumberOfViolations:99999
11:08:10 minSeverity: INFO
11:08:10 keepOldComments: true
11:08:10 shouldSetWip: false
11:08:10 commentTemplate: 
11:08:10 proxyUri: 
11:08:10 proxyUser: no
11:08:10 proxyPassword: no
11:08:10 CPPLINT with pattern .*cpplint\.xml$
11:08:10 Running Violation Comments To GitLab
11:08:10 Merge request: 191
11:08:10 Workspace: F:\Jenkins\workspace\static_check
11:08:10 Found 0 violations from ViolationConfig [pattern=.*cpplint\.xml$, parser=CPPLINT, reporter=CPPLint].

@tomasbjerre
Copy link
Owner

Perhaps you can package the cpplint.xml in a file, perhaps a zip-file, and attach it.

That should ensure I am testing with your exact file.

@shyingsheng
Copy link
Author

cpplint.zip
Thanks for your quick reply. I attached the file.

@shyingsheng
Copy link
Author

cpplint_one.zip
This file only cpplint check one file, and can work well.

tomasbjerre added a commit that referenced this issue Apr 24, 2019
@tomasbjerre
Copy link
Owner

Found it!
Lines like this was the problem: src/common/CustomTip.cpp:None: src/common/CustomTip.cpp should include its header file src/common/CustomTip.h [build/include] [5].
Parsing failed when line was None.

Will release it soon as possible.

@tomasbjerre
Copy link
Owner

Corrected in 2.25 of Violation Comments to Gitlab Plugin. Open issue if still not working.

@shyingsheng
Copy link
Author

Thanks so much for your great help.
Now everything works very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants