@@ -130,49 +130,66 @@ class TestFixture : public ErrorLogger {
130130 check.runChecks (tokenizer, settings, errorLogger);
131131 }
132132
133- // TODO: bail out on redundant settings
134133 class SettingsBuilder
135134 {
136135 public:
137136 explicit SettingsBuilder (const TestFixture &fixture) : fixture(fixture) {}
138137 SettingsBuilder (const TestFixture &fixture, Settings settings) : fixture(fixture), settings(std::move(settings)) {}
139138
140139 SettingsBuilder& severity (Severity::SeverityType sev, bool b = true ) {
140+ if (REDUNDANT_CHECK && settings.severity .isEnabled (sev) == b)
141+ throw std::runtime_error (" redundant setting: severity" );
141142 settings.severity .setEnabled (sev, b);
142143 return *this ;
143144 }
144145
145146 SettingsBuilder& certainty (Certainty cert, bool b = true ) {
147+ if (REDUNDANT_CHECK && settings.certainty .isEnabled (cert) == b)
148+ throw std::runtime_error (" redundant setting: certainty" );
146149 settings.certainty .setEnabled (cert, b);
147150 return *this ;
148151 }
149152
150153 SettingsBuilder& clang () {
154+ if (REDUNDANT_CHECK && settings.clang )
155+ throw std::runtime_error (" redundant setting: clang" );
151156 settings.clang = true ;
152157 return *this ;
153158 }
154159
155160 SettingsBuilder& checkLibrary () {
161+ if (REDUNDANT_CHECK && settings.checkLibrary )
162+ throw std::runtime_error (" redundant setting: checkLibrary" );
156163 settings.checkLibrary = true ;
157164 return *this ;
158165 }
159166
160167 SettingsBuilder& checkUnusedTemplates (bool b = true ) {
168+ if (REDUNDANT_CHECK && settings.checkUnusedTemplates == b)
169+ throw std::runtime_error (" redundant setting: checkUnusedTemplates" );
161170 settings.checkUnusedTemplates = b;
162171 return *this ;
163172 }
164173
165174 SettingsBuilder& debugwarnings (bool b = true ) {
175+ if (REDUNDANT_CHECK && settings.debugwarnings == b)
176+ throw std::runtime_error (" redundant setting: debugwarnings" );
166177 settings.debugwarnings = b;
167178 return *this ;
168179 }
169180
170181 SettingsBuilder& c (Standards::cstd_t std) {
182+ // TODO: CLatest and C11 are the same - handle differently
183+ // if (REDUNDANT_CHECK && settings.standards.c == std)
184+ // throw std::runtime_error("redundant setting: standards.c");
171185 settings.standards .c = std;
172186 return *this ;
173187 }
174188
175189 SettingsBuilder& cpp (Standards::cppstd_t std) {
190+ // TODO: CPPLatest and CPP20 are the same - handle differently
191+ // if (REDUNDANT_CHECK && settings.standards.cpp == std)
192+ // throw std::runtime_error("redundant setting: standards.cpp");
176193 settings.standards .cpp = std;
177194 return *this ;
178195 }
@@ -184,11 +201,15 @@ class TestFixture : public ErrorLogger {
184201 SettingsBuilder& platform (cppcheck::Platform::Type type);
185202
186203 SettingsBuilder& checkConfiguration () {
204+ if (REDUNDANT_CHECK && settings.checkConfiguration )
205+ throw std::runtime_error (" redundant setting: checkConfiguration" );
187206 settings.checkConfiguration = true ;
188207 return *this ;
189208 }
190209
191210 SettingsBuilder& checkHeaders (bool b = true ) {
211+ if (REDUNDANT_CHECK && settings.checkHeaders == b)
212+ throw std::runtime_error (" redundant setting: checkHeaders" );
192213 settings.checkHeaders = b;
193214 return *this ;
194215 }
@@ -199,6 +220,8 @@ class TestFixture : public ErrorLogger {
199220 private:
200221 const TestFixture &fixture;
201222 Settings settings;
223+
224+ const bool REDUNDANT_CHECK = false ;
202225 };
203226
204227 SettingsBuilder settingsBuilder () const {
0 commit comments