Commit Graph

600 Commits

Author SHA1 Message Date
Pranav
7f11534e39
Merge pull request #163 from skrobinson/wip-disable-sa
Remove StaticAnalysis Action
2022-03-28 18:00:27 -05:00
Sean Robinson
eaa8214962 Remove StaticAnalysis Action
I am seeing too many errors due to bad tool configuration, not from
problems in project code.  So, disable SA until I can make it work more
reliably.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-28 13:03:05 -07:00
Sean Robinson
67d2e4476f Annotate range-for loops' structured bindings as [[maybe_unused]]
The 'unused' variable in both cases is most-definitely unused in the loop.
This is a cppcheck warning that appeared after moving these two loops to
range-for.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-24 14:21:14 -07:00
Sean Robinson
843e4eefb0 Move ArgumentParser::parse_args_validate logic into ::parse_args
This code was previously moved from ::parse_args to its own method, but
has since been simplified.  Moving the actual work to Argument::validate
in commit 603e87ae6 leaves a single loop that fits back into ::parse_args.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-24 14:19:20 -07:00
Sean Robinson
063d708c3e Modify ArgumentParser::get_length_of_longest_argument method run in O(1) space
Closes #124

Reported-by: Aayush Anand <aaayushanand5@gmail.com>
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-23 15:02:42 -07:00
Aayush Anand
0d868fdca8 Modify ArgumentParser::parse_args_validate() method to use a for loop instead of std::for_each()
Suggested-by: Aayush Anand <aaayushanand5@gmail.com>
[skrobinson: Updated for latest formatting and naming conventions]
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-03-23 15:02:42 -07:00
Pranav
cba0a1b3c7
Merge pull request #160 from skrobinson/wip-tidy
Enable clang-tidy readability-braces-around-statements check
2022-03-23 16:55:52 -05:00
Pranav
c20621489d
Merge pull request #157 from Sam4uk/cmake_edit
edit CMakeLists.txt
2022-02-23 21:21:45 +05:30
Sean Robinson
ce3c43eb9b Rename identifiers
There are no functional changes in this commit.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-10 09:41:20 -07:00
Sean Robinson
985ea8666d Update identifier names for structs
The new naming pattern is CamelCase for structs, except parse_number as a
primarily callable interface.  Trait structs are named Has*Traits
and constexpr variables to the struct template are named Is*.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
c50346c1df Remove is_representable_v trait
This trait is unused and removing it does not cause any tests to fail.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
cb2777db6e Update header source format with clang-format
Most changes are to better fit within "ColumnLimit: 80".

The change from "T &&... var" to "T &&...var" is caused by
"PointerAlignment: Right".

Member functions chained from add_argument() use ContinuationIndentWidth,
which is set to 4.  Setting ContinuationIndentWidth to 2 causes many
other continuation lines to change.  So, this commit uses the original
value (i.e. 4) as the preferred size.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
486bfdaf8d Update clang-format configuration standard to C++17
The "Cpp11" alias is deprecated for Latest (a rolling standard).  For now,
stick to C++17.

Includes end-of-line whitespace removal.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
a915728da0 Enable clang-tidy cppcoreguidelines-avoid-c-arrays check
Also converts most C-style arrays to a std::array onjects.  The check is
disabled for ArgumentParser::parse_args(int, const char *const[]) as this
is a helper function to convert away from a common input format.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
6564839971 Enable clang-tidy readability-function-cognitive-complexity check
The two functions previously flagged by this check,
Argument::is_decimal_literal and Argument::validate, fell below the
default Cognitive Complexity threshold as a result of the branch
simplification for the readability-else-after-return check.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
d0a492ccba Enable clang-tidy readability-else-after-return check
A common pattern in the previous code was goto/return/throw if a condition
is true, else goto/return/throw something different.  The new pattern
uses the fact that the second goto/return/throw is only reachable when the
first goto/return/throw is not called.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
3c317ddd2d Enable clang-tidy clang-analyzer default checks
Surprisingly, no fixes are required in argparse when turning on this suite
of checks.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
0b74da54d4 Enable clang-tidy cppcoreguidelines-special-member-functions check
Also adds a default destructor, as recommended by the check.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
c25a959597 Enable clang-tidy readability-static-accessed-through-instance check
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:53:08 -07:00
Sean Robinson
bd4837f240 Enable clang-tidy's readability-qualified-auto check
Following the clang-tidy suggested fix in consume_digits causes compile
failures with MSVC 19.29 in our CI.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 15:27:16 -07:00
Sean Robinson
b5fb663bc8 Enable clang-tidy readability-named-parameter check
Adds names recommended by clang-tidy (e.g. "unused").

