Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-tidy入れる #56

Closed
H1rono opened this issue Jan 17, 2024 · 16 comments · Fixed by #167
Closed

clang-tidy入れる #56

H1rono opened this issue Jan 17, 2024 · 16 comments · Fixed by #167
Labels
enhancement New feature or request

Comments

@H1rono
Copy link
Member

H1rono commented Jan 17, 2024

No description provided.

@H1rono H1rono added the enhancement New feature or request label Jan 25, 2024
@H1rono
Copy link
Member Author

H1rono commented Jan 25, 2024

@H1rono H1rono mentioned this issue Jan 25, 2024
@H1rono
Copy link
Member Author

H1rono commented Mar 15, 2024

@H1rono
Copy link
Member Author

H1rono commented Mar 25, 2024

clangdの設定にはpio run -t compiledbを実行してcompile_commands.jsonを生成する必要がある

Compilation database compile_commands.json — PlatformIO latest documentation

@H1rono
Copy link
Member Author

H1rono commented Mar 27, 2024

VSCodeだと下線引いてくれないけどCLionだといい感じになる
Screenshot from 2024-03-27 10-25-37

@H1rono
Copy link
Member Author

H1rono commented Mar 29, 2024

✅ include/schneider_model.hpp:33: [high:error] class 'Schneider' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator  [cppcoreguidelines-special-member-functions,-warnings-as-errors]
✅ include/schneider_model.hpp:133: [high:error] redundant access specifier has the same accessibility as the previous access specifier  [readability-redundant-access-specifiers,-warnings-as-errors]
✅ include/schneider_model.hpp:176: [medium:warning] use a trailing return type for this function  [modernize-use-trailing-return-type]
✅ src/main.cpp:3: [medium:warning] use a trailing return type for this function  [modernize-use-trailing-return-type]
✅ src/main.cpp:7: [medium:warning] converting integer literal to bool, use bool literal instead  [modernize-use-bool-literals]
✅ src/main.cpp:7: [high:error] implicit conversion 'int' -> bool  [readability-implicit-bool-conversion,-warnings-as-errors]
✅ src/schneider_model.cpp:4: [medium:warning] inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead  [modernize-deprecated-headers]
✅ src/schneider_model.cpp:13: [high:error] constructor does not initialize these fields: volume_, adcIn1, adcIn2, volume, servo_1, servo_2, fet_1, fet_2, led1, led2, led3, pc  [cppcoreguidelines-pro-type-member-init,-warnings-as-errors]
🔥 src/schneider_model.cpp:35: [high:error] do not call c-style vararg functions  [cppcoreguidelines-pro-type-vararg,-warnings-as-errors]
🔥 src/schneider_model.cpp:54: [high:error] variable 'whoami' is not initialized  [cppcoreguidelines-init-variables,-warnings-as-errors]
🔥 src/schneider_model.cpp:56: [high:error] do not call c-style vararg functions  [cppcoreguidelines-pro-type-vararg,-warnings-as-errors]
🔥 src/schneider_model.cpp:58: [high:error] do not call c-style vararg functions  [cppcoreguidelines-pro-type-vararg,-warnings-as-errors]
✅ src/schneider_model.cpp:80: [high:error] 0.4F is a magic number; consider replacing it with a named constant  [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
✅ src/schneider_model.cpp:80: [high:error] 0.7F is a magic number; consider replacing it with a named constant  [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
✅ src/schneider_model.cpp:102: [high:error] 2 adjacent parameters of 'joy_read' of convertible types are easily swapped by mistake  [bugprone-easily-swappable-parameters,-warnings-as-errors]
✅ src/schneider_model.cpp:109: [high:error] method 'cal_tjacob' can be made static  [readability-convert-member-functions-to-static,-warnings-as-errors]
🔥 src/schneider_model.cpp:129: [high:error] variable 'coef' is not initialized  [cppcoreguidelines-init-variables,-warnings-as-errors]
🔥 src/schneider_model.cpp:141: [high:error] variable 'diff' is not initialized  [cppcoreguidelines-init-variables,-warnings-as-errors]
✅ src/schneider_model.cpp:142: [high:error] 1e-3 is a magic number; consider replacing it with a named constant  [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
✅ src/schneider_model.cpp:142: [high:error] statement should be inside braces  [readability-braces-around-statements,-warnings-as-errors]
✅ src/schneider_model.cpp:157: [high:error] method 'state_equation' can be made static  [readability-convert-member-functions-to-static,-warnings-as-errors]
✅ src/schneider_model.cpp:165: [high:error] method 'set_q' can be made static  [readability-convert-member-functions-to-static,-warnings-as-errors]
✅ src/schneider_model.cpp:169: [high:error] 0.4F is a magic number; consider replacing it with a named constant  [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
✅ src/schneider_model.cpp:172: [high:error] 0.4F is a magic number; consider replacing it with a named constant  [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
🔥 src/schneider_model.cpp:190: [high:error] variable 'width' is not initialized  [cppcoreguidelines-init-variables,-warnings-as-errors]
🔥 src/schneider_model.cpp:194: [high:error] variable 'width' is not initialized  [cppcoreguidelines-init-variables,-warnings-as-errors]
✅ src/schneider_model.cpp:199: [high:error] method 'rotate' can be made const  [readability-make-member-function-const,-warnings-as-errors]
✅ src/schneider_model.cpp:202: [high:error] if with identical then and else branches  [bugprone-branch-clone,-warnings-as-errors]
✅ src/schneider_model.cpp:202: [high:error] 0.5F is a magic number; consider replacing it with a named constant  [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
✅ src/schneider_model.cpp:211: [high:error] method 'led' can be made static  [readability-convert-member-functions-to-static,-warnings-as-errors]
✅ src/schneider_model.cpp:213: [high:error] switch has 3 consecutive identical branches  [bugprone-branch-clone,-warnings-as-errors]
✅ src/schneider_model.cpp:229: [medium:warning] use a trailing return type for this function  [modernize-use-trailing-return-type]

@H1rono
Copy link
Member Author

H1rono commented Mar 31, 2024

@H1rono
Copy link
Member Author

H1rono commented Mar 31, 2024

手元でチェックする方法:

  1. コマンドパレットを開く(ctrl+shift+P)
  2. Open PlatformIO Core CLIを選択
  3. ターミナルが開くので、そこでpio checkを実行
  4. 上のコメントに似た出力が出る

@H1rono
Copy link
Member Author

H1rono commented Mar 31, 2024

#86

@H1rono
Copy link
Member Author

H1rono commented Apr 1, 2024

#93

@H1rono
Copy link
Member Author

H1rono commented Apr 5, 2024

#104

@H1rono
Copy link
Member Author

H1rono commented Apr 10, 2024

#120

@H1rono
Copy link
Member Author

H1rono commented Apr 11, 2024

cppcoreguidelines-init-variablesはアホすぎるのでignoreする

@Chikurin1014
Copy link
Contributor

Chikurin1014 commented Apr 17, 2024

一番つまらなそうな ~~ is a magic numberのエラーをまとめて対応してしまおうと思うのですが、大丈夫ですか?

一か所でも~~ is a magic numberの対応をしている方が他に居たら別のところをやるつもりです。

@Chikurin1014
Copy link
Contributor

書けたのでとりあえずPRだけ出しておきます

@H1rono
Copy link
Member Author

H1rono commented Apr 24, 2024

cppcoreguidelines-pro-type-vararg はとりあえず設定で無視する

@H1rono
Copy link
Member Author

H1rono commented Apr 28, 2024

↓はignoreする

  • cppcoreguidelines-pro-type-member-init
  • bugprone-branch-clone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants