Enable more clang-tidy checks for new code
authorRoland Schulz <roland.schulz@intel.com>
Fri, 3 Aug 2018 01:19:40 +0000 (18:19 -0700)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 27 Aug 2018 08:44:20 +0000 (10:44 +0200)
commit88754544f483f03d0d939da8a973274acd17da62
treefab0ccbeacd04c18856dcbb44ca0750c5594afe2
parenta5d9f399250514141fa0ea98f7d479a9823e1d00
Enable more clang-tidy checks for new code

Some of the clang-tidy checks would require too many code
changes when enabled globally. To get the benefits from
the checks without changing all legacy code add a second
configuration. Which configuration is used is selected by
directory: Any new module should use the new configuration.

Additionally it is recommended to use the new configuration
on a per file or change basis (clang-tidy-diff.py) manually.

This change contains the proposed configuration for new code and
and enables it for three folders which contain new code.

Checks enabled relative to base configuration:
clang-analyzer-security.insecureAPI.strcpy
readability-inconsistent-declaration-parameter-name
readability-function-size
cppcoreguidelines-owning-memory
cppcoreguidelines-no-malloc
cppcoreguidelines-pro-type-member-init
cppcoreguidelines-pro-type-union-access

The reasons that the remaining checks are still disabled (don't
know a good place to document because json doesn't allow comments):
misc-incorrect-roundings: #2562
readability-else-after-return: I don't think it is something we want to follow
cppcoreguidelines-pro-type-*cast: While it is best to not do those cast there
    are valid reasons for them. And because they are already easy to spot,
    mandating a NOLINT for those is probably not helpful.
cppcoreguidelines-special-member-functions: conflicts with Wunused-member
cppcoreguidelines-pro-type-vararg: #2570
cppcoreguidelines-pro-bounds-constant-array-index: While I think it would be
    nice to have a compile mode with bound checking enabled. It is so ugly
    to have to write at(v, n) instead of v[n].
cppcoreguidelines-pro-bounds-array-to-pointer-decay: This would be particular
    nice to have But it makes it very hard to write warning free code with
    legacy APIs which uses e.g. rvec. Those have to be modernized first.
cppcoreguidelines-pro-bounds-pointer-arithmetic: This would also be very nice.
    But it requires that depending APIs use ArrayRef rather than pointers
    for non-owning array passing.

Change-Id: I891a576d2c185ef6587224a1a19324f1a8967237
29 files changed:
cmake/gmxCFlags.cmake
src/.clang-tidy
src/.clang-tidy.new.code [new file with mode: 0644]
src/external/googletest/googletest/include/gtest/internal/gtest-internal.h
src/gromacs/CMakeLists.txt
src/gromacs/analysisdata/.clang-tidy [new symlink]
src/gromacs/analysisdata/datamodulemanager.cpp
src/gromacs/analysisdata/modules/plot.cpp
src/gromacs/compat/CMakeLists.txt [new file with mode: 0644]
src/gromacs/compat/make_unique.h
src/gromacs/options/.clang-tidy [new symlink]
src/gromacs/options/abstractsection.h
src/gromacs/options/basicoptions.cpp
src/gromacs/options/basicoptions.h
src/gromacs/options/optionsection.cpp
src/gromacs/options/optionsection.h
src/gromacs/options/optionstoragetemplate.h
src/gromacs/options/repeatingsection.h
src/gromacs/options/tests/repeatingsection.cpp
src/gromacs/options/timeunitmanager.cpp
src/gromacs/random/threefry.h
src/gromacs/selection/nbsearch.h
src/gromacs/trajectoryanalysis/.clang-tidy [new symlink]
src/gromacs/trajectoryanalysis/modules/angle.cpp
src/gromacs/trajectoryanalysis/modules/distance.cpp
src/gromacs/trajectoryanalysis/modules/trajectory.cpp
src/gromacs/trajectoryanalysis/tests/surfacearea.cpp
src/gromacs/trajectoryanalysis/topologyinformation.cpp
src/gromacs/utility/variant.h