Compare commits

...
Author SHA1 Message Date
Hanif Koh 0c4897e677 Gate PRs on the Quiet bugprone Checks Only
Keep the six checks that report almost nothing on correct code and clear their remaining hits: drop redundant branch conditions, forward a forwarding reference, mark deliberate discards with (void), and explain the pointer-ordered sets whose order does not matter. Allow (void) to mark a discarded result.
2026-10-12 03:17:14 +08:00
Hanif Koh 7c70300ec5 Flag Likely Bugs with clang-tidy's bugprone Checks
Enable fourteen checks that rarely fire on correct code: use after move, discarded RAII objects and return values, integers stored as string characters, slicing, and similar mistakes. They gate only the lines a pull request changes, like the existing checks.

boost::system::error_code is dropped from bugprone-unused-return-value's checked return types, because Boost.Asio's error_code& overloads also return the code they set.
2026-10-12 02:30:28 +08:00
6 changed files with 31 additions and 18 deletions
+20 -2
View File
@@ -1,5 +1,5 @@
# clang-tidy configuration, enforced by the clang-tidy CI job on the lines a pull
# request changes (scripts/clang_tidy_diff.py). Two things are reported.
# request changes (scripts/clang_tidy_diff.py). Three things are reported.
# Missing includes: a file should include the header for every symbol it uses, not
# rely on the precompiled header or another header's includes. Run with --fix to
# add them.
@@ -7,11 +7,29 @@
# they reach every file that includes the header, and a using-declaration also
# makes the header look like the one to include for that name. Qualify the name
# in the header, and put the using in the source files that want it.
# Likely bugs: an RAII object or a return value thrown away, an integer stored
# as a character in a string, std::move on a forwarding reference, iteration
# whose order depends on pointer values, and a condition already known true.
# Every check listed here gates pull requests, so enable a new one only once the
# code it flags on touched lines is reasonable to fix in passing.
Checks: '-*,misc-include-cleaner,google-global-names-in-headers'
Checks: >-
-*,
misc-include-cleaner,
google-global-names-in-headers,
bugprone-move-forwarding-reference,
bugprone-nondeterministic-pointer-iteration-order,
bugprone-redundant-branch-condition,
bugprone-string-integer-assignment,
bugprone-unused-raii,
bugprone-unused-return-value
WarningsAsErrors: '*'
CheckOptions:
# (void) marks a result dropped on purpose, such as a deliberate leak through
# unique_ptr::release().
bugprone-unused-return-value.AllowCastToVoid: true
# The default list without boost::system::error_code: Boost.Asio's overloads
# that take an error_code& also return it, and callers check the argument.
bugprone-unused-return-value.CheckedReturnTypes: '^::std::error_code$;^::std::error_condition$;^::std::errc$;^::std::expected$'
# Missing includes only. Builds without the precompiled header break on these.
misc-include-cleaner.UnusedIncludes: false
# Headers that declare a symbol but are not the one to include: per-platform
+1 -2
View File
@@ -6865,8 +6865,7 @@ LayerResult GCode::process_layer(
}
#endif
if (support_dontcare)
support_extruder = dontcare_extruder;
support_extruder = dontcare_extruder;
}
else if (support_dontcare || interface_dontcare) {
// Some support will be printed with "don't care" material, preferably non-soluble.
+1 -1
View File
@@ -248,7 +248,7 @@ inline void polylines_merge(PointsType &dst, bool dst_first, PointsType &&src, b
} else if (! src_first)
std::reverse(src.begin(), src.end());
// Merge src into dst.
append(dst, std::move(src));
append(dst, std::forward<PointsType>(src));
}
const Point& leftmost_point(const Polylines &polylines);
+2
View File
@@ -3386,6 +3386,7 @@ void PresetBundle::load_installed_filaments(AppConfig &config)
// compatible_filaments.insert(&filament);
}
// and mark these filaments as installed, therefore this code will not be executed at the next start of the application.
// NOLINTNEXTLINE(bugprone-nondeterministic-pointer-iteration-order) - each is set by name, so only the log order varies
for (const auto &filament: compatible_filaments) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": set filament %1% to visible by default")%filament->name;
config.set(AppConfig::SECTION_FILAMENTS, filament->name, "true");
@@ -3412,6 +3413,7 @@ void PresetBundle::load_installed_sla_materials(AppConfig &config)
comp_sla_materials.insert(&material);
}
// and mark these SLA materials as installed, therefore this code will not be executed at the next start of the application.
// NOLINTNEXTLINE(bugprone-nondeterministic-pointer-iteration-order) - each is set by name, so the order does not matter
for (const auto &material: comp_sla_materials)
config.set(AppConfig::SECTION_MATERIALS, material->name, "true");
}
+5 -11
View File
@@ -3953,9 +3953,7 @@ bool GUI_App::on_init_network(bool try_backup)
if (!bambu_source) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": can not get bambu source module!";
m_networking_compatible = false;
if (should_load_networking_plugin) {
m_networking_need_update = true;
}
m_networking_need_update = true;
}
} else {
if (try_backup) {
@@ -3966,9 +3964,7 @@ bool GUI_App::on_init_network(bool try_backup)
goto __retry;
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, version dismatch, need upload network module";
if (should_load_networking_plugin) {
m_networking_need_update = true;
}
m_networking_need_update = true;
}
} else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, load dll failed";
@@ -3986,10 +3982,8 @@ bool GUI_App::on_init_network(bool try_backup)
load_agent_dll = Slic3r::NetworkAgent::initialize_network_module(false, config_version);
goto __retry;
}
if (should_load_networking_plugin) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, need upload network module";
m_networking_need_update = true;
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, need upload network module";
m_networking_need_update = true;
}
}
@@ -8293,7 +8287,7 @@ bool GUI_App::load_language(wxString language, bool initial)
// Release the old locales, create new locales.
//FIXME wxWidgets cause havoc if the current locale is deleted. We just forget it causing memory leaks for now.
m_wxLocale.release();
(void) m_wxLocale.release();
m_wxLocale = Slic3r::make_unique<wxLocale>();
m_wxLocale->Init(locale_language_info->Language);
// Override language at the active wxTranslations class (which is stored in the active m_wxLocale)
+2 -2
View File
@@ -165,10 +165,10 @@ TEST_CASE("write_file_atomically survives two threads writing one target", "[uti
std::thread other([&] {
for (int i = 0; i < 50; ++i)
write_file_atomically(target.string(), a);
(void) write_file_atomically(target.string(), a);
});
for (int i = 0; i < 50; ++i)
write_file_atomically(target.string(), b);
(void) write_file_atomically(target.string(), b);
other.join();
std::string content;