Commit Graph

13 Commits

Author SHA1 Message Date
Henri Chataing
6e3bc74cc4 all: Pass clang-tidy modernize-unary-static-assert check
Change-Id: If8c3e0d150c85713264fccbe6d2aca906b85bd18
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/56924
Commit-Queue: Henri Chataing <henrichataing@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2022-08-10 20:09:28 +00:00
Ted Pudlik
26c7a13320 clang-tidy: Enable modernize-use-override
Fixes: b/234876269
Change-Id: Idd4ad75e571ac464d253ef9497759d31c5ade7b1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/100160
Pigweed-Auto-Submit: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Ted Pudlik <tpudlik@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
2022-06-29 21:10:34 +00:00
Ted Pudlik
c8b15bfe12 clang-tidy: Re-enable accidentally disabled checks
Missing commas in the config file!

Change-Id: I4730741cb714aaa2cdf1215151bbc367c5b5a735
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/83565
Pigweed-Auto-Submit: Ted Pudlik <tpudlik@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
2022-02-09 18:22:54 +00:00
Ted Pudlik
e480df97b2 clang-tidy: Enforce google-global-names-in-headers
I remove the alias altogether because it appears inconsistent with the
style guide: "Don't put an alias in your public API just to save typing
in the implementation; do so only if you intend it to be used by your
clients." (https://google.github.io/styleguide/cppguide.html#Aliases).

Bug: 45
Change-Id: Ie9878250ca34387241d70d4261e9269147d8dcb6
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/68084
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Ted Pudlik <tpudlik@google.com>
2021-11-10 19:16:31 +00:00
Ted Pudlik
7c295d2c54 clang-tidy: Explicity list enforced checks
This is a no-op change: I switch from excluding certain modernize-
checks to explicitly including.  I think this is clearer (since it shows
what we actually enforce).  The list was generated using `clang-tidy
-list-checks`.

Bug: 45
Change-Id: Ie477d330ca2a2867f8f2edafb865d489478cf562
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66900
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Ted Pudlik <tpudlik@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
2021-10-30 00:49:59 +00:00
Ted Pudlik
4180d4de9a clang-tidy: readability-inconsistent-declaration-parameter-name
This check verifies that the parameter names used in the function
declarations and definitions match. The fix involves changing either the
declaration or the definition; I chose to do one or the other on a case
by case basis.  My guiding principles were (1) use the same names for
the same parameter in different functions in the same header, and (2)
generally prefer to retain the name in the header over that in the
source file (since it's more public), especially if that name also
appears in a documenting comment on the function.

Bug: 45
No-Docs-Update-Reason: clang-tidy change only.
Change-Id: I1f1c8b421923e0ef692086138ea8df0a7d5d11c3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66640
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Ted Pudlik <tpudlik@google.com>
2021-10-28 22:20:23 +00:00
Ted Pudlik
10ec2bd207 clang-tidy: readability-container-size-empty
Enable readability-container-size-empty, after fixing all violations.

Also, exclude some additional source/header files from clang-tidy.

Bug: 45
No-Docs-Update-Reason: clang-tidy change only.
Change-Id: I205f27051b804d652ff00d9c8964b2492975e762
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66621
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Ali Zhang <alizhang@google.com>
Commit-Queue: Ted Pudlik <tpudlik@google.com>
2021-10-28 19:10:34 +00:00
Ted Pudlik
6d642e4a14 clang-tidy: Fix and enforce additional checks
This fixes all violations of the following checks, and turns on their
enforcement:

*   bugprone-argument-comment
*   bugprone-fold-init-type
*   bugprone-move-forwarding-reference
*   bugprone-string-constructor
*   bugprone-use-after-move

Bug: 45
No-Docs-Update-Reason: clang-tidy change only.
Change-Id: Ifd1f46161aba3ae4c37983f6707d6a5259a40e3f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66444
Commit-Queue: Ted Pudlik <tpudlik@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
2021-10-28 16:49:43 +00:00
Ted Pudlik
585a0c59ef clang-tidy: Enable misc-unused-using-decls
Bug: 45
No-Docs-Update-Reason: clang-tidy change only.
Change-Id: I9e99afcfc8a20feb46c986203977bc23c40a28fb
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66620
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Ted Pudlik <tpudlik@google.com>
2021-10-28 01:14:30 +00:00
Ted Pudlik
17d5e71d27 Enable additional clang-tidy checks
These checks are all fast, worthwhile, and currently pass.

Also update comment in static_analysis_toolchain.gni.

Runtime impact: On my workstation I ran,

    for i in 1 2 3;
    do gn clean out; gn gen out; time ninja -C out static_analysis;
    done

with and without this change.  The mean CPU time (user+sys) increased by
about 25%, from 559 s to 707 s.  I think this is acceptable.

No-Docs-Update-Reason: We do not currently discuss in the documentation which clang-tidy checks are run for upstream pigweed itself.
Change-Id: If28652ecbd3ca6c876e6942d08d24a30717e8294
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66440
Commit-Queue: Ted Pudlik <tpudlik@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
2021-10-25 23:19:50 +00:00
Ted Pudlik
36986c0d87 Remove outdated comment
Change-Id: I2e2ba663ebe75004a13ee3ba65e80da6f85711d7
No-Docs-Update-Reason: clang-tidy config change only.
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66246
Commit-Queue: Ted Pudlik <tpudlik@google.com>
Pigweed-Auto-Submit: Ted Pudlik <tpudlik@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2021-10-21 00:47:43 +00:00
Henri Chataing
77f2f358c3 all: Pass clang-tidy modernize-use-bool-literals check
Change-Id: Iddf04fac95d04a4816a0d1d022f04450679377af
No-Docs-Update-Reason: Format fixes
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/56925
Commit-Queue: Henri Chataing <henrichataing@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2021-08-30 12:52:25 +00:00
Henri Chataing
f06e42b039 pw_presubmit: Fix clang_tidy pass
- Implement workarounds to fix system include paths in
  generated compile_commands.json files: clang-tidy is otherwise
  often unable to find some system headers.
- Add basic .clang-tidy configuration
- To run the pass in pigweed presubmits:
  pw presubmit --step clang_tidy
  pw presubmit -p other_checks

Bug: 45
No-Docs-Update-Reason: Fix in internal API
Change-Id: I3f6cae98bfecaff86543804b28083bf304ad6a60
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/55000
Commit-Queue: Henri Chataing <henrichataing@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2021-08-09 16:01:28 +00:00