Skip to content

Check specific Visual Studio configurations#2503

Merged
danmar merged 14 commits into
cppcheck-opensource:masterfrom
fuzzelhjb:check_specific_VS_config
Jan 31, 2020
Merged

Check specific Visual Studio configurations#2503
danmar merged 14 commits into
cppcheck-opensource:masterfrom
fuzzelhjb:check_specific_VS_config

Conversation

@fuzzelhjb

Copy link
Copy Markdown
Contributor

Add support to check against selected Visual Studio configurations in a cppcheck project file.
The cppcheck project file format was extended with a potential list of VS configurations. On importing a Visual Studio solution or project file from a .cppcheck file only those configurations that match the ones in the list are checked.

@danmar danmar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. this is probably 95% good.

I think I need to build and test it..

Comment thread lib/importproject.h Outdated
const char MaxCtuDepthElementName[] = "max-ctu-depth";
const char CheckUnknownFunctionReturn[] = "check-unknown-function-return-values";
const char Name[] = "name";
const char VSConfigurationElementName[] = "vsconfigurations";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable names are fine. But the xml elements normally use "-" to separate names. So maybe "vs-configurations" and "config" are good names.

@fuzzelhjb

fuzzelhjb commented Jan 25, 2020 via email

Copy link
Copy Markdown
Contributor Author

@danmar

danmar commented Jan 26, 2020

Copy link
Copy Markdown
Collaborator

I assume this technically is working but maybe the UI can be tweaked.

For me it is confusing what happens if I both click on "Analyze all visual studio solutions" and write something in the edit box. If "analyze all visual studio solutions" is checked I suggest that the editbox is disabled.

Somehow it would be good if the available configurations is listed. Do you want to be able to analyze several configurations but not all? If you are fine analyzing 1 configuration then a combobox could be used.

@fuzzelhjb

Copy link
Copy Markdown
Contributor Author

I changed the behavior as suggested. If you select "Analyze all visual studio configurations" then the textbox is disabled. I think it would be nice to define multiple configurations so a semicolon separated list would make more sense here.
Afaik the UI doesn't read the actual vcxproj/sln file so there is no way to list all configurations in the textbox.

@danmar

danmar commented Jan 28, 2020

Copy link
Copy Markdown
Collaborator

Afaik the UI doesn't read the actual vcxproj/sln file so there is no way to list all configurations in the textbox.

That is true. But that would be pretty simple to add.

#include "importproject.h"

Then create a utility function like:

static QStringList getProjectConfigs(QString fileName) {
    QStringList ret;
    ImportProject importer;
    importer.load(fileName.toStdString());
    for (const std::string &cfg : importer.getConfigs())
        ret << QString::fromStdString(cfg);
    return ret;
}

And then in ImportProject we need a function getConfigs()... I am sure you can put that together.

I have the feeling that it's more difficult to tweak the GUI. In my head I would like that the user could select configurations somehow. It would be very easy to miswrite a configuration if they are not listed or checked at all. What happens then, Cppcheck will not write any warning? And can't the configurations contain semicolon also?

@danmar

danmar commented Jan 28, 2020

Copy link
Copy Markdown
Collaborator

I am grateful that you are working on this. It will be a really cool enhancement!

@fuzzelhjb

Copy link
Copy Markdown
Contributor Author

You're welcome :) I updated the importer to automatically read all different configurations. The UI was updated too. I replaced the textbox with a QListWidget so the user can multi-select configurations

Comment thread lib/importproject.cpp Outdated
if (p.platform != ProjectConfiguration::Unknown)
if (p.platform != ProjectConfiguration::Unknown) {
projectConfigurationList.emplace_back(cfg);
bool alreadyIn = false;

@danmar danmar Jan 28, 2020

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. I envisioned that this would be kept out of importVcxproj.

std::set<std::string> ImportProject::getVSConfigs() const {
    std::set<std::string> ret;
    for (const FileSettings &fs: fileSettings)
        ret.insert(fs.cfg);
    return ret;
}

@danmar

danmar commented Jan 28, 2020

Copy link
Copy Markdown
Collaborator

The UI was updated too. I replaced the textbox with a QListWidget so the user can multi-select configurations

Cool.. will take a look soon

@danmar danmar merged commit 074d08e into cppcheck-opensource:master Jan 31, 2020
@danmar

danmar commented Jan 31, 2020

Copy link
Copy Markdown
Collaborator

I merged this, it works good enough for merge. But I think you can tweak it better.

  • When I did not have a vcxproj/sln and chose a sln, both the checkbox and the listbox was enabled.
  • When I remove the vcxproj/sln from the editbox then the list box is not cleared.

@fuzzelhjb

Copy link
Copy Markdown
Contributor Author

I created a new PR with some tiny fixed that should fix this.

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

Successfully merging this pull request may close these issues.

2 participants