forked from organicmaps/organicmaps
Configure clang-tidy CI check
Signed-off-by: Siarhei Fedartsou <siarhei.fedartsou@gmail.com>
This commit is contained in:
parent
a1887b716a
commit
557c0b3c3e
16 changed files with 153 additions and 14 deletions
114
.clang-tidy
Normal file
114
.clang-tidy
Normal file
|
@ -0,0 +1,114 @@
|
|||
---
|
||||
Checks: >
|
||||
bugprone-*,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-branch-clone,
|
||||
-bugprone-misplaced-widening-cast,
|
||||
-bugprone-exception-escape,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-integer-division,
|
||||
-bugprone-reserved-identifier,
|
||||
-bugprone-unhandled-self-assignment,
|
||||
-bugprone-forward-declaration-namespace,
|
||||
-bugprone-sizeof-expression,
|
||||
-bugprone-throw-keyword-missing,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-forwarding-reference-overload,
|
||||
-bugprone-move-forwarding-reference,
|
||||
-bugprone-incorrect-roundings,
|
||||
-bugprone-unchecked-optional-access,
|
||||
-bugprone-assignment-in-if-condition,
|
||||
-bugprone-signed-char-misuse,
|
||||
-bugprone-suspicious-include,
|
||||
-bugprone-sizeof-container,
|
||||
-bugprone-bool-pointer-implicit-conversion,
|
||||
-bugprone-lambda-function-name,
|
||||
-bugprone-use-after-move,
|
||||
-bugprone-suspicious-enum-usage,
|
||||
-clang-analyzer-*,
|
||||
-clang-diagnostic-deprecated-declarations,
|
||||
-clang-diagnostic-constant-conversion,
|
||||
-clang-diagnostic-unqualified-std-cast-call,
|
||||
google-*,
|
||||
-google-build-explicit-make-pair,
|
||||
-google-build-using-namespace,
|
||||
-google-explicit-constructor,
|
||||
-google-default-arguments,
|
||||
-google-readability-braces-around-statements,
|
||||
-google-readability-casting,
|
||||
-google-readability-namespace-comments,
|
||||
-google-readability-function,
|
||||
-google-readability-todo,
|
||||
-google-runtime-int,
|
||||
-google-build-namespaces,
|
||||
-google-runtime-references,
|
||||
-google-readability-function-size,
|
||||
-google-global-names-in-headers,
|
||||
llvm-*,
|
||||
-llvm-namespace-comment,
|
||||
-llvm-qualified-auto,
|
||||
-llvm-include-order,
|
||||
-llvm-else-after-return,
|
||||
-llvm-header-guard,
|
||||
-llvm-twine-local,
|
||||
misc-*,
|
||||
-misc-argument-comment,
|
||||
-misc-const-correctness,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
-misc-unconventional-assign-operator,
|
||||
-misc-no-recursion,
|
||||
-misc-misplaced-const,
|
||||
-misc-definitions-in-headers,
|
||||
-misc-unused-parameters,
|
||||
-misc-unused-using-decls,
|
||||
-misc-static-assert,
|
||||
-misc-confusable-identifiers,
|
||||
-misc-redundant-expression,
|
||||
performance-*,
|
||||
-performance-noexcept-move-constructor,
|
||||
-performance-no-int-to-ptr,
|
||||
-performance-unnecessary-value-param,
|
||||
-performance-unnecessary-copy-initialization,
|
||||
-performance-move-const-arg,
|
||||
-performance-inefficient-string-concatenation,
|
||||
-performance-no-automatic-move,
|
||||
-performance-type-promotion-in-math-fn,
|
||||
-performance-for-range-copy,
|
||||
readability-*,
|
||||
-readability-avoid-const-params-in-decls,
|
||||
-readability-braces-around-statements,
|
||||
-readability-container-size-empty,
|
||||
-readability-convert-member-functions-to-static,
|
||||
-readability-container-data-pointer,
|
||||
-readability-const-return-type,
|
||||
-readability-function-cognitive-complexity,
|
||||
-readability-function-size,
|
||||
-readability-identifier-naming,
|
||||
-readability-implicit-bool-conversion,
|
||||
-readability-magic-numbers,
|
||||
-readability-else-after-return,
|
||||
-readability-inconsistent-declaration-parameter-name,
|
||||
-readability-isolate-declaration,
|
||||
-readability-identifier-length,
|
||||
-readability-redundant-declaration,
|
||||
-readability-uppercase-literal-suffix,
|
||||
-readability-named-parameter,
|
||||
-readability-qualified-auto,
|
||||
-readability-suspicious-call-argument,
|
||||
-readability-redundant-access-specifiers,
|
||||
-readability-redundant-member-init,
|
||||
-readability-static-definition-in-anonymous-namespace,
|
||||
-readability-use-anyofallof,
|
||||
-readability-simplify-boolean-expr,
|
||||
-readability-make-member-function-const,
|
||||
-readability-redundant-string-init,
|
||||
-readability-non-const-parameter,
|
||||
-readability-static-accessed-through-instance,
|
||||
-readability-misleading-indentation,
|
||||
-readability-redundant-string-cstr,
|
||||
-readability-redundant-smartptr-get,
|
||||
-readability-duplicate-include
|
||||
|
||||
WarningsAsErrors: '*'
|
||||
HeaderFilterRegex: '.*'
|
2
.github/workflows/linux-check.yaml
vendored
2
.github/workflows/linux-check.yaml
vendored
|
@ -63,7 +63,7 @@ jobs:
|
|||
CXX: clang++-14
|
||||
# -g1 should slightly reduce build time.
|
||||
run: |
|
||||
cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-g1 -DUNITY_DISABLE=ON
|
||||
cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-g1 -DUNITY_DISABLE=ON -DUSE_CLANG_TIDY=ON
|
||||
|
||||
- name: Compile
|
||||
shell: bash
|
||||
|
|
|
@ -126,6 +126,7 @@ if (BUILD_DESIGNER)
|
|||
add_definitions(-DBUILD_DESIGNER)
|
||||
endif()
|
||||
|
||||
option(USE_CLANG_TIDY "Enable Clang Tidy" OFF)
|
||||
option(USE_ASAN "Enable Address Sanitizer" OFF)
|
||||
option(USE_TSAN "Enable Thread Sanitizer" OFF)
|
||||
option(USE_LIBFUZZER "Enable LibFuzzer" OFF)
|
||||
|
@ -161,6 +162,10 @@ if (PLATFORM_LINUX)
|
|||
option(USE_PPROF "Enable Google Profiler" OFF)
|
||||
endif()
|
||||
|
||||
if (USE_CLANG_TIDY)
|
||||
message(STATUS "Clang Tidy is enabled")
|
||||
endif()
|
||||
|
||||
if (USE_ASAN)
|
||||
message(STATUS "Address Sanitizer is enabled")
|
||||
endif()
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
buffer_vector(buffer_vector const &) = default;
|
||||
|
||||
buffer_vector(buffer_vector && rhs) : m_size(rhs.m_size), m_dynamic(move(rhs.m_dynamic))
|
||||
buffer_vector(buffer_vector && rhs) : m_size(rhs.m_size), m_dynamic(std::move(rhs.m_dynamic))
|
||||
{
|
||||
if (!IsDynamic())
|
||||
MoveStatic(rhs);
|
||||
|
|
|
@ -18,7 +18,7 @@ DeferredTask::DeferredTask(Duration const & duration) : m_duration(duration)
|
|||
if (m_cv.wait_for(l, m_duration) != std::cv_status::timeout || !m_fn)
|
||||
continue;
|
||||
|
||||
auto fn = move(m_fn);
|
||||
auto fn = std::move(m_fn);
|
||||
m_fn = nullptr;
|
||||
|
||||
l.unlock();
|
||||
|
|
|
@ -33,7 +33,7 @@ function(omim_add_executable executable)
|
|||
|
||||
# Enable warnings for all our binaries.
|
||||
target_compile_options(${executable} PRIVATE ${OMIM_WARNING_FLAGS})
|
||||
target_include_directories(${executable} PRIVATE ${OMIM_INCLUDE_DIRS})
|
||||
target_include_directories(${executable} SYSTEM PRIVATE ${OMIM_INCLUDE_DIRS})
|
||||
if (USE_ASAN)
|
||||
target_link_libraries(${executable}
|
||||
-fsanitize=address
|
||||
|
@ -74,12 +74,15 @@ function(omim_add_executable executable)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
# SYSTEM is needed to suppress warnings from 3party headers.
|
||||
|
||||
function(omim_add_library library)
|
||||
add_library(${library} ${ARGN})
|
||||
|
||||
# Enable warnings for all our libraries.
|
||||
target_compile_options(${library} PRIVATE ${OMIM_WARNING_FLAGS})
|
||||
target_include_directories(${library} PRIVATE ${OMIM_INCLUDE_DIRS})
|
||||
target_include_directories(${library} SYSTEM PRIVATE ${OMIM_INCLUDE_DIRS})
|
||||
if (USE_PPROF AND PLATFORM_MAC)
|
||||
find_path(PPROF_INCLUDE_DIR NAMES gperftools/profiler.h)
|
||||
target_include_directories(${library} SYSTEM PUBLIC ${PPROF_INCLUDE_DIR})
|
||||
|
@ -87,6 +90,18 @@ function(omim_add_library library)
|
|||
if (USE_PCH)
|
||||
add_precompiled_headers_to_target(${library} ${OMIM_PCH_TARGET_NAME})
|
||||
endif()
|
||||
|
||||
|
||||
if (USE_CLANG_TIDY)
|
||||
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
|
||||
if(NOT CLANG_TIDY_COMMAND)
|
||||
message(FATAL_ERROR "USE_CLANG_TIDY is ON but clang-tidy is not found!")
|
||||
else()
|
||||
message(STATUS "Found clang-tidy at ${CLANG_TIDY_COMMAND}")
|
||||
set_target_properties(${library} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
function(omim_add_test_impl disable_platform_init executable)
|
||||
|
@ -96,7 +111,7 @@ function(omim_add_test_impl disable_platform_init executable)
|
|||
${OMIM_ROOT}/testing/testingmain.cpp
|
||||
)
|
||||
target_compile_options(${executable} PRIVATE ${OMIM_WARNING_FLAGS})
|
||||
target_include_directories(${executable} PRIVATE ${OMIM_INCLUDE_DIRS})
|
||||
target_include_directories(${executable} SYSTEM PRIVATE ${OMIM_INCLUDE_DIRS})
|
||||
if(disable_platform_init)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE OMIM_UNIT_TEST_DISABLE_PLATFORM_INIT)
|
||||
else()
|
||||
|
|
|
@ -227,7 +227,7 @@ public:
|
|||
|
||||
SubElements(O5MSource * reader, TSubElementGetter const & func) : m_reader(reader), m_func(func) {}
|
||||
|
||||
void Skip() { while (m_reader && m_func(nullptr)); }
|
||||
void Skip() { while (m_reader && m_func(nullptr)) { /* no-op */ } }
|
||||
|
||||
Iterator const begin() const { return Iterator(m_reader, m_func); }
|
||||
Iterator const end() const { return Iterator(); }
|
||||
|
|
|
@ -52,16 +52,16 @@ public:
|
|||
{
|
||||
// String format: <<lat;lon;id;is_capital>>.
|
||||
// First ';'.
|
||||
auto pos = oneLine.find(";");
|
||||
auto pos = oneLine.find(';');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
// Second ';'.
|
||||
pos = oneLine.find(";", pos + 1);
|
||||
pos = oneLine.find(';', pos + 1);
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
uint64_t nodeId;
|
||||
// Third ';'.
|
||||
auto endPos = oneLine.find(";", pos + 1);
|
||||
auto endPos = oneLine.find(';', pos + 1);
|
||||
if (endPos != std::string::npos)
|
||||
{
|
||||
if (strings::to_uint64(oneLine.substr(pos + 1, endPos - pos - 1), nodeId))
|
||||
|
|
|
@ -290,7 +290,7 @@ bool ValidateWebsite(string const & site)
|
|||
if ('.' == site[startPos] || '.' == site.back())
|
||||
return false;
|
||||
|
||||
if (string::npos == site.find("."))
|
||||
if (string::npos == site.find('.'))
|
||||
return false;
|
||||
|
||||
if (string::npos != site.find(".."))
|
||||
|
|
|
@ -807,6 +807,7 @@ void TransitRouteDisplay::CreateTransitMarks()
|
|||
GetTransitMarkerSizes(kStopMarkerScale, m_maxSubrouteWidth);
|
||||
|
||||
vector<m2::PointF> transferArrowOffsets;
|
||||
transferArrowOffsets.reserve(transferMarkerSizes.size());
|
||||
for (auto const & size : transferMarkerSizes)
|
||||
transferArrowOffsets.emplace_back(0.0f, size.y * 0.5f);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace openlr
|
|||
vector<m2::PointD> LinearSegment::GetMercatorPoints() const
|
||||
{
|
||||
vector<m2::PointD> points;
|
||||
points.reserve(m_locationReference.m_points.size());
|
||||
for (auto const & point : m_locationReference.m_points)
|
||||
points.push_back(mercator::FromLatLon(point.m_latLon));
|
||||
return points;
|
||||
|
|
|
@ -175,7 +175,7 @@ string HttpClient::NormalizeServerCookies(string && cookies)
|
|||
// Split by ", ". Can have invalid tokens here, expires= can also contain a comma.
|
||||
while (getline(is, str, ','))
|
||||
{
|
||||
size_t const leading = str.find_first_not_of(" ");
|
||||
size_t const leading = str.find_first_not_of(' ');
|
||||
if (leading != string::npos)
|
||||
str.substr(leading).swap(str);
|
||||
|
||||
|
@ -193,7 +193,7 @@ string HttpClient::NormalizeServerCookies(string && cookies)
|
|||
result.append("; ");
|
||||
|
||||
// Read cookie itself.
|
||||
result.append(str, 0, str.find(";"));
|
||||
result.append(str, 0, str.find(';'));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ bool MatchResults(DataSource const & dataSource, vector<shared_ptr<MatchingRule>
|
|||
vector<search::Result> const & actual)
|
||||
{
|
||||
vector<FeatureID> resultIds;
|
||||
resultIds.reserve(actual.size());
|
||||
for (auto const & a : actual)
|
||||
resultIds.push_back(a.GetFeatureID());
|
||||
sort(resultIds.begin(), resultIds.end());
|
||||
|
|
|
@ -21,7 +21,7 @@ void CountryInfo::FileName2FullName(string & fName)
|
|||
// static
|
||||
void CountryInfo::FullName2GroupAndMap(string const & fName, string & group, string & map)
|
||||
{
|
||||
size_t pos = fName.find(",");
|
||||
size_t pos = fName.find(',');
|
||||
if (pos == string::npos)
|
||||
{
|
||||
map = fName;
|
||||
|
|
|
@ -182,6 +182,7 @@ TimeTable GetTimeTableFromJson(json_t * obj)
|
|||
std::vector<TimeInterval> timeIntervals;
|
||||
|
||||
auto const & rawValues = GetVectorFromJson<uint64_t>(item, "intervals");
|
||||
timeIntervals.reserve(rawValues.size());
|
||||
for (auto const & rawValue : rawValues)
|
||||
timeIntervals.push_back(TimeInterval(rawValue));
|
||||
|
||||
|
|
|
@ -134,6 +134,7 @@ template <class Id, class Item>
|
|||
void UpdateItems(set<Id> const & ids, vector<Item> & items)
|
||||
{
|
||||
vector<Item> itemsToFill;
|
||||
itemsToFill.reserve(ids.size());
|
||||
for (auto const id : ids)
|
||||
itemsToFill.push_back(FindById(items, id));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue