Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,6 @@ bool CmdLineParser::loadCppcheckCfg()
mLogger.printError("could not load cppcheck.cfg - " + cfgErr);
return false;
}
mSettings.premium = startsWith(mSettings.cppcheckCfgProductName, "Cppcheck Premium");
return true;
}

Expand Down
1,130 changes: 750 additions & 380 deletions gui/cppcheck_de.ts

Large diffs are not rendered by default.

1,132 changes: 749 additions & 383 deletions gui/cppcheck_es.ts

Large diffs are not rendered by default.

1,134 changes: 744 additions & 390 deletions gui/cppcheck_fi.ts

Large diffs are not rendered by default.

1,134 changes: 748 additions & 386 deletions gui/cppcheck_fr.ts

Large diffs are not rendered by default.

1,132 changes: 749 additions & 383 deletions gui/cppcheck_it.ts

Large diffs are not rendered by default.

1,130 changes: 750 additions & 380 deletions gui/cppcheck_ja.ts

Large diffs are not rendered by default.

1,130 changes: 750 additions & 380 deletions gui/cppcheck_ka.ts

Large diffs are not rendered by default.

1,128 changes: 747 additions & 381 deletions gui/cppcheck_ko.ts

Large diffs are not rendered by default.

1,134 changes: 748 additions & 386 deletions gui/cppcheck_nl.ts

Large diffs are not rendered by default.

1,130 changes: 750 additions & 380 deletions gui/cppcheck_ru.ts

Large diffs are not rendered by default.

1,134 changes: 744 additions & 390 deletions gui/cppcheck_sr.ts

Large diffs are not rendered by default.

1,130 changes: 750 additions & 380 deletions gui/cppcheck_sv.ts

Large diffs are not rendered by default.

1,130 changes: 750 additions & 380 deletions gui/cppcheck_zh_CN.ts

Large diffs are not rendered by default.

1,130 changes: 744 additions & 386 deletions gui/cppcheck_zh_TW.ts

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,8 +1091,6 @@ bool MainWindow::getCppcheckSettings(Settings& settings, Suppressions& supprs)
return false;
}

settings.premium = startsWith(settings.cppcheckCfgProductName, "Cppcheck Premium");

const auto cfgAddons = settings.addons;
settings.addons.clear();
for (const std::string& addon : cfgAddons) {
Expand Down Expand Up @@ -2326,7 +2324,7 @@ void MainWindow::hideInformation() {
}

bool MainWindow::isCppcheckPremium() const {
return mCppcheckCfgProductName.startsWith("Cppcheck Premium ");
return Settings::isCppcheckPremium(mCppcheckCfgProductName.toStdString());
}

void MainWindow::changeReportType() {
Expand Down
5 changes: 5 additions & 0 deletions lib/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,16 @@ std::string Settings::loadCppcheckCfg(Settings& settings, Suppressions& suppress
}
}

settings.premium = isCppcheckPremium(settings.cppcheckCfgProductName);
settings.settingsFiles.emplace_back(std::move(fileName));

return "";
}

bool Settings::isCppcheckPremium(const std::string& productName) {
return startsWith(productName, "Cppcheck Premium");
}

std::pair<std::string, std::string> Settings::getNameAndVersion(const std::string& productName) {
if (productName.empty())
return {};
Expand Down
2 changes: 2 additions & 0 deletions lib/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ class CPPCHECKLIB WARN_UNUSED Settings {
/** Is checker id enabled by premiumArgs */
bool isPremiumEnabled(const char id[]) const;

static bool isCppcheckPremium(const std::string& productName);

Comment on lines +330 to +331
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great - now we have an additional way (again) to check for premium which fragments the code and needs to be removed again in the future...

Copy link
Owner Author

@danmar danmar Oct 30, 2025

Choose a reason for hiding this comment

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

which fragments the code and needs to be removed again in the future...

imho it's more "fragmented" to have copy pasted code. If you want to refactor this in the future, feel free to do it but there will be compiler errors if you miss the refactoring somewhere. It will not be silently missed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This actually makes it more fragment and you also missed some cases. But I would prefer if you remove this change.

After moving the duplicated line you only had to add a single line to fix the tests (which was a bug but not yet exposed because there is nothing which could be tested yet). Everything else is just unnecessary cruft.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I don't understand your goal and therefore it just seems to me that you rather have copy-pasted code. Can you share some insight into how it should be done instead?

I moved the startsWith("Cppcheck Premium") to a single place:

  • if the string literal has a typo in 1 place the code will compile fine and we don't have great testing of Cppcheck GUI so it might not be spotted.
  • when it is refactored later I fear that you will miss some places. If I missed a place then why wouldn't you.. so it feels safer to avoid the copy/paste immediately.

/** @brief Using -E for debugging purposes */
bool preprocessOnly{};

Expand Down
1 change: 1 addition & 0 deletions test/testcmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class TestCmdlineParser : public TestFixture {
void asPremium() {
// set this so we think it is the premium
settings->cppcheckCfgProductName = "Cppcheck Premium 0.0.0";
settings->premium = true;
}

template<size_t size>
Expand Down