Note that clang-tidy v12 appears to detect unnamed parameters in lambdas,
while clang-tidy v13 does not.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-09 14:05:21 -07:00
Sean Robinson
9eb1fe5cef Enable clang-tidy readability-magic-numbers check
Adds names for integer bases used with details::parse_number.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-07 14:29:25 -07:00
Sean Robinson
b918763adf Enable clang-tidy readability-implicit-bool-conversion check
Enabling this check caught the implicit bool conversion with
default_arguments::operator& fixed in the previous commit.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-07 14:27:06 -07:00
Sean Robinson
7cbc66f65b Return default_arguments from operator& of two default_arguments
operator& should return combined values of the same type, not a new type
(i.e. bool).  This is much more verbose, but easier to reason about
without implied conversion.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-07 14:27:06 -07:00
Sean Robinson
6a8b1318ec Enable clang-tidy readability-container-size-empty check
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-07 14:27:06 -07:00
Sean Robinson
158b8a0d2f Enable clang-tidy readability-braces-around-statements check
All tests still pass.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-07 13:10:03 -07:00
Sam4uk
06f687b594
update cmake_minimum_required to 3.12.4 2022-02-07 22:09:36 +02:00
Pranav
419648bf74
Merge pull request #158 from skrobinson/fix-SA-runner
Refactor configuration for StaticAnalysis
2022-02-07 13:04:53 -06:00
Sean Robinson
97204363b5 Refactor configuration for StaticAnalysis
Upstream StaticAnalysis looks to be changing for more flexibility with
source files to process.  While these changes may eventually benefit
argparse, the public interfaces are in flux and we need a stable tool.
argparse also needs a SA change which is not yet upstream.

Trying to run clang-tidy via StaticAnalysis on a single file in a
directory with many source file is not easy, so move the analysis kernel
to a location (i.e. tools) where it is the only C++ source file.

Another benefit is cppcheck no longer needs to be told to ignore the test
sources.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-02-07 11:51:22 -07:00
Sam4uk
5a1b4c3068 edit CMakeLists.txt 2022-02-04 23:36:26 +02:00
Pranav
79df7808d2
Merge pull request #155 from skrobinson/fix-test-server-deprecation
Remove Windows Server 2016 from test matrix
2022-01-11 09:40:13 -06:00
Sean Robinson
736099ef3f Remove Windows Server 2016 from test matrix
The Windows Server 2016 test environment is scheduled for removal on
March 15, 2022.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-01-11 08:33:41 -07:00
Pranav
fcfbe7141e
Merge pull request #148 from skrobinson/feat-add-sa-pr-action
Add StaticAnalysis PR Action
2022-01-11 09:11:10 -06:00
Sean Robinson
6246a9df0e Change Static Analysis trigger event to pull_request_target
The GH security model restricts comment posting from PR actions.
StaticAnalysis has added support for pull_request_target to mitigate
risks while still allowing comments by the bot.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2022-01-11 06:48:00 -07:00
Sean Robinson
c0bbcf613c Remove sentry check in ArgumentParser::operator<<
cppcheck reports "Variable 'sen' is assigned a value that is never used.
[unreadVariable]" for this line.

As far as I understand, std::ostream::sentry is used to prepare access to
the stream buffer.  But, we are never directly accessing the stream
buffer.  Stream access in this function uses other operator<< functions.

Most noise in this patch is about unindenting after if() removal.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-11-10 13:54:35 -07:00
Sean Robinson
abb2206141 Declare lambda parameter and ArgumentParser::print_help as const
These were respectively reported as constParameter and functionConst
style issues by cppcheck.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-11-10 13:54:33 -07:00
Sean Robinson
6530a06747 Copy more members in ArgumentParser copy constructor
This showed as a cppcheck warning: uninitMemberVar.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-11-10 13:54:31 -07:00
Sean Robinson
8d8282bac3 Add Static Analysis action to run on Pull Request
Unit test source files are not currently checked.  Hopefully, these can
be added so that all source files in a pull request are verified.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-11-10 13:54:29 -07:00
Sean Robinson
9a9c3042aa Add a clang-tidy configuration file
This file matches the current practices of the argparse project.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-11-10 13:54:27 -07:00
Sean Robinson
18a229e849 Add a minimal binary to generate compile_commands.json file
clang-tidy needs compile_commands.json to generate a set of source files
to parse.  tidy-base is not built but is used as a source file in which
included headers can be parsed.  Without this process, clang-tidy will
process many other source files (e.g. doctest.hpp) that we do not want
to worry about.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-11-10 13:54:25 -07:00
Pranav
4cacdc4b30
Merge pull request #147 from MaciejPatro/master
Improve thrown message in case of invalid argument.
2021-11-09 12:44:40 -06:00
Maciej Patro
87afaba6ba Improve thrown message in case of invalid argument.
Now message contains information which argument is the source of error.
It's easier to spot typo/understand which part of more complex command
is the source of problem.
2021-11-05 09:56:17 +01:00
Pranav
b9583b42ab
Merge pull request #146 from p-ranav/update_readme_stdout_to_stderr
Update readme stdout to stderr
2021-11-03 08:34:40 -05:00
Pranav Srinivas Kumar
6f1a90f101 Removed duplicate entry for Daniel Marshall 2021-11-03 08:31:09 -05:00
Ashwin Rohit
2e25423db8 Modify README.md to show printing errors to stderr instead of stdout 2021-11-03 08:29:56 -05:00
Pranav
9c729f54b1
Updated contributors 2021-10-31 17:34:51 -05:00
Pranav
10190c89dc
Merge pull request #144 from aashwinr/update_err
Modify README.md to show printing errors to stderr instead of stdout
2021-10-31 17:22:32 -05:00
Ashwin Rohit
2c55a2e423 Modify README.md to show printing errors to stderr instead of stdout 2021-10-31 12:29:19 -07:00
Pranav
b98bf25a34
Merge pull request #142 from skrobinson/wip-deactivatable-defaults
Actions with nonary arguments, removable defaults, and some clean ups
2021-10-27 12:52:29 -05:00
Sean Robinson
5cceb98e3c Update "Printing Help" documentation
Help output has changed format over time.  This updates the README
example to reflect current practice by running the example code
and copy-pasting its output.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
2021-10-27 09:02:33 -07:00