Repository navigation
test: rc.29 e2e (new: cpp-linter 2.0.0rc29) - #89
shenxianpeng wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
cpp-linter review
7 comments (clang-format 23.1.6, clang-tidy 23.1.6)
Some findings could not be posted as suggestions:
- stress/latin1.cpp: 1 fix is only in the patch file because the file is not UTF-8 encoded
Powered by cpp-linter | Feedback
| @@ -0,0 +1 @@ | |||
| int top_dash( ){return 1;} | |||
There was a problem hiding this comment.
Warning: misc-use-internal-linkage
function 'top_dash' can be made static or moved into an anonymous namespace to enforce internal linkage
| int top_dash( ){return 1;} | |
| static int top_dash() { return 1; } |
| total += 14; | ||
| return total; | ||
| } | ||
| // touched |
There was a problem hiding this comment.
clang-format suggests this formatting.
| // touched | |
| // touched |
| @@ -0,0 +1,2 @@ | |||
| #include "missing_lib.h" | |||
| int use_two(){return lib_value();} | |||
There was a problem hiding this comment.
Warning: misc-use-internal-linkage
function 'use_two' can be made static or moved into an anonymous namespace to enforce internal linkage
| int use_two(){return lib_value();} | |
| static int use_two() { return lib_value(); } |
| @@ -0,0 +1,2 @@ | |||
| #include "missing_lib.h" | |||
| int fixits(int x, int *p) { | ||
| if (p == 0) | ||
| return 0; | ||
| if (x > 1) | ||
| return 1; | ||
| else | ||
| return 2; |
There was a problem hiding this comment.
Warning: misc-use-internal-linkage
function 'fixits' can be made static or moved into an anonymous namespace to enforce internal linkage
Warning: misc-const-correctness
pointee of variable 'p' of type 'int *' can be declared 'const'
Warning: readability-non-const-parameter
pointer parameter 'p' can be pointer to const
Warning: readability-braces-around-statements
statement should be inside braces
Warning: readability-braces-around-statements
statement should be inside braces
Warning: readability-else-after-return
do not use 'else' after 'return'
Warning: readability-braces-around-statements
statement should be inside braces
| int fixits(int x, int *p) { | |
| if (p == 0) | |
| return 0; | |
| if (x > 1) | |
| return 1; | |
| else | |
| return 2; | |
| static int fixits(int x, const int const* p) | |
| { | |
| if (p == 0) { | |
| return 0; | |
| } | |
| if (x > 1) { | |
| return 1; | |
| } | |
| { | |
| return 2; | |
| } |
Warning: readability-identifier-length
parameter name 'x' is too short, expected at least 3 characters
Warning: readability-identifier-length
parameter name 'p' is too short, expected at least 3 characters
| int added(){ | ||
| int x=1; | ||
| printf("%d",x); | ||
| return x;} No newline at end of file |
There was a problem hiding this comment.
Warning: misc-use-internal-linkage
function 'added' can be made static or moved into an anonymous namespace to enforce internal linkage
Warning: misc-const-correctness
variable 'x' of type 'int' can be declared 'const'
| int added(){ | |
| int x=1; | |
| printf("%d",x); | |
| return x;} | |
| static int added() | |
| { | |
| int const x = 1; | |
| printf("%d", x); | |
| return x; | |
| } |
Warning: readability-identifier-length
variable name 'x' is too short, expected at least 3 characters
| int main(){ | ||
| char* p = NULL; | ||
| printf("%d\n",f(3)); return 0;} | ||
| int edited_space( ){return 1;} |
There was a problem hiding this comment.
Warning: misc-use-internal-linkage
function 'edited_space' can be made static or moved into an anonymous namespace to enforce internal linkage
| int edited_space( ){return 1;} | |
| static int edited_space() { return 1; } |
|
| Tool | Result |
|---|---|
| 7 files need formatting | |
| 1 error, 16 warnings, 13 fixable |
clang-tidy could not find 1 included file, so it likely does not know how this code is built, and its other findings may be wrong too. Generate a compilation database (with CMake: -DCMAKE_EXPORT_COMPILE_COMMANDS=ON) and pass its folder as the database option.
clang-tidy: 1 error, 16 warnings, 13 fixable
-top.cpp
| Line | Finding |
|---|---|
| 1 | function 'top_dash' can be made static or moved into an anonymous namespace to enforce internal linkage (fixable) misc-use-internal-linkage |
incdemo/use2.cpp
| Line | Finding |
|---|---|
| 1 | error: 'missing_lib.h' file not found clang-diagnostic-error |
| 2 | function 'use_two' can be made static or moved into an anonymous namespace to enforce internal linkage (fixable) misc-use-internal-linkage |
src/fixits.cpp
| Line | Finding |
|---|---|
| 1 | function 'fixits' can be made static or moved into an anonymous namespace to enforce internal linkage (fixable) misc-use-internal-linkage |
| 1 | parameter name 'x' is too short, expected at least 3 characters readability-identifier-length |
| 1 | pointee of variable 'p' of type 'int *' can be declared 'const' (fixable) misc-const-correctness |
| 1 | parameter name 'p' is too short, expected at least 3 characters readability-identifier-length |
| 1 | pointer parameter 'p' can be pointer to const (fixable) readability-non-const-parameter |
| 2 | statement should be inside braces (fixable) readability-braces-around-statements |
| 4 | statement should be inside braces (fixable) readability-braces-around-statements |
| 6 | do not use 'else' after 'return' (fixable) readability-else-after-return |
| 6 | statement should be inside braces (fixable) readability-braces-around-statements |
src/no_final_newline.cpp
| Line | Finding |
|---|---|
| 2 | function 'added' can be made static or moved into an anonymous namespace to enforce internal linkage (fixable) misc-use-internal-linkage |
| 3 | variable 'x' of type 'int' can be declared 'const' (fixable) misc-const-correctness |
| 3 | variable name 'x' is too short, expected at least 3 characters readability-identifier-length |
stress/latin1.cpp
| Line | Finding |
|---|---|
| 7 | function 'edited_latin1' can be made static or moved into an anonymous namespace to enforce internal linkage (fixable) misc-use-internal-linkage |
stress/with space.cpp
| Line | Finding |
|---|---|
| 6 | function 'edited_space' can be made static or moved into an anonymous namespace to enforce internal linkage (fixable) misc-use-internal-linkage |
clang-format: 7 files
-top.cpp, line 1cap/many.cpp, line 36incdemo/use2.cpp, line 2src/fixits.cpp, lines 1-7src/no_final_newline.cpp, lines 2-5stress/latin1.cpp, line 7stress/with space.cpp, line 6
How to fix
From the repository root, format the listed lines with clang-format 23:
clang-format -i --style=file --lines=1:1 ./-top.cpp
clang-format -i --style=file --lines=36:36 cap/many.cpp
clang-format -i --style=file --lines=2:2 incdemo/use2.cpp
clang-format -i --style=file --lines=1:7 src/fixits.cpp
clang-format -i --style=file --lines=2:5 src/no_final_newline.cpp
clang-format -i --style=file --lines=7:7 stress/latin1.cpp
clang-format -i --style=file --lines=6:6 'stress/with space.cpp'Or apply every fix at once: this step's fix-patch-path output is a patch for git apply.
For the clang-tidy findings, give this to your coding agent:
Fix these clang-tidy findings:
- -top.cpp:1:7: warning: function 'top_dash' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
- incdemo/use2.cpp:1:10: error: 'missing_lib.h' file not found [clang-diagnostic-error]
- incdemo/use2.cpp:2:5: warning: function 'use_two' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
- src/fixits.cpp:1:5: warning: function 'fixits' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
- src/fixits.cpp:1:16: warning: parameter name 'x' is too short, expected at least 3 characters [readability-identifier-length]
- src/fixits.cpp:1:19: warning: pointee of variable 'p' of type 'int *' can be declared 'const' [misc-const-correctness]
- src/fixits.cpp:1:24: warning: parameter name 'p' is too short, expected at least 3 characters [readability-identifier-length]
- src/fixits.cpp:1:24: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
- src/fixits.cpp:2:14: warning: statement should be inside braces [readability-braces-around-statements]
- src/fixits.cpp:4:13: warning: statement should be inside braces [readability-braces-around-statements]
- src/fixits.cpp:6:3: warning: do not use 'else' after 'return' [readability-else-after-return]
- src/fixits.cpp:6:7: warning: statement should be inside braces [readability-braces-around-statements]
- src/no_final_newline.cpp:2:5: warning: function 'added' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
- src/no_final_newline.cpp:3:3: warning: variable 'x' of type 'int' can be declared 'const' [misc-const-correctness]
- src/no_final_newline.cpp:3:9: warning: variable name 'x' is too short, expected at least 3 characters [readability-identifier-length]
- stress/latin1.cpp:7:7: warning: function 'edited_latin1' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
- stress/with space.cpp:6:7: warning: function 'edited_space' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
Powered by cpp-linter | Feedback
Requested by Xianpeng · project thread
Temporary pre-release test PR for cpp-linter-rs v2.0.0-rc.29 with action v3 (PR #543 head). Do not merge; close after the test.