Skip to content

Commit d8a5bdc

Browse files
authored
Add and fix cpplint whitespace/comments (#434)
* Add whitespace/comments check * Adapt spacing in clang-format * Fix cpplint whitespace/comments issues * Grammar * Do not use clang-format for comment spacing * Fix with clang-format pre-commit hook
1 parent ba68040 commit d8a5bdc

30 files changed

+170
-174
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ SortIncludes: true
7575
# SpaceBeforeAssignmentOperators: true
7676
SpaceBeforeParens: Never
7777
# SpaceInEmptyParentheses: false
78-
# SpacesBeforeTrailingComments: 1
78+
SpacesBeforeTrailingComments: 2
7979
# SpacesInAngles: false
8080
# SpacesInContainerLiterals: true
8181
# SpacesInCStyleCastParentheses: false

CPPLINT.cfg

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
set noparent
22
linelength=120 # As in .clang-format
33

4-
# Non-used filters
4+
# Unused filters
55
filter=-build/include_order # Requires unusual include order that encourages creating not self-contained headers
66
filter=-readability/nolint # Conflicts with clang-tidy
77
filter=-runtime/references # Requires fundamental change of API, don't see need for this
88
filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability
99
filter=-whitespace/indent # Requires strange 3-space indent of private/protected/public markers
1010
filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format
1111

12-
# Filters to be included in future
13-
filter=-whitespace/comments
14-

examples/groups.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int main(int argc, char **argv) {
2020
int count{0};
2121
CLI::Option *copt = app.add_flag("-c,--count", count, "Counter")->required()->group("Important");
2222

23-
double value{0.0}; // = 3.14;
23+
double value{0.0}; // = 3.14;
2424
app.add_option("-d,--double", value, "Some Value")->group("Other");
2525

2626
try {

examples/nested.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main(int argc, char **argv) {
1414
app.add_flag("--version", "Get version");
1515

1616
CLI::App *cameraApp = app.add_subcommand("camera", "Configure the app camera");
17-
cameraApp->require_subcommand(0, 1); // 0 (default) or 1 camera
17+
cameraApp->require_subcommand(0, 1); // 0 (default) or 1 camera
1818

1919
std::string mvcamera_config_file = "mvcamera_config.json";
2020
CLI::App *mvcameraApp = cameraApp->add_subcommand("mvcamera", "MatrixVision Camera Configuration");

examples/simple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int main(int argc, char **argv) {
2121
int v{0};
2222
CLI::Option *flag = app.add_flag("--flag", v, "Some flag that can be passed multiple times");
2323

24-
double value{0.0}; // = 3.14;
24+
double value{0.0}; // = 3.14;
2525
app.add_option("-d,--double", value, "Some Value");
2626

2727
CLI11_PARSE(app, argc, argv);

examples/subcom_partitioned.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int main(int argc, char **argv) {
2323
CLI::Option *copt = impOpt->add_flag("-c,--count", count, "Counter")->required();
2424

2525
CLI::App_p otherOpt = std::make_shared<CLI::App>("Other");
26-
double value{0.0}; // = 3.14;
26+
double value{0.0}; // = 3.14;
2727
otherOpt->add_option("-d,--double", value, "Some Value");
2828

2929
// add the subapps to the main one

examples/subcommands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int main(int argc, char **argv) {
1515
app.add_flag("--random", "Some random flag");
1616
CLI::App *start = app.add_subcommand("start", "A great subcommand");
1717
CLI::App *stop = app.add_subcommand("stop", "Do you really want to stop?");
18-
app.require_subcommand(); // 1 or more
18+
app.require_subcommand(); // 1 or more
1919

2020
std::string file;
2121
start->add_option("-f,--file", file, "File name");

include/CLI/App.hpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ namespace CLI {
4343
namespace detail {
4444
enum class Classifier { NONE, POSITIONAL_MARK, SHORT, LONG, WINDOWS, SUBCOMMAND, SUBCOMMAND_TERMINATOR };
4545
struct AppFriend;
46-
} // namespace detail
46+
} // namespace detail
4747

4848
namespace FailureMessage {
4949
std::string simple(const App *app, const Error &e);
5050
std::string help(const App *app, const Error &e);
51-
} // namespace FailureMessage
51+
} // namespace FailureMessage
5252

5353
/// enumeration of modes of how to deal with extras in config files
5454

@@ -464,7 +464,7 @@ class App {
464464
auto *p = (parent_ != nullptr) ? _get_fallthrough_parent() : this;
465465
auto &match = _compare_subcommand_names(*this, *p);
466466
if(!match.empty()) {
467-
ignore_case_ = false; // we are throwing so need to be exception invariant
467+
ignore_case_ = false; // we are throwing so need to be exception invariant
468468
throw OptionAlreadyAdded("ignore case would cause subcommand name conflicts: " + match);
469469
}
470470
}
@@ -586,19 +586,19 @@ class App {
586586
}
587587
}
588588
// this line should not be reached the above loop should trigger the throw
589-
throw(OptionAlreadyAdded("added option matched existing option name")); // LCOV_EXCL_LINE
589+
throw(OptionAlreadyAdded("added option matched existing option name")); // LCOV_EXCL_LINE
590590
}
591591

592592
/// Add option for assigning to a variable
593593
template <typename AssignTo,
594594
typename ConvertTo = AssignTo,
595595
enable_if_t<!std::is_const<ConvertTo>::value, detail::enabler> = detail::dummy>
596596
Option *add_option(std::string option_name,
597-
AssignTo &variable, ///< The variable to set
597+
AssignTo &variable, ///< The variable to set
598598
std::string option_description = "",
599599
bool defaulted = false) {
600600

601-
auto fun = [&variable](const CLI::results_t &res) { // comment for spacing
601+
auto fun = [&variable](const CLI::results_t &res) { // comment for spacing
602602
return detail::lexical_conversion<AssignTo, ConvertTo>(res, variable);
603603
};
604604

@@ -619,7 +619,7 @@ class App {
619619
/// Add option for a callback of a specific type
620620
template <typename T>
621621
Option *add_option_function(std::string option_name,
622-
const std::function<void(const T &)> &func, ///< the callback to execute
622+
const std::function<void(const T &)> &func, ///< the callback to execute
623623
std::string option_description = "") {
624624

625625
auto fun = [func](const CLI::results_t &res) {
@@ -731,7 +731,7 @@ class App {
731731
template <typename T,
732732
enable_if_t<std::is_integral<T>::value && !is_bool<T>::value, detail::enabler> = detail::dummy>
733733
Option *add_flag(std::string flag_name,
734-
T &flag_count, ///< A variable holding the count
734+
T &flag_count, ///< A variable holding the count
735735
std::string flag_description = "") {
736736
flag_count = 0;
737737
CLI::callback_t fun = [&flag_count](const CLI::results_t &res) {
@@ -754,7 +754,7 @@ class App {
754754
!std::is_constructible<std::function<void(int)>, T>::value,
755755
detail::enabler> = detail::dummy>
756756
Option *add_flag(std::string flag_name,
757-
T &flag_result, ///< A variable holding true if passed
757+
T &flag_result, ///< A variable holding true if passed
758758
std::string flag_description = "") {
759759

760760
CLI::callback_t fun = [&flag_result](const CLI::results_t &res) {
@@ -768,7 +768,7 @@ class App {
768768
typename T,
769769
enable_if_t<!std::is_assignable<std::function<void(std::int64_t)>, T>::value, detail::enabler> = detail::dummy>
770770
Option *add_flag(std::string flag_name,
771-
std::vector<T> &flag_results, ///< A vector of values with the flag results
771+
std::vector<T> &flag_results, ///< A vector of values with the flag results
772772
std::string flag_description = "") {
773773
CLI::callback_t fun = [&flag_results](const CLI::results_t &res) {
774774
bool retval = true;
@@ -785,7 +785,7 @@ class App {
785785

786786
/// Add option for callback that is triggered with a true flag and takes no arguments
787787
Option *add_flag_callback(std::string flag_name,
788-
std::function<void(void)> function, ///< A function to call, void(void)
788+
std::function<void(void)> function, ///< A function to call, void(void)
789789
std::string flag_description = "") {
790790

791791
CLI::callback_t fun = [function](const CLI::results_t &res) {
@@ -801,7 +801,7 @@ class App {
801801

802802
/// Add option for callback with an integer value
803803
Option *add_flag_function(std::string flag_name,
804-
std::function<void(std::int64_t)> function, ///< A function to call, void(int)
804+
std::function<void(std::int64_t)> function, ///< A function to call, void(int)
805805
std::string flag_description = "") {
806806

807807
CLI::callback_t fun = [function](const CLI::results_t &res) {
@@ -817,7 +817,7 @@ class App {
817817
#ifdef CLI11_CPP14
818818
/// Add option for callback (C++14 or better only)
819819
Option *add_flag(std::string flag_name,
820-
std::function<void(std::int64_t)> function, ///< A function to call, void(std::int64_t)
820+
std::function<void(std::int64_t)> function, ///< A function to call, void(std::int64_t)
821821
std::string flag_description = "") {
822822
return add_flag_function(std::move(flag_name), std::move(function), std::move(flag_description));
823823
}
@@ -826,8 +826,8 @@ class App {
826826
/// Add set of options (No default, temp reference, such as an inline set) DEPRECATED
827827
template <typename T>
828828
Option *add_set(std::string option_name,
829-
T &member, ///< The selected member of the set
830-
std::set<T> options, ///< The set of possibilities
829+
T &member, ///< The selected member of the set
830+
std::set<T> options, ///< The set of possibilities
831831
std::string option_description = "") {
832832

833833
Option *opt = add_option(option_name, member, std::move(option_description));
@@ -838,8 +838,8 @@ class App {
838838
/// Add set of options (No default, set can be changed afterwards - do not destroy the set) DEPRECATED
839839
template <typename T>
840840
Option *add_mutable_set(std::string option_name,
841-
T &member, ///< The selected member of the set
842-
const std::set<T> &options, ///< The set of possibilities
841+
T &member, ///< The selected member of the set
842+
const std::set<T> &options, ///< The set of possibilities
843843
std::string option_description = "") {
844844

845845
Option *opt = add_option(option_name, member, std::move(option_description));
@@ -850,8 +850,8 @@ class App {
850850
/// Add set of options (with default, static set, such as an inline set) DEPRECATED
851851
template <typename T>
852852
Option *add_set(std::string option_name,
853-
T &member, ///< The selected member of the set
854-
std::set<T> options, ///< The set of possibilities
853+
T &member, ///< The selected member of the set
854+
std::set<T> options, ///< The set of possibilities
855855
std::string option_description,
856856
bool defaulted) {
857857

@@ -863,8 +863,8 @@ class App {
863863
/// Add set of options (with default, set can be changed afterwards - do not destroy the set) DEPRECATED
864864
template <typename T>
865865
Option *add_mutable_set(std::string option_name,
866-
T &member, ///< The selected member of the set
867-
const std::set<T> &options, ///< The set of possibilities
866+
T &member, ///< The selected member of the set
867+
const std::set<T> &options, ///< The set of possibilities
868868
std::string option_description,
869869
bool defaulted) {
870870

@@ -932,7 +932,7 @@ class App {
932932
// Remove existing config if present
933933
if(config_ptr_ != nullptr) {
934934
remove_option(config_ptr_);
935-
config_ptr_ = nullptr; // need to remove the config_ptr completely
935+
config_ptr_ = nullptr; // need to remove the config_ptr completely
936936
}
937937

938938
// Only add config if option passed
@@ -1107,7 +1107,7 @@ class App {
11071107
for(auto &sub : subcommands_) {
11081108
cnt += sub->count_all();
11091109
}
1110-
if(!get_name().empty()) { // for named subcommands add the number of times the subcommand was called
1110+
if(!get_name().empty()) { // for named subcommands add the number of times the subcommand was called
11111111
cnt += parsed_;
11121112
}
11131113
return cnt;
@@ -1881,7 +1881,7 @@ class App {
18811881
app->name_.clear();
18821882
}
18831883
if(app->name_.empty()) {
1884-
app->fallthrough_ = false; // make sure fallthrough_ is false to prevent infinite loop
1884+
app->fallthrough_ = false; // make sure fallthrough_ is false to prevent infinite loop
18851885
app->prefix_command_ = false;
18861886
}
18871887
// make sure the parent is set to be this object in preparation for parse
@@ -2657,14 +2657,14 @@ class App {
26572657
int max_num = op->get_items_expected_max();
26582658

26592659
// Make sure we always eat the minimum for unlimited vectors
2660-
int collected = 0; // total number of arguments collected
2661-
int result_count = 0; // local variable for number of results in a single arg string
2660+
int collected = 0; // total number of arguments collected
2661+
int result_count = 0; // local variable for number of results in a single arg string
26622662
// deal with purely flag like things
26632663
if(max_num == 0) {
26642664
auto res = op->get_flag_value(arg_name, value);
26652665
op->add_result(res);
26662666
parse_order_.push_back(op.get());
2667-
} else if(!value.empty()) { // --this=value
2667+
} else if(!value.empty()) { // --this=value
26682668
op->add_result(value, result_count);
26692669
parse_order_.push_back(op.get());
26702670
collected += result_count;
@@ -2685,11 +2685,11 @@ class App {
26852685
collected += result_count;
26862686
}
26872687

2688-
if(min_num > collected) { // if we have run out of arguments and the minimum was not met
2688+
if(min_num > collected) { // if we have run out of arguments and the minimum was not met
26892689
throw ArgumentMismatch::TypedAtLeast(op->get_name(), min_num, op->get_type_name());
26902690
}
26912691

2692-
if(max_num > collected || op->get_allow_extra_args()) { // we allow optional arguments
2692+
if(max_num > collected || op->get_allow_extra_args()) { // we allow optional arguments
26932693
auto remreqpos = _count_remaining_positionals(true);
26942694
// we have met the minimum now optionally check up to the maximum
26952695
while((collected < max_num || op->get_allow_extra_args()) && !args.empty() &&
@@ -2866,7 +2866,7 @@ class App {
28662866
throw OptionNotFound("could not locate the given Option");
28672867
}
28682868
}
2869-
}; // namespace CLI
2869+
}; // namespace CLI
28702870

28712871
/// Extension of App to better manage groups of options
28722872
class Option_group : public App {
@@ -3050,7 +3050,7 @@ inline std::string help(const App *app, const Error &e) {
30503050
return header;
30513051
}
30523052

3053-
} // namespace FailureMessage
3053+
} // namespace FailureMessage
30543054

30553055
namespace detail {
30563056
/// This class is simply to allow tests access to App's protected functions
@@ -3072,6 +3072,6 @@ struct AppFriend {
30723072
/// Wrap the fallthrough parent function to make sure that is working correctly
30733073
static App *get_fallthrough_parent(App *app) { return app->_get_fallthrough_parent(); }
30743074
};
3075-
} // namespace detail
3075+
} // namespace detail
30763076

3077-
} // namespace CLI
3077+
} // namespace CLI

include/CLI/Config.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ inline void checkParentSegments(std::vector<ConfigItem> &output, const std::stri
160160
output.back().parents = std::move(parents);
161161
output.back().name = "++";
162162
}
163-
} // namespace detail
163+
} // namespace detail
164164

165165
inline std::vector<ConfigItem> ConfigBase::from_config(std::istream &input) const {
166166
std::string line;
@@ -343,4 +343,4 @@ ConfigBase::to_config(const App *app, bool default_also, bool write_description,
343343
return out.str();
344344
}
345345

346-
} // namespace CLI
346+
} // namespace CLI

include/CLI/ConfigFwd.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ class ConfigTOML : public ConfigINI {
128128
valueDelimiter = '=';
129129
}
130130
};
131-
} // namespace CLI
131+
} // namespace CLI

0 commit comments

Comments
 (0)