Commit 1ee22ec9ffc2875cee864ce10e05747b102b8f16
1 parent
60934c8a
Using empty instead of 0 size
Showing
4 changed files
with
18 additions
and
18 deletions
.clang-tidy
| 1 | 1 | #Checks: '*,-clang-analyzer-alpha.*' |
| 2 | 2 | #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*' |
| 3 | -Checks: '-*,llvm-namespace-comment,llvm-include-order' | |
| 3 | +Checks: '-*,llvm-namespace-comment,llvm-include-order,readability-container-size-empty' | |
| 4 | 4 | HeaderFilterRegex: '.*hpp' |
| 5 | 5 | CheckOptions: |
| 6 | 6 | - key: readability-braces-around-statements.ShortStatementLines | ... | ... |
include/CLI/App.hpp
| ... | ... | @@ -602,7 +602,7 @@ public: |
| 602 | 602 | for(const Option_p &opt : options_) { |
| 603 | 603 | |
| 604 | 604 | // Only process option with a long-name |
| 605 | - if(opt->lnames_.size() > 0) { | |
| 605 | + if(!opt->lnames_.empty()) { | |
| 606 | 606 | std::string name = prefix + opt->lnames_[0]; |
| 607 | 607 | |
| 608 | 608 | // Non-flags |
| ... | ... | @@ -644,7 +644,7 @@ public: |
| 644 | 644 | prev += " " + name_; |
| 645 | 645 | |
| 646 | 646 | auto selected_subcommands = get_subcommands(); |
| 647 | - if(selected_subcommands.size() > 0) | |
| 647 | + if(!selected_subcommands.empty()) | |
| 648 | 648 | return selected_subcommands.at(0)->help(wid, prev); |
| 649 | 649 | |
| 650 | 650 | std::stringstream out; |
| ... | ... | @@ -676,7 +676,7 @@ public: |
| 676 | 676 | pos=true; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - if(subcommands_.size() > 0) { | |
| 679 | + if(!subcommands_.empty()) { | |
| 680 | 680 | if(require_subcommand_ != 0) |
| 681 | 681 | out << " SUBCOMMAND"; |
| 682 | 682 | else |
| ... | ... | @@ -715,7 +715,7 @@ public: |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | // Subcommands |
| 718 | - if(subcommands_.size()> 0) { | |
| 718 | + if(!subcommands_.empty()) { | |
| 719 | 719 | out << "Subcommands:" << std::endl; |
| 720 | 720 | for(const App_p &com : subcommands_) |
| 721 | 721 | detail::format_help(out, com->get_name(), com->description_, wid); |
| ... | ... | @@ -829,7 +829,7 @@ protected: |
| 829 | 829 | parsed_ = true; |
| 830 | 830 | bool positional_only = false; |
| 831 | 831 | |
| 832 | - while(args.size()>0) { | |
| 832 | + while(!args.empty()) { | |
| 833 | 833 | _parse_single(args, positional_only); |
| 834 | 834 | } |
| 835 | 835 | |
| ... | ... | @@ -842,7 +842,7 @@ protected: |
| 842 | 842 | if (config_ptr_ != nullptr && config_name_ != "") { |
| 843 | 843 | try { |
| 844 | 844 | std::vector<detail::ini_ret_t> values = detail::parse_ini(config_name_); |
| 845 | - while(values.size() > 0) { | |
| 845 | + while(!values.empty()) { | |
| 846 | 846 | if(!_parse_ini(values)) { |
| 847 | 847 | throw ExtrasINIError(values.back().fullname); |
| 848 | 848 | } |
| ... | ... | @@ -888,7 +888,7 @@ protected: |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | auto selected_subcommands =get_subcommands(); |
| 891 | - if(require_subcommand_ < 0 && selected_subcommands.size() == 0) | |
| 891 | + if(require_subcommand_ < 0 && selected_subcommands.empty()) | |
| 892 | 892 | throw RequiredError("Subcommand required"); |
| 893 | 893 | else if(require_subcommand_ > 0 && static_cast<int>( selected_subcommands.size()) != require_subcommand_) |
| 894 | 894 | throw RequiredError(std::to_string(require_subcommand_) + " subcommand(s) required"); |
| ... | ... | @@ -1081,11 +1081,11 @@ protected: |
| 1081 | 1081 | |
| 1082 | 1082 | |
| 1083 | 1083 | if(num == -1) { |
| 1084 | - while(args.size()>0 && _recognize(args.back()) == detail::Classifer::NONE) { | |
| 1084 | + while(!args.empty() && _recognize(args.back()) == detail::Classifer::NONE) { | |
| 1085 | 1085 | op->add_result(args.back()); |
| 1086 | 1086 | args.pop_back(); |
| 1087 | 1087 | } |
| 1088 | - } else while(num>0 && args.size() > 0) { | |
| 1088 | + } else while(num>0 && !args.empty()) { | |
| 1089 | 1089 | num--; |
| 1090 | 1090 | std::string current_ = args.back(); |
| 1091 | 1091 | args.pop_back(); |
| ... | ... | @@ -1137,11 +1137,11 @@ protected: |
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | 1139 | if(num == -1) { |
| 1140 | - while(args.size() > 0 && _recognize(args.back()) == detail::Classifer::NONE) { | |
| 1140 | + while(!args.empty() && _recognize(args.back()) == detail::Classifer::NONE) { | |
| 1141 | 1141 | op->add_result(args.back()); |
| 1142 | 1142 | args.pop_back(); |
| 1143 | 1143 | } |
| 1144 | - } else while(num>0 && args.size()>0) { | |
| 1144 | + } else while(num>0 && !args.empty()) { | |
| 1145 | 1145 | num--; |
| 1146 | 1146 | op->add_result(args.back()); |
| 1147 | 1147 | args.pop_back(); | ... | ... |
include/CLI/Option.hpp
| ... | ... | @@ -354,12 +354,12 @@ public: |
| 354 | 354 | } |
| 355 | 355 | if(envname_ != "") |
| 356 | 356 | out << " (env:" << envname_ << ")"; |
| 357 | - if(requires_.size() > 0) { | |
| 357 | + if(!requires_.empty()) { | |
| 358 | 358 | out << " Requires:"; |
| 359 | 359 | for(const Option* opt : requires_) |
| 360 | 360 | out << " " << opt->get_name(); |
| 361 | 361 | } |
| 362 | - if(excludes_.size() > 0) { | |
| 362 | + if(!excludes_.empty()) { | |
| 363 | 363 | out << " Excludes:"; |
| 364 | 364 | for(const Option* opt : excludes_) |
| 365 | 365 | out << " " << opt->get_name(); |
| ... | ... | @@ -377,7 +377,7 @@ public: |
| 377 | 377 | void run_callback() const { |
| 378 | 378 | if(!callback_(results_)) |
| 379 | 379 | throw ConversionError(get_name() + "=" + detail::join(results_)); |
| 380 | - if(validators_.size()>0) { | |
| 380 | + if(!validators_.empty()) { | |
| 381 | 381 | for(const std::string & result : results_) |
| 382 | 382 | for(const std::function<bool(std::string)> &vali : validators_) |
| 383 | 383 | if(!vali(result)) |
| ... | ... | @@ -486,7 +486,7 @@ public: |
| 486 | 486 | ///@{ |
| 487 | 487 | /// Can print positional name detailed option if true |
| 488 | 488 | bool _has_help_positional() const { |
| 489 | - return get_positional() && (has_description() || requires_.size()>0 || excludes_.size()>0 ); | |
| 489 | + return get_positional() && (has_description() || !requires_.empty() || !excludes_.empty() ); | |
| 490 | 490 | } |
| 491 | 491 | ///@} |
| 492 | 492 | }; | ... | ... |
include/CLI/StringTools.hpp
| ... | ... | @@ -136,7 +136,7 @@ bool valid_later_char(T c) { |
| 136 | 136 | |
| 137 | 137 | /// Verify an option name |
| 138 | 138 | inline bool valid_name_string(const std::string &str) { |
| 139 | - if(str.size()<1 || !valid_first_char(str[0])) | |
| 139 | + if(str.empty() || !valid_first_char(str[0])) | |
| 140 | 140 | return false; |
| 141 | 141 | for(auto c : str.substr(1)) |
| 142 | 142 | if(!valid_later_char(c)) |
| ... | ... | @@ -160,7 +160,7 @@ inline std::vector<std::string> split_up(std::string str) { |
| 160 | 160 | |
| 161 | 161 | std::vector<std::string> output; |
| 162 | 162 | |
| 163 | - while(str.size() > 0) { | |
| 163 | + while(!str.empty()) { | |
| 164 | 164 | if(str[0] == '\'') { |
| 165 | 165 | auto end = str.find('\'', 1); |
| 166 | 166 | if(end != std::string::npos) { | ... | ... |