From 1cc9890197bd17c9a1b4af26b34dd09be810b0fa Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 10 Oct 2026 16:55:10 +0200 Subject: [PATCH] refactor(sonar): mark converting constructors explicit (cpp:S1709) sound_source and the gl::object conversion operators stay implicit; they are relied upon by copy-list-initialisation and GL calls. Co-Authored-By: Claude Opus 5.5 --- environment/skydome.h | 2 +- extras/piped_proc.h | 2 +- gl/postfx.h | 4 ++-- gl/query.h | 2 +- gl/shader.h | 4 ++-- launcher/deferred_image.h | 4 ++-- network/backend/asio.h | 2 +- network/message.h | 2 +- network/network.h | 4 ++-- scene/sceneeditor.h | 2 +- scripting/ladderlogic.h | 2 +- utilities/Float3d.h | 2 +- utilities/dictionary.h | 2 +- widgets/popup.h | 2 +- widgets/vehiclelist.h | 2 +- world/Segment.h | 2 +- world/TractionPower.h | 2 +- world/mtable.h | 2 +- 18 files changed, 22 insertions(+), 22 deletions(-) diff --git a/environment/skydome.h b/environment/skydome.h index bf5f8533..477d731b 100644 --- a/environment/skydome.h +++ b/environment/skydome.h @@ -5,7 +5,7 @@ class CSkyDome { public: - CSkyDome( int const Tesselation = 54 ); + explicit CSkyDome( int const Tesselation = 54 ); ~CSkyDome(); void Generate(); void RebuildColors(); diff --git a/extras/piped_proc.h b/extras/piped_proc.h index b16c6b3d..e4f625ce 100644 --- a/extras/piped_proc.h +++ b/extras/piped_proc.h @@ -23,7 +23,7 @@ HANDLE pipe_wr = nullptr; #endif public: - piped_proc(std::string cmd, bool write = false); + explicit piped_proc(std::string cmd, bool write = false); size_t read(unsigned char *buf, size_t len); size_t write(unsigned char *buf, size_t len); ~piped_proc(); diff --git a/gl/postfx.h b/gl/postfx.h index cc0c5450..9ea4b719 100644 --- a/gl/postfx.h +++ b/gl/postfx.h @@ -15,8 +15,8 @@ namespace gl static std::shared_ptr vao; public: - postfx(const std::string &s); - postfx(const shader &s); + explicit postfx(const std::string &s); + explicit postfx(const shader &s); void attach(); void apply(opengl_texture &src, framebuffer *dst); diff --git a/gl/query.h b/gl/query.h index 67e62b4f..12445790 100644 --- a/gl/query.h +++ b/gl/query.h @@ -25,7 +25,7 @@ protected: GLenum glenum_target(targets target) const; public: - query(targets target); + explicit query(targets target); ~query(); void begin(); diff --git a/gl/shader.h b/gl/shader.h index fdda9af8..1bb45924 100644 --- a/gl/shader.h +++ b/gl/shader.h @@ -21,7 +21,7 @@ namespace gl #ifdef SHADERVALIDATOR_STANDALONE shader() = default; #endif - shader(const std::string &filename); + explicit shader(const std::string &filename); ~shader(); enum class components_e @@ -85,7 +85,7 @@ namespace gl { public: program(); - program(std::vector>); + explicit program(std::vector>); ~program(); using bindable::bind; diff --git a/launcher/deferred_image.h b/launcher/deferred_image.h index 6217fdc9..6ad2802a 100644 --- a/launcher/deferred_image.h +++ b/launcher/deferred_image.h @@ -11,11 +11,11 @@ public: static constexpr GLuint invalid_id { std::numeric_limits::max() }; deferred_image() = default; - deferred_image(const std::string &p) : path(p) { } + explicit deferred_image(const std::string &p) : path(p) { } deferred_image(const deferred_image&) = delete; deferred_image(deferred_image&&) = default; deferred_image &operator=(deferred_image&&) = default; - operator bool() const + explicit operator bool() const { return image != null_handle || !path.empty(); } diff --git a/network/backend/asio.h b/network/backend/asio.h index 68b63e2f..2bc4fc6b 100644 --- a/network/backend/asio.h +++ b/network/backend/asio.h @@ -18,7 +18,7 @@ namespace network::tcp friend class client; public: - connection(asio::io_context &io_ctx, bool client = false, size_t counter = 0); + explicit connection(asio::io_context &io_ctx, bool client = false, size_t counter = 0); ~connection(); void connected() override; diff --git a/network/message.h b/network/message.h index 8fbdfd64..38a16c00 100644 --- a/network/message.h +++ b/network/message.h @@ -18,7 +18,7 @@ struct message type_e type; - message(type_e t) : type(t) {} + explicit message(type_e t) : type(t) {} virtual void serialize(std::ostream &stream) const { /* message carries no payload */ } virtual void deserialize(std::istream &stream) { /* message carries no payload */ } virtual ~message() = default; diff --git a/network/network.h b/network/network.h index 5fcc17df..ebeba8d7 100644 --- a/network/network.h +++ b/network/network.h @@ -35,7 +35,7 @@ namespace network virtual void send_message(const message &msg) = 0; virtual void send_messages(const std::vector> &messages) = 0; - connection(bool client = false, size_t counter = 0); + explicit connection(bool client = false, size_t counter = 0); void set_handler(std::function handler); virtual void disconnect() = 0; @@ -63,7 +63,7 @@ namespace network command_queue::commands_map client_commands_queue; public: - server(std::shared_ptr buf); + explicit server(std::shared_ptr buf); void push_delta(const frame_info &msg); command_queue::commands_map pop_commands(); }; diff --git a/scene/sceneeditor.h b/scene/sceneeditor.h index c72bd081..63edd87a 100644 --- a/scene/sceneeditor.h +++ b/scene/sceneeditor.h @@ -19,7 +19,7 @@ struct node_snapshot { scene::basic_node *node; std::string data; - node_snapshot( scene::basic_node *Node ) : + explicit node_snapshot( scene::basic_node *Node ) : node( Node ) { if( Node != nullptr ) { Node->export_as_text( data ); } }; diff --git a/scripting/ladderlogic.h b/scripting/ladderlogic.h index 0d064508..df8a9b73 100644 --- a/scripting/ladderlogic.h +++ b/scripting/ladderlogic.h @@ -27,7 +27,7 @@ public: }; // constructors template - basic_element( basic_element::type_e Type = basic_element::type_e::variable, Args_ ...Args ); + explicit basic_element( basic_element::type_e Type = basic_element::type_e::variable, Args_ ...Args ); // methods // data access auto input() -> int &; diff --git a/utilities/Float3d.h b/utilities/Float3d.h index d61072ae..68feea2b 100644 --- a/utilities/Float3d.h +++ b/utilities/Float3d.h @@ -225,7 +225,7 @@ public: void deserialize_float64(std::istream&); void serialize_float32(std::ostream&) const; float4x4() = default; - float4x4(const float f[16]) + explicit float4x4(const float f[16]) { for (int i = 0; i < 16; ++i) e[i] = f[i]; diff --git a/utilities/dictionary.h b/utilities/dictionary.h index 1532b492..4b97e5cc 100644 --- a/utilities/dictionary.h +++ b/utilities/dictionary.h @@ -23,7 +23,7 @@ struct dictionary_source { keyvaluepair_sequence> vec2_lists; // constructors dictionary_source() = default; - dictionary_source( std::string const &Input ); + explicit dictionary_source( std::string const &Input ); // methods inline void insert( std::string const &Key, double const Value ) { floats.emplace_back( Key, Value ); } inline void insert( std::string const &Key, int const Value ) { integers.emplace_back( Key, Value ); } diff --git a/widgets/popup.h b/widgets/popup.h index 82c3f258..d91b9f8b 100644 --- a/widgets/popup.h +++ b/widgets/popup.h @@ -11,7 +11,7 @@ class popup static int id; public: - popup(ui_panel &panel); + explicit popup(ui_panel &panel); virtual ~popup(); virtual bool render(); diff --git a/widgets/vehiclelist.h b/widgets/vehiclelist.h index b1dd509a..b2143b94 100644 --- a/widgets/vehiclelist.h +++ b/widgets/vehiclelist.h @@ -8,7 +8,7 @@ class vehiclelist_panel : public ui_panel bool m_first_show = true; public: - vehiclelist_panel(ui_layer &parent); + explicit vehiclelist_panel(ui_layer &parent); void render_contents() override; }; diff --git a/world/Segment.h b/world/Segment.h index d6d1ae9b..a3c83ade 100644 --- a/world/Segment.h +++ b/world/Segment.h @@ -70,7 +70,7 @@ class TSegment public: bool bCurve = false; - TSegment(TTrack *owner); + explicit TSegment(TTrack *owner); bool Init(glm::dvec3 NewPoint1, glm::dvec3 NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0); bool Init(glm::dvec3 &NewPoint1, glm::dvec3 NewCPointOut, glm::dvec3 NewCPointIn, glm::dvec3 &NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0, bool bIsCurve = true); double diff --git a/world/TractionPower.h b/world/TractionPower.h index fd5d7384..61127ae0 100644 --- a/world/TractionPower.h +++ b/world/TractionPower.h @@ -19,7 +19,7 @@ class TTractionPowerSource : public scene::basic_node { public: // constructor - TTractionPowerSource( scene::node_data const &Nodedata ); + explicit TTractionPowerSource( scene::node_data const &Nodedata ); // methods void Init(double const u, double const i); bool Load(cParser *parser); diff --git a/world/mtable.h b/world/mtable.h index 7f1747a0..7f853899 100644 --- a/world/mtable.h +++ b/world/mtable.h @@ -81,7 +81,7 @@ class TTrainParameters bool UpdateMTable(double hh, double mm, std::string const &NewName); bool UpdateMTable( scenario_time const &Time, std::string const &NewName ); bool RewindTimeTable( std::string actualStationName ); - TTrainParameters( std::string const &NewTrainName = "none" ); + explicit TTrainParameters( std::string const &NewTrainName = "none" ); void NewName(std::string const &NewTrainName); void UpdateVelocity(int StationCount, double vActual); bool LoadTTfile(std::string scnpath, int iPlus, double vmax);