Commit b856c0ba9c564050cf0449d2b34d21f56c9862ae
Committed by
Henry Schreiner
1 parent
93c90d1d
Add cpplint to CI (#400)
* Add cpplint config file * Add cpplint to CI * Add checks * Add docker container tag * Unindent container As suggested in code review Co-Authored-By: Henry Schreiner <HenrySchreinerIII@gmail.com> * Fix cpplint issues * Fix clang-format * Include and fix modern cpplint runtime/int * Include and fix cpplint build/include_order * Revert "Include and fix cpplint build/include_order" This reverts commit bddb6a2d6744c5397f387ccd03416a1ec5e29862. * Update explanation, sort alphabetically * Implement suggestion from code review Co-Authored-By: Henry Schreiner <HenrySchreinerIII@gmail.com> * Include cstdint header, prefix its symbols with std:: * Forgot std:: Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Showing
7 changed files
with
34 additions
and
12 deletions
CPPLINT.cfg
0 → 100644
| 1 | +set noparent | |
| 2 | +linelength=120 # As in .clang-format | |
| 3 | + | |
| 4 | +# Non-used filters | |
| 5 | +filter=-build/include_order # Requires unusual include order that encourages creating not self-contained headers | |
| 6 | +filter=-readability/nolint # Conficts with clang-tidy | |
| 7 | +filter=-runtime/references # Requires fundamental change of API, don't see need for this | |
| 8 | +filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability | |
| 9 | +filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format | |
| 10 | + | |
| 11 | +# Filters to be included in future | |
| 12 | +filter=-whitespace/indent,-whitespace/comments,-readability/braces,-build/include_what_you_use | |
| 13 | +filter=-legal/copyright # Remove this line after Version 1.9 | |
| 14 | + | ... | ... |
azure-pipelines.yml
| ... | ... | @@ -31,6 +31,14 @@ jobs: |
| 31 | 31 | - script: git diff --exit-code --color |
| 32 | 32 | displayName: Check tidy |
| 33 | 33 | |
| 34 | +- job: CppLint | |
| 35 | + pool: | |
| 36 | + vmImage: 'ubuntu-latest' | |
| 37 | + container: sharaku/cpplint:latest | |
| 38 | + steps: | |
| 39 | + - bash: cpplint --counting=detailed --recursive examples include/CLI | |
| 40 | + displayName: Checking against google style guide | |
| 41 | + | |
| 34 | 42 | # TODO: Fix macOS error and windows warning in c++17 mode |
| 35 | 43 | - job: Native |
| 36 | 44 | strategy: |
| ... | ... | @@ -97,4 +105,3 @@ jobs: |
| 97 | 105 | - template: .ci/azure-cmake.yml |
| 98 | 106 | - template: .ci/azure-build.yml |
| 99 | 107 | - template: .ci/azure-test.yml |
| 100 | - | ... | ... |
examples/subcom_in_files/subcommand_a.hpp
include/CLI/App.hpp
| ... | ... | @@ -2657,9 +2657,7 @@ class App { |
| 2657 | 2657 | auto res = op->get_flag_value(arg_name, value); |
| 2658 | 2658 | op->add_result(res); |
| 2659 | 2659 | parse_order_.push_back(op.get()); |
| 2660 | - } | |
| 2661 | - // --this=value | |
| 2662 | - else if(!value.empty()) { | |
| 2660 | + } else if(!value.empty()) { // --this=value | |
| 2663 | 2661 | op->add_result(value, result_count); |
| 2664 | 2662 | parse_order_.push_back(op.get()); |
| 2665 | 2663 | collected += result_count; | ... | ... |
include/CLI/Timer.hpp
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #endif |
| 11 | 11 | |
| 12 | 12 | #include <array> |
| 13 | -#include <chrono> | |
| 13 | +#include <chrono> // NOLINT(build/c++11) | |
| 14 | 14 | #include <functional> |
| 15 | 15 | #include <iostream> |
| 16 | 16 | #include <string> |
| ... | ... | @@ -87,8 +87,9 @@ class Timer { |
| 87 | 87 | /// This prints out a time string from a time |
| 88 | 88 | std::string make_time_str(double time) const { |
| 89 | 89 | auto print_it = [](double x, std::string unit) { |
| 90 | - std::array<char, 50> buffer; | |
| 91 | - std::snprintf(buffer.data(), 50, "%.5g", x); | |
| 90 | + const unsigned int buffer_length = 50; | |
| 91 | + std::array<char, buffer_length> buffer; | |
| 92 | + std::snprintf(buffer.data(), buffer_length, "%.5g", x); | |
| 92 | 93 | return buffer.data() + std::string(" ") + unit; |
| 93 | 94 | }; |
| 94 | 95 | ... | ... |
include/CLI/TypeTools.hpp
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | // file LICENSE or https://github.com/CLIUtils/CLI11 for details. |
| 5 | 5 | |
| 6 | 6 | #include "StringTools.hpp" |
| 7 | +#include <cstdint> | |
| 7 | 8 | #include <exception> |
| 8 | 9 | #include <memory> |
| 9 | 10 | #include <string> |
| ... | ... | @@ -595,9 +596,9 @@ template <typename T, |
| 595 | 596 | bool lexical_cast(const std::string &input, T &output) { |
| 596 | 597 | try { |
| 597 | 598 | std::size_t n = 0; |
| 598 | - long long output_ll = std::stoll(input, &n, 0); | |
| 599 | + std::int64_t output_ll = std::stoll(input, &n, 0); | |
| 599 | 600 | output = static_cast<T>(output_ll); |
| 600 | - return n == input.size() && static_cast<long long>(output) == output_ll; | |
| 601 | + return n == input.size() && static_cast<std::int64_t>(output) == output_ll; | |
| 601 | 602 | } catch(const std::invalid_argument &) { |
| 602 | 603 | return false; |
| 603 | 604 | } catch(const std::out_of_range &) { |
| ... | ... | @@ -614,9 +615,9 @@ bool lexical_cast(const std::string &input, T &output) { |
| 614 | 615 | |
| 615 | 616 | try { |
| 616 | 617 | std::size_t n = 0; |
| 617 | - unsigned long long output_ll = std::stoull(input, &n, 0); | |
| 618 | + std::uint64_t output_ll = std::stoull(input, &n, 0); | |
| 618 | 619 | output = static_cast<T>(output_ll); |
| 619 | - return n == input.size() && static_cast<unsigned long long>(output) == output_ll; | |
| 620 | + return n == input.size() && static_cast<std::uint64_t>(output) == output_ll; | |
| 620 | 621 | } catch(const std::invalid_argument &) { |
| 621 | 622 | return false; |
| 622 | 623 | } catch(const std::out_of_range &) { | ... | ... |
include/CLI/Validators.hpp