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.
This commit is contained in:
Hanif Koh
2026-10-12 03:17:14 +08:00
parent 7c70300ec5
commit 0c4897e677
6 changed files with 18 additions and 28 deletions
+7 -12
View File
@@ -7,31 +7,26 @@
# 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: a use after std::move, an RAII object or a return value thrown
# away, an integer stored as a character in a string, slicing, and similar
# mistakes these checks rarely report on correct code.
# 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,
bugprone-copy-constructor-init,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-nondeterministic-pointer-iteration-order,
bugprone-redundant-branch-condition,
bugprone-string-integer-assignment,
bugprone-suspicious-semicolon,
bugprone-unhandled-self-assignment,
bugprone-unused-local-non-trivial-variable,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
cppcoreguidelines-slicing,
misc-redundant-expression
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$'
+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;