diff --git a/.clang-tidy b/.clang-tidy index dbf7d077..c9b6458f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,8 +1,35 @@ -#Checks: '*,-clang-analyzer-alpha.*' -#Checks: '-*,google-readability-casting,llvm-namespace-comment,performance-unnecessary-value-param,llvm-include-order,misc-throw-by-value-catch-by-reference,readability-container-size-empty,google-runtime-references,modernize*' -Checks: '-*,llvm-namespace-comment,readability-container-size-empty,misc-throw-by-value-catch-by-reference,modernize*,google-readability-casting' -HeaderFilterRegex: '.*hpp' -CheckOptions: -- key: readability-braces-around-statements.ShortStatementLines - value: '1' +# Checks that will be implemented in future PRs: +# performance-unnecessary-value-param, hints to ~110 issues. Be careful with implementing the suggested changes of this one, as auto-fixes may break the code + +FormatStyle: file + +Checks: ' +-*, +google-*, +-google-runtime-int, +-google-runtime-references, +llvm-include-order, +llvm-namespace-comment, +misc-throw-by-value-catch-by-reference, +modernize*, +readability-container-size-empty, +' + +WarningsAsErrors: ' +-*, +google-*, +-google-runtime-int, +-google-runtime-references, +llvm-include-order, +llvm-namespace-comment, +misc-throw-by-value-catch-by-reference, +modernize*, +readability-container-size-empty, +' + +HeaderFilterRegex: '.*hpp' + +CheckOptions: +- key: google-readability-braces-around-statements.ShortStatementLines + value: '3' diff --git a/examples/enum.cpp b/examples/enum.cpp index c9616241..a5f84f98 100644 --- a/examples/enum.cpp +++ b/examples/enum.cpp @@ -18,7 +18,7 @@ int main(int argc, char **argv) { CLI11_PARSE(app, argc, argv); // CLI11's built in enum streaming can be used outside CLI11 like this: - using namespace CLI::enums; + using CLI::enums::operator<<; std::cout << "Enum received: " << level << std::endl; return 0; diff --git a/examples/enum_ostream.cpp b/examples/enum_ostream.cpp index cf8b3295..62bc6971 100644 --- a/examples/enum_ostream.cpp +++ b/examples/enum_ostream.cpp @@ -34,7 +34,7 @@ int main(int argc, char **argv) { CLI11_PARSE(app, argc, argv); // CLI11's built in enum streaming can be used outside CLI11 like this: - using namespace CLI::enums; + using CLI::enums::operator<<; std::cout << "Enum received: " << level << std::endl; return 0; diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 7967afc6..5c616378 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -2416,10 +2416,11 @@ class App { /// Count the required remaining positional arguments bool _has_remaining_positionals() const { - for(const Option_p &opt : options_) + for(const Option_p &opt : options_) { if(opt->get_positional() && ((static_cast(opt->count()) < opt->get_items_expected_min()))) { return true; } + } return false; } diff --git a/include/CLI/Config.hpp b/include/CLI/Config.hpp index f9a3e058..f340dfb2 100644 --- a/include/CLI/Config.hpp +++ b/include/CLI/Config.hpp @@ -314,7 +314,7 @@ ConfigBase::to_config(const App *app, bool default_also, bool write_description, } } - for(const App *subcom : subcommands) + for(const App *subcom : subcommands) { if(!subcom->get_name().empty()) { if(subcom->get_configurable() && app->got_subcommand(subcom)) { if(!prefix.empty() || app->get_parent() == nullptr) { @@ -333,6 +333,7 @@ ConfigBase::to_config(const App *app, bool default_also, bool write_description, out << to_config(subcom, default_also, write_description, prefix + subcom->get_name() + "."); } } + } return out.str(); } diff --git a/include/CLI/Error.hpp b/include/CLI/Error.hpp index 2613527b..80467018 100644 --- a/include/CLI/Error.hpp +++ b/include/CLI/Error.hpp @@ -216,16 +216,18 @@ class RequiredError : public ParseError { Option(std::size_t min_option, std::size_t max_option, std::size_t used, const std::string &option_list) { if((min_option == 1) && (max_option == 1) && (used == 0)) return RequiredError("Exactly 1 option from [" + option_list + "]"); - if((min_option == 1) && (max_option == 1) && (used > 1)) + if((min_option == 1) && (max_option == 1) && (used > 1)) { return RequiredError("Exactly 1 option from [" + option_list + "] is required and " + std::to_string(used) + " were given", ExitCodes::RequiredError); + } if((min_option == 1) && (used == 0)) return RequiredError("At least 1 option from [" + option_list + "]"); - if(used < min_option) + if(used < min_option) { return RequiredError("Requires at least " + std::to_string(min_option) + " options used and only " + std::to_string(used) + "were given from [" + option_list + "]", ExitCodes::RequiredError); + } if(max_option == 1) return RequiredError("Requires at most 1 options be given from [" + option_list + "]", ExitCodes::RequiredError); diff --git a/include/CLI/StringTools.hpp b/include/CLI/StringTools.hpp index 63c006c1..b943eb4c 100644 --- a/include/CLI/StringTools.hpp +++ b/include/CLI/StringTools.hpp @@ -28,7 +28,7 @@ std::ostream &operator<<(std::ostream &in, const T &item) { } // namespace enums /// Export to CLI namespace -using namespace enums; +using enums::operator<<; namespace detail { /// a constant defining an expected max vector size defined to be a big number that could be multiplied by 4 and not diff --git a/include/CLI/Timer.hpp b/include/CLI/Timer.hpp index 2cda8cde..683839d0 100644 --- a/include/CLI/Timer.hpp +++ b/include/CLI/Timer.hpp @@ -54,7 +54,7 @@ class Timer { public: /// Standard constructor, can set title and print function - Timer(std::string title = "Timer", time_print_t time_print = Simple) + explicit Timer(std::string title = "Timer", time_print_t time_print = Simple) : title_(std::move(title)), time_print_(std::move(time_print)), start_(clock::now()) {} /// Time a function by running it multiple times. Target time is the len to target. @@ -117,7 +117,7 @@ class Timer { class AutoTimer : public Timer { public: /// Reimplementing the constructor is required in GCC 4.7 - AutoTimer(std::string title = "Timer", time_print_t time_print = Simple) : Timer(title, time_print) {} + explicit AutoTimer(std::string title = "Timer", time_print_t time_print = Simple) : Timer(title, time_print) {} // GCC 4.7 does not support using inheriting constructors. /// This destructor prints the string