Repository navigation
test: end-to-end check of cpp-linter-action#501 with clang-tools 2.0.0 - #65
shenxianpeng wants to merge 3 commits into
Conversation
Cpp-Linter Report
|
There was a problem hiding this comment.
Cpp-linter Review
Used clang-tidy v20.1.2
Only 6 out of 13 clang-tidy concerns fit within this pull request's diff.
Click here for the full clang-tidy patch
diff --git a/src/demo.cpp b/src/demo.cpp
--- a/src/demo.cpp
+++ b/src/demo.cpp
@@ -7 +7 @@
-size_t dummyFunc(size_t i) { return i; }
+static auto dummyFunc(size_t i) -> size_t { return i; }
@@ -9 +9 @@ size_t dummyFunc(size_t i) { return i; }
-int main()
+auto main() -> int
@@ -11 +11 @@ int main()
- for (;;)
+ for (;;) {
@@ -12,0 +13 @@ int main()
+ }
@@ -20 +21 @@ int main()
-int addNumbers(int a, int b)
+static auto addNumbers(int a, int b) -> int
@@ -22,2 +23,2 @@ int addNumbers(int a, int b)
- int* unused = NULL;
- if (a > b)
+ int* unused = nullptr;
+ if (a > b) {
@@ -24,0 +26 @@ int addNumbers(int a, int b)
+ }
@@ -29 +31 @@ int addNumbers(int a, int b)
-int subtract(int x, int y) { return x - y; }
+static auto subtract(int x, int y) -> int { return x - y; }
@@ -32 +34 @@ int subtract(int x, int y) { return x - y; }
-int multiply( int x,int y ){return x*y;}
+static auto multiply(int x, int y) -> int { return x * y; }
Used clang-format v20.1.2
Click here for the full clang-format patch
diff --git a/src/demo.cpp b/src/demo.cpp
--- a/src/demo.cpp
+++ b/src/demo.cpp
@@ -32 +32 @@ int subtract(int x, int y) { return x - y; }
-int multiply( int x,int y ){return x*y;}
+int multiply(int x, int y) { return x * y; }
✨ Powered by cpp-linter -- ⭐ Star • ❤️ Sponsor • 💬 Feedback
| int subtract(int x, int y) { return x - y; } | ||
|
|
||
| // round 2: badly formatted on purpose (temporary) | ||
| int multiply( int x,int y ){return x*y;} |
There was a problem hiding this comment.
clang-format suggestion
| int multiply( int x,int y ){return x*y;} | |
| int multiply(int x, int y) { return x * y; } |
clang-tidy diagnostics
- function 'multiply' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
- use a trailing return type for this function [modernize-use-trailing-return-type]
| int multiply( int x,int y ){return x*y;} | |
| static auto multiply(int x, int y) -> int { return x * y; } |
| #include <cstdio> | ||
|
|
||
| // using size_t from cstddef | ||
| size_t dummyFunc(size_t i) { return i; } |
There was a problem hiding this comment.
clang-tidy diagnostics
- function 'dummyFunc' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
- use a trailing return type for this function [modernize-use-trailing-return-type]
| size_t dummyFunc(size_t i) { return i; } | |
| static auto dummyFunc(size_t i) -> size_t { return i; } |
| } | ||
|
|
||
| // added to test cpp-linter-action#501 (temporary) | ||
| int addNumbers(int a, int b) |
There was a problem hiding this comment.
clang-tidy diagnostics
- function 'addNumbers' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
- use a trailing return type for this function [modernize-use-trailing-return-type]
| int addNumbers(int a, int b) | |
| static auto addNumbers(int a, int b) -> int |
clang-tidy diagnostic
src/demo.cpp:20:20: warning: [readability-identifier-length]
parameter name 'a' is too short, expected at least 3 characters
20 | int addNumbers(int a, int b)
| ^clang-tidy diagnostic
src/demo.cpp:20:27: warning: [readability-identifier-length]
parameter name 'b' is too short, expected at least 3 characters
20 | int addNumbers(int a, int b)
| ^| int* unused = NULL; | ||
| if (a > b) |
There was a problem hiding this comment.
clang-tidy diagnostics
- use nullptr [modernize-use-nullptr]
- statement should be inside braces [readability-braces-around-statements]
| int* unused = NULL; | |
| if (a > b) | |
| int* unused = nullptr; | |
| if (a > b) { |
| if (a > b) | ||
| return a + b; | ||
| return b + a; | ||
| } |
There was a problem hiding this comment.
clang-tidy suggestion
| } | |
| } |
| } | ||
|
|
||
| // second round (temporary) | ||
| int subtract(int x, int y) { return x - y; } |
There was a problem hiding this comment.
clang-tidy diagnostics
- function 'subtract' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
- use a trailing return type for this function [modernize-use-trailing-return-type]
| int subtract(int x, int y) { return x - y; } | |
| static auto subtract(int x, int y) -> int { return x - y; } |
clang-tidy diagnostic
src/demo.cpp:29:18: warning: [readability-identifier-length]
parameter name 'x' is too short, expected at least 3 characters
29 | int subtract(int x, int y) { return x - y; }
| ^clang-tidy diagnostic
src/demo.cpp:29:25: warning: [readability-identifier-length]
parameter name 'y' is too short, expected at least 3 characters
29 | int subtract(int x, int y) { return x - y; }
| ^
Temporary PR, do not merge. It runs cpp-linter-action at cpp-linter/cpp-linter-action@fc065f1 (#501 head: cpp-linter 1.15.1, plus clang-tools 2.0.0) on a pull request, to check PR reviews, thread comments, annotations and auto-fix. It is not a draft because the action skips reviews on draft PRs. Close it after the test.