Skip to content

Commit

Permalink
Codequality (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
DefinitelyNotSimon13 authored Apr 26, 2024
2 parents 8304792 + e78e111 commit 8fb2685
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/include/JsonHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class JsonHandler {
*
* @bool If the string contains a bad char or not
*/
[[nodiscard]] static bool containsBadCharacter(const std::string &str);
[[nodiscard]] static bool containsBadCharacter(const std::string_view &str);
std::shared_ptr<Json::Value> root;
std::shared_ptr<FileData> data;
};
Expand Down
2 changes: 1 addition & 1 deletion src/include/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Utils {
*
* @return The processed string
*/
static const std::string escapeString(const std::string &str);
static std::string escapeString(const std::string &str);
};
} // namespace utilities

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ std::vector<std::string> validateFiles(const std::vector<std::string> &files) {

// Check if the file ends in .json
if (file.extension() != ".json") {
LOG_WARNING << "The file \"" << file << "\" does not end in \".json\"";
LOG_WARNING << "The file \"" << file << R"(" does not end in ".json")";
OUTPUT << "If the file is not in JSON Format, continuing may "
"result in\nunexpected behaviour!\n";

Expand Down
4 changes: 2 additions & 2 deletions src/sources/JsonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void JsonHandler::assignPathValue(const Json::Value &entry) const {
this->data->addPathValue(path);
}

bool JsonHandler::containsBadCharacter(const std::string &str) {
bool JsonHandler::containsBadCharacter(const std::string_view &str) {

// Set of characters which may not be in the string
static const std::unordered_set<char> badChars = {
Expand All @@ -163,6 +163,6 @@ bool JsonHandler::containsBadCharacter(const std::string &str) {
return badChars.contains(c);
};

return std::any_of(str.begin(), str.end(), isBadCharacter);
return std::ranges::any_of(str, isBadCharacter);
}
} // namespace parsing
2 changes: 1 addition & 1 deletion src/sources/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bool Utils::handleParseException(const exceptions::CustomException &e,
return true;
}

const std::string Utils::escapeString(const std::string &str) {
std::string Utils::escapeString(const std::string &str) {
// Map of characters to their escape sequences
static const std::unordered_map<char, std::string> escapeSequences = {
{'\\', "\\\\"}, // Replace backslash with double backslash
Expand Down

0 comments on commit 8fb2685

Please sign in to comment.