Use clang-tidy to clean up the codebase

Bug #1731034 reported by GunChleoc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Won't Fix
Undecided
Unassigned

Bug Description

I found another cleanup tool: http://clang.llvm.org/extra/clang-tidy/

I'll attach a script with instructions.

This is generating a lot or warnings, it's probably best if we run this one check at a time. Some of the checks also have a -fix option to fix stuff automatically.

Related branches

Revision history for this message
SirVer (sirver) wrote :

That tool is written by some of the people in my office :).

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thank them for a great tool then!

I found it via this post: https://forum.freegamedev.net/viewtopic.php?p=74965#p74965 which links to the following video about common bugs: https://www.youtube.com/watch?v=lkgszkPnV8g

Here are the stats on first run:

   1 [cert-dcl03-c]
  11 [cert-dcl50-cpp]
   1 [cert-err52-cpp]
  51 [cert-err58-cpp]
   2 [cert-err61-cpp]
  16 [clang-analyzer-alpha.core.CastToStruct]
   1 [clang-analyzer-alpha.core.IdenticalExpr]
  12 [clang-analyzer-alpha.core.SizeofPtr]
 211 [clang-analyzer-alpha.deadcode.UnreachableCode]
  10 [clang-analyzer-alpha.security.ArrayBound]
   1 [clang-analyzer-alpha.security.ArrayBoundV2]
   4 [clang-analyzer-alpha.unix.cstring.OutOfBounds]
  10 [clang-analyzer-alpha.unix.Stream]
   4 [clang-analyzer-core.CallAndMessage]
   2 [clang-analyzer-core.DivideZero]
   3 [clang-analyzer-core.NonNullParamChecker]
   2 [clang-analyzer-core.NullDereference]
   1 [clang-analyzer-core.UndefinedBinaryOperatorResult]
   1 [clang-analyzer-core.uninitialized.Assign]
   2 [clang-analyzer-cplusplus.NewDelete]
   7 [clang-analyzer-cplusplus.NewDeleteLeaks]
   8 [clang-analyzer-deadcode.DeadStores]
   2 [clang-analyzer-security.insecureAPI.strcpy]
   1 [clang-diagnostic-unused-const-variable]
1475 [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
 270 [cppcoreguidelines-pro-bounds-constant-array-index]
 393 [cppcoreguidelines-pro-bounds-pointer-arithmetic]
  18 [cppcoreguidelines-pro-type-reinterpret-cast]
  56 [cppcoreguidelines-pro-type-static-cast-downcast]
  73 [cppcoreguidelines-pro-type-union-access]
   2 [google-build-explicit-make-pair]
  23 [google-build-using-namespace]
   1 [google-explicit-constructor]
3212 [google-readability-braces-around-statements]
  14 [google-readability-casting]
 138 [google-readability-namespace-comments]
  28 [google-readability-redundant-smartptr-get]
  54 [google-runtime-int]
   1 [misc-assert-side-effect]
  77 [misc-macro-parentheses]
   6 [misc-move-const-arg]
   2 [misc-noexcept-move-constructor]
   1 [misc-static-assert]
   5 [misc-uniqueptr-reset-release]
 132 [modernize-loop-convert]
  31 [modernize-make-unique]
  45 [modernize-pass-by-value]
 186 [modernize-use-auto]
  54 [modernize-use-default]
  36 [modernize-use-nullptr]
  17 [modernize-use-override]
 866 [readability-braces-around-statements]
  36 [readability-container-size-empty]
 255 [readability-else-after-return]
   1 [readability-function-size]
2257 [readability-implicit-bool-cast]
 257 [readability-inconsistent-declaration-parameter-name]
   3 [readability-redundant-smartptr-get]
  20 [readability-simplify-boolean-expr]
   1 [readability-uniqueptr-delete-release]

Revision history for this message
GunChleoc (gunchleoc) wrote :

https://code.launchpad.net/~widelands-dev/widelands/clang-tidy-round1 has fixed:

    cert-dcl03-c
    cert-err52-cpp
    cert-err61-cpp
    clang-analyzer-core.CallAndMessage
    clang-analyzer-core.DivideZero
    clang-analyzer-core.NonNullParamChecker
    clang-analyzer-core.NullDereference
    clang-analyzer-core.UndefinedBinaryOperatorResult
    clang-analyzer-deadcode.DeadStores
    clang-analyzer-security.insecureAPI.strcpy
    clang-diagnostic-unused-const-variable
    google-explicit-constructor
    misc-assert-side-effect
    misc-static-assert
    readability-function-size
    readability-redundant-smartptr-get
    readability-uniqueptr-delete-release

There is 1 instance of clang-analyzer-core.CallAndMessage remaining.

Revision history for this message
GunChleoc (gunchleoc) wrote :
Changed in widelands:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.