mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
ci(app): run clang-tidy (#8442)
* fix(app): clang-tidy warnings * build(app): convert checks to list * build(app): fix clang-tidy `HeaderFilterRegex` * ci(app): run clang-tidy * fix: ftbfs * wtf
This commit is contained in:
34
.github/workflows/actions.yml
vendored
34
.github/workflows/actions.yml
vendored
@@ -234,7 +234,9 @@ jobs:
|
|||||||
clang-tidy-libtransmission:
|
clang-tidy-libtransmission:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: [ what-to-make ]
|
needs: [ what-to-make ]
|
||||||
if: ${{ needs.what-to-make.outputs.make-core == 'true' || needs.what-to-make.outputs.make-tests == 'true' }}
|
if: |
|
||||||
|
needs.what-to-make.outputs.make-core ||
|
||||||
|
needs.what-to-make.outputs.make-tests
|
||||||
steps:
|
steps:
|
||||||
- name: Show Configuration
|
- name: Show Configuration
|
||||||
run: |
|
run: |
|
||||||
@@ -261,7 +263,7 @@ jobs:
|
|||||||
-DCMAKE_CXX_COMPILER='clang++' \
|
-DCMAKE_CXX_COMPILER='clang++' \
|
||||||
-DCMAKE_C_COMPILER='clang' \
|
-DCMAKE_C_COMPILER='clang' \
|
||||||
-DCMAKE_INSTALL_PREFIX=pfx \
|
-DCMAKE_INSTALL_PREFIX=pfx \
|
||||||
-DENABLE_TESTS=${{ (needs.what-to-make.outputs.make-tests == 'true') && 'ON' || 'OFF' }} \
|
-DENABLE_TESTS=${{ needs.what-to-make.outputs.make-tests && 'ON' || 'OFF' }} \
|
||||||
-DRUN_CLANG_TIDY=ON \
|
-DRUN_CLANG_TIDY=ON \
|
||||||
-DUSE_SYSTEM_DEFAULT=ON \
|
-DUSE_SYSTEM_DEFAULT=ON \
|
||||||
-DUSE_SYSTEM_CRC32C=OFF `# Not packaged in Ubuntu` \
|
-DUSE_SYSTEM_CRC32C=OFF `# Not packaged in Ubuntu` \
|
||||||
@@ -271,18 +273,28 @@ jobs:
|
|||||||
-DUSE_SYSTEM_UTP=OFF `# Not packaged in Ubuntu` \
|
-DUSE_SYSTEM_UTP=OFF `# Not packaged in Ubuntu` \
|
||||||
-DUSE_SYSTEM_WIDE_INTEGER=OFF `# Not packaged in Ubuntu`
|
-DUSE_SYSTEM_WIDE_INTEGER=OFF `# Not packaged in Ubuntu`
|
||||||
- name: Make (Core)
|
- name: Make (Core)
|
||||||
run: cmake --build obj --config Debug --target transmission 2>&1 | tee makelog
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cmake --build obj --config Debug --target transmission 2>&1 | tee makelog
|
||||||
|
- name: Make (App)
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cmake --build obj --config Debug --target transmission-app 2>&1 | tee -a makelog
|
||||||
- name: Make (Tests)
|
- name: Make (Tests)
|
||||||
if: ${{ needs.what-to-make.outputs.make-tests == 'true' }}
|
if: needs.what-to-make.outputs.make-tests
|
||||||
run: cmake --build obj --config Debug --target libtransmission-test 2>&1 | tee -a makelog
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cmake --build obj --config Debug --target libtransmission-test 2>&1 | tee -a makelog
|
||||||
- name: Test for warnings
|
- name: Test for warnings
|
||||||
run: |
|
run: |
|
||||||
if grep 'warning:' makelog; then exit 1; fi
|
if grep 'warning:' makelog; then exit 1; fi
|
||||||
|
|
||||||
clang-tidy-libtransmission-win32:
|
clang-tidy-libtransmission-win32:
|
||||||
runs-on: windows-2025
|
runs-on: windows-2025
|
||||||
needs: [ what-to-make ]
|
needs: what-to-make
|
||||||
if: ${{ needs.what-to-make.outputs.make-core == 'true' || needs.what-to-make.outputs.make-tests == 'true' }}
|
if: |
|
||||||
|
needs.what-to-make.outputs.make-core ||
|
||||||
|
needs.what-to-make.outputs.make-tests
|
||||||
steps:
|
steps:
|
||||||
- name: Show Configuration
|
- name: Show Configuration
|
||||||
run: |
|
run: |
|
||||||
@@ -307,15 +319,19 @@ jobs:
|
|||||||
-G Ninja `
|
-G Ninja `
|
||||||
-DCMAKE_BUILD_TYPE=Debug `
|
-DCMAKE_BUILD_TYPE=Debug `
|
||||||
-DCMAKE_PREFIX_PATH="${Env:DEPS_PREFIX}" `
|
-DCMAKE_PREFIX_PATH="${Env:DEPS_PREFIX}" `
|
||||||
-DENABLE_TESTS=${{ (needs.what-to-make.outputs.make-tests == 'true') && 'ON' || 'OFF' }} `
|
-DENABLE_TESTS=${{ needs.what-to-make.outputs.make-tests && 'ON' || 'OFF' }} `
|
||||||
-DRUN_CLANG_TIDY=ON `
|
-DRUN_CLANG_TIDY=ON `
|
||||||
-DUSE_SYSTEM_DEFAULT=OFF
|
-DUSE_SYSTEM_DEFAULT=OFF
|
||||||
- name: Make (Core)
|
- name: Make (Core)
|
||||||
run: |
|
run: |
|
||||||
Import-VisualStudioVars -VisualStudioVersion 2022 -Architecture x64
|
Import-VisualStudioVars -VisualStudioVersion 2022 -Architecture x64
|
||||||
cmake --build obj --config Debug --target transmission 2>&1 | tee makelog
|
cmake --build obj --config Debug --target transmission 2>&1 | tee makelog
|
||||||
|
- name: Make (App)
|
||||||
|
run: |
|
||||||
|
Import-VisualStudioVars -VisualStudioVersion 2022 -Architecture x64
|
||||||
|
cmake --build obj --config Debug --target transmission-app 2>&1 | tee -a makelog
|
||||||
- name: Make (Tests)
|
- name: Make (Tests)
|
||||||
if: ${{ needs.what-to-make.outputs.make-tests == 'true' }}
|
if: needs.what-to-make.outputs.make-tests
|
||||||
run: |
|
run: |
|
||||||
Import-VisualStudioVars -VisualStudioVersion 2022 -Architecture x64
|
Import-VisualStudioVars -VisualStudioVersion 2022 -Architecture x64
|
||||||
cmake --build obj --config Debug --target libtransmission-test 2>&1 | tee -a makelog
|
cmake --build obj --config Debug --target libtransmission-test 2>&1 | tee -a makelog
|
||||||
|
|||||||
@@ -473,7 +473,7 @@ Glib::RefPtr<Gtk::ListStore> FilterBar::Impl::show_mode_filter_model_new()
|
|||||||
|
|
||||||
static auto constexpr types = std::array<FilterTypeInfo, 9>({ {
|
static auto constexpr types = std::array<FilterTypeInfo, 9>({ {
|
||||||
{ ShowMode::ShowAll, nullptr, N_("All"), nullptr },
|
{ ShowMode::ShowAll, nullptr, N_("All"), nullptr },
|
||||||
{ ShowMode{ -1 }, nullptr, nullptr, nullptr },
|
{ ShowModeSeparator, nullptr, nullptr, nullptr },
|
||||||
{ ShowMode::ShowActive, nullptr, N_("Active"), "system-run" },
|
{ ShowMode::ShowActive, nullptr, N_("Active"), "system-run" },
|
||||||
{ ShowMode::ShowDownloading, "Verb", NC_("Verb", "Downloading"), "network-receive" },
|
{ ShowMode::ShowDownloading, "Verb", NC_("Verb", "Downloading"), "network-receive" },
|
||||||
{ ShowMode::ShowSeeding, "Verb", NC_("Verb", "Seeding"), "network-transmit" },
|
{ ShowMode::ShowSeeding, "Verb", NC_("Verb", "Seeding"), "network-transmit" },
|
||||||
|
|||||||
@@ -1,48 +1,47 @@
|
|||||||
---
|
---
|
||||||
HeaderFilterRegex: .*/libtransmission/.*
|
HeaderFilterRegex: .*/libtransmission-app/.*
|
||||||
|
|
||||||
# TODO: Enable `portability-template-virtual-member-function` after https://github.com/llvm/llvm-project/issues/139031 is fixed
|
|
||||||
# PRs welcome to fix & re-enable any of these explicitly-disabled checks
|
# PRs welcome to fix & re-enable any of these explicitly-disabled checks
|
||||||
Checks: >
|
Checks:
|
||||||
bugprone-*,
|
- bugprone-*
|
||||||
-bugprone-branch-clone,
|
- -bugprone-branch-clone
|
||||||
-bugprone-easily-swappable-parameters,
|
- -bugprone-easily-swappable-parameters
|
||||||
-bugprone-implicit-widening-of-multiplication-result,
|
- -bugprone-implicit-widening-of-multiplication-result
|
||||||
-bugprone-narrowing-conversions,
|
- -bugprone-narrowing-conversions
|
||||||
cert-*,
|
- cert-*
|
||||||
-cert-err58-cpp,
|
- -cert-err58-cpp
|
||||||
-cert-int09-c,
|
- -cert-int09-c # alias of `readability-enum-initial-value`
|
||||||
clang-analyzer-*,
|
- clang-analyzer-*
|
||||||
-clang-analyzer-optin.core.EnumCastOutOfRange,
|
- -clang-analyzer-optin.core.EnumCastOutOfRange
|
||||||
cppcoreguidelines-avoid-do-while,
|
- cppcoreguidelines-avoid-do-while
|
||||||
cppcoreguidelines-avoid-goto,
|
- cppcoreguidelines-avoid-goto
|
||||||
cppcoreguidelines-avoid-reference-coroutine-parameters,
|
- cppcoreguidelines-avoid-reference-coroutine-parameters
|
||||||
cppcoreguidelines-init-variables,
|
- cppcoreguidelines-init-variables
|
||||||
cppcoreguidelines-interfaces-global-init,
|
- cppcoreguidelines-interfaces-global-init
|
||||||
cppcoreguidelines-no-malloc,
|
- cppcoreguidelines-no-malloc
|
||||||
cppcoreguidelines-prefer-member-initializer,
|
- cppcoreguidelines-prefer-member-initializer
|
||||||
cppcoreguidelines-pro-type-cstyle-cast,
|
- cppcoreguidelines-pro-type-cstyle-cast
|
||||||
cppcoreguidelines-pro-type-member-init,
|
- cppcoreguidelines-pro-type-member-init
|
||||||
cppcoreguidelines-slicing,
|
- cppcoreguidelines-slicing
|
||||||
cppcoreguidelines-special-member-functions,
|
- cppcoreguidelines-special-member-functions
|
||||||
cppcoreguidelines-virtual-class-destructor,
|
- cppcoreguidelines-virtual-class-destructor
|
||||||
google-explicit-constructor,
|
- google-explicit-constructor
|
||||||
misc-*,
|
- misc-*
|
||||||
-misc-include-cleaner,
|
- -misc-include-cleaner
|
||||||
-misc-no-recursion,
|
- -misc-no-recursion
|
||||||
-misc-non-private-member-variables-in-classes,
|
- -misc-non-private-member-variables-in-classes
|
||||||
modernize-*,
|
- modernize-*
|
||||||
-modernize-use-trailing-return-type,
|
- -modernize-use-trailing-return-type
|
||||||
performance-*,
|
- performance-*
|
||||||
-performance-move-const-arg,
|
- -performance-move-const-arg
|
||||||
portability-*,
|
- portability-*
|
||||||
-portability-template-virtual-member-function,
|
- -portability-template-virtual-member-function # TODO: Enable after https://github.com/llvm/llvm-project/issues/139031 is fixed
|
||||||
readability-*,
|
- readability-*
|
||||||
-readability-enum-initial-value,
|
- -readability-enum-initial-value
|
||||||
-readability-function-cognitive-complexity,
|
- -readability-function-cognitive-complexity
|
||||||
-readability-identifier-length,
|
- -readability-identifier-length
|
||||||
-readability-magic-numbers,
|
- -readability-magic-numbers
|
||||||
-readability-qualified-auto,
|
- -readability-qualified-auto
|
||||||
|
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- { key: cppcoreguidelines-avoid-do-while.IgnoreMacros, value: true }
|
- { key: cppcoreguidelines-avoid-do-while.IgnoreMacros, value: true }
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include "libtransmission-app/display-modes.h"
|
#include "libtransmission-app/display-modes.h"
|
||||||
#include "libtransmission-app/converters.h"
|
#include "libtransmission-app/converters.h"
|
||||||
|
|
||||||
|
using namespace std::literals;
|
||||||
|
|
||||||
namespace tr::app::detail
|
namespace tr::app::detail
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
@@ -88,10 +90,10 @@ struct TrYearMonthDay
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto const dim = days_in_month(y, m);
|
auto const dim = days_in_month(y, m);
|
||||||
return d >= 1 && d <= static_cast<unsigned>(dim);
|
return d >= 1 && std::cmp_less_equal(d, dim);
|
||||||
};
|
};
|
||||||
|
|
||||||
return TrYearMonthDay{ year, month, day, is_valid_ymd(year, month, day) };
|
return TrYearMonthDay{ .year = year, .month = month, .day = day, .valid = is_valid_ymd(year, month, day) };
|
||||||
}
|
}
|
||||||
|
|
||||||
// c++20 (P0355) replace with std::chrono::sys_days{} after Debian 11 is EOL
|
// c++20 (P0355) replace with std::chrono::sys_days{} after Debian 11 is EOL
|
||||||
@@ -344,11 +346,12 @@ tr_variant from_stats_mode(StatsMode const& src)
|
|||||||
{
|
{
|
||||||
if (auto const* local = std::localtime(&tt))
|
if (auto const* local = std::localtime(&tt))
|
||||||
{
|
{
|
||||||
return fmt::format(FMT_STRING("{:%FT%T%z}"), *local);
|
// fmt::runtime to workaround FTBFS in clang
|
||||||
|
return fmt::format(fmt::runtime("{:%FT%T%z}"), *local);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt::format(FMT_STRING("{:%FT%TZ}"), src);
|
return fmt::format("{:%FT%TZ}", src);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool to_sys_seconds(tr_variant const& src, std::chrono::sys_seconds* tgt)
|
bool to_sys_seconds(tr_variant const& src, std::chrono::sys_seconds* tgt)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace tr::app
|
namespace tr::app
|
||||||
{
|
{
|
||||||
enum class ShowMode
|
enum class ShowMode : uint8_t
|
||||||
{
|
{
|
||||||
ShowAll,
|
ShowAll,
|
||||||
ShowActive,
|
ShowActive,
|
||||||
@@ -21,7 +21,7 @@ enum class ShowMode
|
|||||||
inline auto constexpr ShowModeCount = 8U;
|
inline auto constexpr ShowModeCount = 8U;
|
||||||
inline auto constexpr DefaultShowMode = ShowMode::ShowAll;
|
inline auto constexpr DefaultShowMode = ShowMode::ShowAll;
|
||||||
|
|
||||||
enum class SortMode
|
enum class SortMode : uint8_t
|
||||||
{
|
{
|
||||||
SortByActivity,
|
SortByActivity,
|
||||||
SortByAge,
|
SortByAge,
|
||||||
@@ -37,7 +37,7 @@ enum class SortMode
|
|||||||
inline auto constexpr SortModeCount = 10U;
|
inline auto constexpr SortModeCount = 10U;
|
||||||
inline auto constexpr DefaultSortMode = SortMode::SortByName;
|
inline auto constexpr DefaultSortMode = SortMode::SortByName;
|
||||||
|
|
||||||
enum class StatsMode
|
enum class StatsMode : uint8_t
|
||||||
{
|
{
|
||||||
TotalRatio,
|
TotalRatio,
|
||||||
TotalTransfer,
|
TotalTransfer,
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
{
|
{
|
||||||
return item.first == key;
|
return item.first == key;
|
||||||
};
|
};
|
||||||
return std::find_if(std::begin(vec_), std::end(vec_), predicate);
|
return std::ranges::find_if(vec_, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] constexpr auto find(tr_quark const key) const noexcept
|
[[nodiscard]] constexpr auto find(tr_quark const key) const noexcept
|
||||||
@@ -101,7 +101,7 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] constexpr auto contains(tr_quark const key) const noexcept
|
[[nodiscard]] constexpr auto contains(tr_quark const key) const noexcept
|
||||||
{
|
{
|
||||||
return find(key) != end();
|
return find(key) != end(); // NOLINT(readability-container-contains)
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] constexpr auto size() const noexcept
|
[[nodiscard]] constexpr auto size() const noexcept
|
||||||
|
|||||||
Reference in New Issue
Block a user