mirror of https://github.com/Icinga/icinga2.git
Apply clang-tidy fix 'modernize-raw-string-literal'
This commit is contained in:
parent
621eed3f13
commit
d6062eefbf
|
@ -358,7 +358,7 @@ void ElasticsearchWriter::Enqueue(const String& type, const Dictionary::Ptr& fie
|
||||||
* We do it this way to avoid problems with a near full queue.
|
* We do it this way to avoid problems with a near full queue.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String indexBody = "{ \"index\" : { \"_type\" : \"" + eventType + "\" } }\n";
|
String indexBody = R"({ "index" : { "_type" : ")" + eventType + "\" } }\n";
|
||||||
String fieldsBody = JsonEncode(fields);
|
String fieldsBody = JsonEncode(fields);
|
||||||
|
|
||||||
Log(LogDebug, "ElasticsearchWriter")
|
Log(LogDebug, "ElasticsearchWriter")
|
||||||
|
|
|
@ -98,7 +98,7 @@ bool InfoHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request,
|
||||||
} else
|
} else
|
||||||
body += "Your user does not have any permissions.</p>";
|
body += "Your user does not have any permissions.</p>";
|
||||||
|
|
||||||
body += "<p>More information about API requests is available in the <a href=\"https://docs.icinga.com/icinga2/latest\" target=\"_blank\">documentation</a>.</p></html>";
|
body += R"(<p>More information about API requests is available in the <a href="https://docs.icinga.com/icinga2/latest" target="_blank">documentation</a>.</p></html>)";
|
||||||
response.WriteBody(body.CStr(), body.GetLength());
|
response.WriteBody(body.CStr(), body.GetLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,34 +109,34 @@ BOOST_AUTO_TEST_CASE(simple)
|
||||||
expr = ConfigCompiler::CompileText("<test>", "256 >> 4 >> 3");
|
expr = ConfigCompiler::CompileText("<test>", "256 >> 4 >> 3");
|
||||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 2);
|
BOOST_CHECK(expr->Evaluate(frame).GetValue() == 2);
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"hello\" == \"hello\"");
|
expr = ConfigCompiler::CompileText("<test>", R"("hello" == "hello")");
|
||||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"hello\" != \"hello\"");
|
expr = ConfigCompiler::CompileText("<test>", R"("hello" != "hello")");
|
||||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in [ \"foo\", \"bar\" ]");
|
expr = ConfigCompiler::CompileText("<test>", R"("foo" in [ "foo", "bar" ])");
|
||||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in [ \"bar\", \"baz\" ]");
|
expr = ConfigCompiler::CompileText("<test>", R"("foo" in [ "bar", "baz" ])");
|
||||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in null");
|
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in null");
|
||||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in \"bar\"");
|
expr = ConfigCompiler::CompileText("<test>", R"("foo" in "bar")");
|
||||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in [ \"bar\", \"baz\" ]");
|
expr = ConfigCompiler::CompileText("<test>", R"("foo" !in [ "bar", "baz" ])");
|
||||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in [ \"foo\", \"bar\" ]");
|
expr = ConfigCompiler::CompileText("<test>", R"("foo" !in [ "foo", "bar" ])");
|
||||||
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
BOOST_CHECK(!expr->Evaluate(frame).GetValue());
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in null");
|
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in null");
|
||||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in \"bar\"");
|
expr = ConfigCompiler::CompileText("<test>", R"("foo" !in "bar")");
|
||||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "{ a += 3 }");
|
expr = ConfigCompiler::CompileText("<test>", "{ a += 3 }");
|
||||||
|
@ -156,10 +156,10 @@ BOOST_AUTO_TEST_CASE(simple)
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"test\" + 3");
|
expr = ConfigCompiler::CompileText("<test>", "\"test\" + 3");
|
||||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == "test3");
|
BOOST_CHECK(expr->Evaluate(frame).GetValue() == "test3");
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"\\\"te\\\\st\"");
|
expr = ConfigCompiler::CompileText("<test>", R"("\"te\\st")");
|
||||||
BOOST_CHECK(expr->Evaluate(frame).GetValue() == "\"te\\st");
|
BOOST_CHECK(expr->Evaluate(frame).GetValue() == "\"te\\st");
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "\"\\'test\"");
|
expr = ConfigCompiler::CompileText("<test>", R"("\'test")");
|
||||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "({ a = 3\nb = 3 })");
|
expr = ConfigCompiler::CompileText("<test>", "({ a = 3\nb = 3 })");
|
||||||
|
@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(advanced)
|
||||||
std::unique_ptr<Expression> expr;
|
std::unique_ptr<Expression> expr;
|
||||||
Function::Ptr func;
|
Function::Ptr func;
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "regex(\"^Hello\", \"Hello World\")");
|
expr = ConfigCompiler::CompileText("<test>", R"(regex("^Hello", "Hello World"))");
|
||||||
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
BOOST_CHECK(expr->Evaluate(frame).GetValue());
|
||||||
|
|
||||||
expr = ConfigCompiler::CompileText("<test>", "__boost_test()");
|
expr = ConfigCompiler::CompileText("<test>", "__boost_test()");
|
||||||
|
|
|
@ -494,7 +494,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
||||||
else
|
else
|
||||||
m_Impl << "\t" << "if (" << argName << ".IsEmpty())" << std::endl;
|
m_Impl << "\t" << "if (" << argName << ".IsEmpty())" << std::endl;
|
||||||
|
|
||||||
m_Impl << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<ConfigObject *>(this), { \"" << field.Name << "\" }, \"Attribute must not be empty.\"));" << std::endl << std::endl;
|
m_Impl << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<ConfigObject *>(this), { \"" << field.Name << R"(" }, "Attribute must not be empty."));)" << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.Attributes & FADeprecated) {
|
if (field.Attributes & FADeprecated) {
|
||||||
|
@ -503,7 +503,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
||||||
else
|
else
|
||||||
m_Impl << "\t" << "if (" << argName << " != GetDefault" << field.GetFriendlyName() << "())" << std::endl;
|
m_Impl << "\t" << "if (" << argName << " != GetDefault" << field.GetFriendlyName() << "())" << std::endl;
|
||||||
|
|
||||||
m_Impl << "\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << "' for object '\" << dynamic_cast<ConfigObject *>(this)->GetName() << \"' of type '\" << dynamic_cast<ConfigObject *>(this)->GetReflectionType()->GetName() << \"' is deprecated and should not be used.\";" << std::endl;
|
m_Impl << "\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << R"(' for object '" << dynamic_cast<ConfigObject *>(this)->GetName() << "' of type '" << dynamic_cast<ConfigObject *>(this)->GetReflectionType()->GetName() << "' is deprecated and should not be used.";)" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.Type.ArrayRank > 0) {
|
if (field.Type.ArrayRank > 0) {
|
||||||
|
@ -518,7 +518,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
||||||
m_Impl << "\t" << "if (value.IsObjectType<Function>()) {" << std::endl
|
m_Impl << "\t" << "if (value.IsObjectType<Function>()) {" << std::endl
|
||||||
<< "\t\t" << "Function::Ptr func = value;" << std::endl
|
<< "\t\t" << "Function::Ptr func = value;" << std::endl
|
||||||
<< "\t\t" << "if (func->IsDeprecated())" << std::endl
|
<< "\t\t" << "if (func->IsDeprecated())" << std::endl
|
||||||
<< "\t\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << "' for object '\" << dynamic_cast<ConfigObject *>(this)->GetName() << \"' of type '\" << dynamic_cast<ConfigObject *>(this)->GetReflectionType()->GetName() << \"' is set to a deprecated function: \" << func->GetName();" << std::endl
|
<< "\t\t\t" << "Log(LogWarning, \"" << klass.Name << "\") << \"Attribute '" << field.Name << R"(' for object '" << dynamic_cast<ConfigObject *>(this)->GetName() << "' of type '" << dynamic_cast<ConfigObject *>(this)->GetReflectionType()->GetName() << "' is set to a deprecated function: " << func->GetName();)" << std::endl
|
||||||
<< "\t" << "}" << std::endl << std::endl;
|
<< "\t" << "}" << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,13 +531,13 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
||||||
m_Impl << "!value.IsEmpty() && ";
|
m_Impl << "!value.IsEmpty() && ";
|
||||||
|
|
||||||
m_Impl << "!utils.ValidateName(\"" << field.Type.TypeName << "\", value))" << std::endl
|
m_Impl << "!utils.ValidateName(\"" << field.Type.TypeName << "\", value))" << std::endl
|
||||||
<< "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<ConfigObject *>(this), { \"" << field.Name << "\" }, \"Object '\" + value + \"' of type '" << field.Type.TypeName
|
<< "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<ConfigObject *>(this), { \"" << field.Name << R"(" }, "Object '" + value + "' of type ')" << field.Type.TypeName
|
||||||
<< "' does not exist.\"));" << std::endl;
|
<< "' does not exist.\"));" << std::endl;
|
||||||
} else if (field.Type.ArrayRank > 0 && (ftype == "Number" || ftype == "Boolean")) {
|
} else if (field.Type.ArrayRank > 0 && (ftype == "Number" || ftype == "Boolean")) {
|
||||||
m_Impl << "\t" << "try {" << std::endl
|
m_Impl << "\t" << "try {" << std::endl
|
||||||
<< "\t\t" << "Convert::ToDouble(value);" << std::endl
|
<< "\t\t" << "Convert::ToDouble(value);" << std::endl
|
||||||
<< "\t" << "} catch (const std::invalid_argument&) {" << std::endl
|
<< "\t" << "} catch (const std::invalid_argument&) {" << std::endl
|
||||||
<< "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<ConfigObject *>(this), { \"" << field.Name << "\", \"Array element '\" + value + \"' of type '\" + value.GetReflectionType()->GetName() + \"' is not valid here; expected type '" << ftype << "'.\"));" << std::endl
|
<< "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<ConfigObject *>(this), { \"" << field.Name << R"(", "Array element '" + value + "' of type '" + value.GetReflectionType()->GetName() + "' is not valid here; expected type ')" << ftype << "'.\"));" << std::endl
|
||||||
<< "\t" << "}" << std::endl;
|
<< "\t" << "}" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,7 +1144,7 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string&
|
||||||
<< "\t\t\t" << "if (utils.ValidateName(\"" << rule.Type << "\", value))" << std::endl
|
<< "\t\t\t" << "if (utils.ValidateName(\"" << rule.Type << "\", value))" << std::endl
|
||||||
<< "\t\t\t\t" << "return;" << std::endl
|
<< "\t\t\t\t" << "return;" << std::endl
|
||||||
<< "\t\t\t" << "else" << std::endl
|
<< "\t\t\t" << "else" << std::endl
|
||||||
<< "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<ConfigObject>(object), location, \"Object '\" + value + \"' of type '" << rule.Type << "' does not exist.\"));" << std::endl
|
<< "\t\t\t\t" << R"(BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<ConfigObject>(object), location, "Object '" + value + "' of type ')" << rule.Type << "' does not exist.\"));" << std::endl
|
||||||
<< "\t\t" << "}" << std::endl;
|
<< "\t\t" << "}" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue