Skip to content

Commit 0d17c47

Browse files
committed
src: remove unreachable code after strict schema validation
1 parent 9414f0e commit 0d17c47

1 file changed

Lines changed: 11 additions & 58 deletions

File tree

src/node_config_file.cc

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,6 @@ ParseResult ConfigReader::ProcessOptionValue(
148148
output->push_back(option_name + "=" + std::to_string(result));
149149
break;
150150
}
151-
case options_parser::OptionType::kNoOp: {
152-
FPrintF(
153-
stderr, "No-op flag %s is currently not supported\n", option_name);
154-
return ParseResult::InvalidContent;
155-
}
156-
case options_parser::OptionType::kV8Option: {
157-
FPrintF(stderr, "V8 flag %s is currently not supported\n", option_name);
158-
return ParseResult::InvalidContent;
159-
}
160151
default:
161152
UNREACHABLE();
162153
}
@@ -197,31 +188,21 @@ ParseResult ConfigReader::ParseOptions(
197188
return ParseResult::InvalidContent;
198189
}
199190

200-
// The key needs to match the CLI option
201191
std::string prefix = "--";
202192
auto option = options_map.find(prefix.append(option_key));
203-
if (option != options_map.end()) {
204-
// If the option has already been set, return an error
205-
if (unique_options->contains(option->first)) {
206-
FPrintF(stderr, "Option %s is already defined\n", option->first);
207-
return ParseResult::InvalidContent;
208-
}
209-
// Add the option to the unique set to prevent duplicates
210-
// on future iterations
211-
unique_options->insert(option->first);
212-
// Process the option value based on its type
213-
ParseResult result =
214-
ProcessOptionValue(*option, &option_value, output_vector);
215-
if (result != ParseResult::Valid) {
216-
return result;
217-
}
218-
} else {
219-
FPrintF(stderr,
220-
"Unknown or not allowed option %s for namespace %s\n",
221-
option_key,
222-
namespace_name);
193+
if (option == options_map.end()) {
223194
return ParseResult::InvalidContent;
224195
}
196+
if (unique_options->contains(option->first)) {
197+
FPrintF(stderr, "Option %s is already defined\n", option->first);
198+
return ParseResult::InvalidContent;
199+
}
200+
unique_options->insert(option->first);
201+
ParseResult result =
202+
ProcessOptionValue(*option, &option_value, output_vector);
203+
if (result != ParseResult::Valid) {
204+
return result;
205+
}
225206
}
226207
return ParseResult::Valid;
227208
}
@@ -261,18 +242,7 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) {
261242
return ParseResult::InvalidContent;
262243
}
263244

264-
// Get all available namespaces for validation
265-
std::vector<std::string> available_namespaces =
266-
options_parser::MapAvailableNamespaces();
267-
// Add "nodeOptions" as a special case for backward compatibility
268-
available_namespaces.emplace_back("nodeOptions");
269-
270-
// Create a set for faster lookup of valid namespaces
271-
std::unordered_set<std::string> valid_namespaces(available_namespaces.begin(),
272-
available_namespaces.end());
273-
// Create a set to track unique options
274245
std::unordered_set<std::string> unique_options;
275-
// Namespaces in OPTION_NAMESPACE_LIST
276246
std::unordered_set<std::string> namespaces_with_implicit_flags;
277247

278248
// Iterate through the main object to find all namespaces
@@ -284,27 +254,10 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) {
284254

285255
std::string namespace_name(field_name);
286256

287-
// TODO(@marco-ippolito): Remove warning for testRunner namespace
288-
if (namespace_name == "testRunner") {
289-
FPrintF(stderr,
290-
"the \"testRunner\" namespace has been removed. "
291-
"Use \"test\" instead.\n");
292-
// Better to throw an error than to ignore it
293-
// Otherwise users might think their test suite is green
294-
// when it's not running
295-
return ParseResult::InvalidContent;
296-
}
297-
298257
if (namespace_name == kSchemaField) {
299258
continue;
300259
}
301260

302-
// Check if this field is a valid namespace
303-
if (!valid_namespaces.contains(namespace_name)) {
304-
FPrintF(stderr, "Unknown namespace %s\n", namespace_name);
305-
return ParseResult::InvalidContent;
306-
}
307-
308261
// List of implicit namespace flags
309262
for (auto ns_enum : options_parser::AllNamespaces()) {
310263
std::string ns_str = options_parser::NamespaceEnumToString(ns_enum);

0 commit comments

Comments
 (0)