Fix issue with kdev-cppcheck selecting wrong project
ClosedPublic

Authored by kfunk on Mar 11 2016, 7:13 AM.

Details

Summary

When When encountering a file with an issue the program iterates through available projects to try to find which project the file is part of.

As implemented, the last project in project list is selected.

Fix this with a proper test inside loop and exit on success.

Diff Detail

Repository
R61 KDevelop: CppCheck Integration
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
parolanilsson retitled this revision from to Fix issue with kdev-cppcheck selecting wrong project.
parolanilsson updated this object.
parolanilsson edited the test plan for this revision. (Show Details)
parolanilsson added a reviewer: kfunk.
parolanilsson set the repository for this revision to R61 KDevelop: CppCheck Integration.
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptMar 11 2016, 7:13 AM
kfunk edited edge metadata.Mar 11 2016, 7:37 AM

Could you maybe refactor that code altogether? ProjectPath is quite pointless anyway. It's never read in kdev-cppcheck, only ProjectPath + ErrorFile is used.

My idea: Get rid off ProjectPath, just *always* store the absolute path in ErrorFile. IMO we don't even need findProjectForUrl at all. If you do run cppcheck /path/fo/file.cpp (what we do), then the resulting XML always contains the absolute path anyway.

kfunk added a comment.Mar 11 2016, 7:38 AM

And: If you could write a basic unit test for the parser, that would be awesome as well! It's trivial to do, just get a sample cppcheck output, parse that, and check whether the CppcheckParser::problems() returns the right things.

parolanilsson updated this object.
parolanilsson edited edge metadata.

Remove ProjectPath as suggested by kfunk

Add basic testing

  • Remove ProjectPath as suggested by kfunk
  • Update License
kfunk added a comment.Mar 11 2016, 4:40 PM

Nice!

parsers/test_cppcheckparser.cpp
68 ↗(On Diff #2718)

No temporary variables, here and below, just use the values in here.

parsers/test_cppcheckparser.h
25 ↗(On Diff #2718)

Nitpick: Name it TestCppcheckParser

32 ↗(On Diff #2718)

Name it testParser

  • Remove ProjectPath as suggested by kfunk
  • Update License
  • Rename test & method
  • Don't use temporary variables
kfunk accepted this revision.Mar 12 2016, 12:41 AM
kfunk edited edge metadata.

Awesome, thanks! Keep up the good work. Then we can eventually merge kdev-cppcheck into kdevelop.git, finally...

This revision is now accepted and ready to land.Mar 12 2016, 12:41 AM

Pushed your patch, with some minor changes. Thanks!

kfunk commandeered this revision.Mar 12 2016, 12:46 AM
kfunk edited reviewers, added: parolanilsson; removed: kfunk.
This revision now requires review to proceed.Mar 12 2016, 12:46 AM
kfunk abandoned this revision.Mar 12 2016, 12:47 AM

Pushed.

This revision was automatically updated to reflect the committed changes.