-
Couldn't load subscription status.
- Fork 1.5k
Added Hash to plist file names #2898
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
Conversation
This is done in order to support files with the same in diffrent directories. Added simple cli test for --plist-output cmd. Added fix for #8289 an error is generated if the --plist-output folder does not exist.
|
Hello i hope i peformed the pull request correctly. We are using https://github.com/Ericsson/codechecker for our static analyses tool that also includes cppcheck. This works really fine up to the point where a project contains the same file name in several directories. To work around this we added a hash at the end of the generated plist files. Thanks for the good work. |
|
@Falital thanks for the info.. good to know that this plist output is actually used |
cli/cmdlineparser.cpp
Outdated
| return true; | ||
| } | ||
|
|
||
| static bool folderExist(const std::string &path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can move this to lib/path.cpp .. add a function Path::folderExist instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved function to Path module
cli/cmdlineparser.cpp
Outdated
| else if (!endsWith(mSettings->plistOutput,'/')) | ||
| mSettings->plistOutput += '/'; | ||
|
|
||
| printf("mSettings->plistOutput %s\n", mSettings->plistOutput.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This printf is just some debug command I assume that you should remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes debug output i removed it.
This is done in order to support files with the same in diffrent directories. Added simple cli test for --plist-output cmd. Added fix for #8289 an error is generated if the --plist-output folder does not exist.
This is done in order to support files with the same in diffrent directories. Added simple cli test for --plist-output cmd. Added fix for #8289 an error is generated if the --plist-output folder does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits
lib/path.h
Outdated
| * @param path Path to be checked if it is a folder | ||
| * @return true if given path is a folder | ||
| */ | ||
| static bool folderExist(const std::string &path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a fileExists at the bottom so I think it's logical to put this above/below that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found similar functions in FileLister and moved them to Path adapted test etc.
cli/cmdlineparser.cpp
Outdated
| else if (!endsWith(mSettings->plistOutput,'/')) | ||
| mSettings->plistOutput += '/'; | ||
|
|
||
| if ((mSettings->plistOutput != "./") && (!Path::folderExist(mSettings->plistOutput))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The (mSettings->plistOutput != "./") && seems redundant to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed redundant check and also converted path to native so this can also work in windows.
This is done in order to support files with the same in diffrent directories. Added simple cli test for --plist-output cmd. Added fix for #8289 an error is generated if the --plist-output folder does not exist.
This is done in order to support files with the same in diffrent directories. Added simple cli test for --plist-output cmd. Added fix for #8289 an error is generated if the --plist-output folder does not exist.
This is done in order to support files with the same in diffrent directories. Added simple cli test for --plist-output cmd. Added fix for #8289 an error is generated if the --plist-output folder does not exist.
This is done in order to support files with the same in diffrent directories. Added simple cli test for --plist-output cmd. Added fix for #8289 an error is generated if the --plist-output folder does not exist.
| path = Path::fromNativeSeparators(path); | ||
| path = Path::simplifyPath(path); | ||
|
|
||
| if (FileLister::isDirectory(path)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm.. sorry. I think I gave the wrong advice about putting folderExists in Path. It would be preferable to keep the old code in FileLister and reuse FileLister::isDirectory. Sorry I should have realized this from the start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted my changes FileLister:fileExists Windows implimentation was broken i fixed it.
cli/cmdlineparser.cpp
Outdated
| mSettings->plistOutput += '/'; | ||
|
|
||
| if ((mSettings->plistOutput != "./") && (!Path::folderExist(mSettings->plistOutput))) | ||
| std::string plistOutput = Path::toNativeSeparators(mSettings->plistOutput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the scope of this variable can be reduced and it can be const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it cannot it should be used in the FileLister::isDirectory check. Changed it to const.
This is done in order to support files with the same in diffrent directories. Added simple cli test for --plist-output cmd. Added fix for #8289 an error is generated if the --plist-output folder does not exist.
This is done in order to support files with the same in diffrent directories. Added simple cli test for --plist-output cmd. Added fix for #8289 an error is generated if the --plist-output folder does not exist.
|
|
||
| void fileExists() const { | ||
| ASSERT_EQUALS(false, FileLister::fileExists("lib")); | ||
| ASSERT_EQUALS(true, FileLister::fileExists("readme.txt")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this assertion. The testrunner binary is placed in different paths.. we cant expect that there will be a readme.txt in the build output folder.
The previous assertion is fine. If testrunner is placed in cppcheck root path then it checks that fileExists returns false for a existing folder. Otherwise the assertion will check that fileExists returns false for a non-existing path.. that is good also. The problem would be if the build output folder has a file with the name "lib" but we can maybe ignore that problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We check if we are in the correct place during the test setup see line 41 of testfilelister.cpp
I can still remove it but for me it seems like a valid test.
This is done in order to support files with the same in diffrent
directories. Added simple cli test for --plist-output cmd.
Added fix for #8289 an error is generated if the --plist-output
folder does not exist.