Skip to content

Commit 0d745f4

Browse files
committed
Bug#33559796: Single-argument constructors should be explicit (patch #1)
This reduces the number of issues of type "Single - argument constructor may inadvertently be used as a type conversion constructor" as reported by Flint++ tool. Some of the reported issues were not addressed: - lines explicitly marked with NOLINT (like plugin/x/src/prepare_param_handler.h) - false positives (tool reports alignas() calls as constructors) - issues where objects were intended to be used with type conversion - constructors with "const std::string &" param, to accept literal strings as well Change-Id: I7eb6fabea7137fc7e81143f06ec7636b22f6ea97
1 parent 2a272bc commit 0d745f4

34 files changed

+44
-43
lines changed

client/base/debug_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Debug_options : public Abstract_options_provider {
4747
Constructs new debug options provider.
4848
@param program Pointer to main program class.
4949
*/
50-
Debug_options(Abstract_program *program);
50+
explicit Debug_options(Abstract_program *program);
5151
/**
5252
Creates all options that will be provided.
5353
Implementation of Abstract_options_provider virtual method.

client/base/help_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Help_options : public Abstract_options_provider {
4646
@param program Pointer to main program class, used to collect list of all
4747
options available in program.
4848
*/
49-
Help_options(Base::Abstract_program *program);
49+
explicit Help_options(Base::Abstract_program *program);
5050
/**
5151
Creates all options that will be provided.
5252
Implementation of Abstract_options_provider virtual method.

client/base/mysql_connection_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class Mysql_connection_options : public Composite_options_provider,
7878
function from multiple threads simultaneously is not thread safe.
7979
@param program Pointer to main program class.
8080
*/
81-
Mysql_connection_options(Abstract_program *program);
81+
explicit Mysql_connection_options(Abstract_program *program);
8282

8383
/**
8484
Creates all options that will be provided.

client/base/mysql_query_runner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Mysql_query_runner {
5252
/**
5353
Standard constructor based on MySQL connection.
5454
*/
55-
Mysql_query_runner(MYSQL *connection);
55+
explicit Mysql_query_runner(MYSQL *connection);
5656
/**
5757
Copy constructor.
5858
*/
@@ -200,7 +200,7 @@ class Mysql_query_runner {
200200

201201
class Store_result_helper {
202202
public:
203-
Store_result_helper(std::vector<const Row *> *result);
203+
explicit Store_result_helper(std::vector<const Row *> *result);
204204
std::function<int64(const Row &)> *get_result_callback();
205205

206206
private:

client/dump/abstract_connection_provider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Dump {
3737

3838
class Abstract_connection_provider : public I_connection_provider {
3939
protected:
40-
Abstract_connection_provider(
40+
explicit Abstract_connection_provider(
4141
Mysql::Tools::Base::I_connection_factory *connection_factory);
4242

4343
virtual Mysql::Tools::Base::Mysql_query_runner *create_new_runner(
@@ -49,7 +49,7 @@ class Abstract_connection_provider : public I_connection_provider {
4949

5050
class Message_handler_wrapper {
5151
public:
52-
Message_handler_wrapper(
52+
explicit Message_handler_wrapper(
5353
std::function<bool(const Mysql::Tools::Base::Message_data &)>
5454
*message_handler);
5555

client/dump/abstract_database_dump_task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Dump {
3737
*/
3838
class Abstract_database_dump_task : public Abstract_dump_task {
3939
public:
40-
Abstract_database_dump_task(Database *related_database);
40+
explicit Abstract_database_dump_task(Database *related_database);
4141

4242
/**
4343
Returns database the current task is created for.

client/dump/abstract_dump_task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Dump {
4242
*/
4343
class Abstract_dump_task : public Abstract_simple_dump_task {
4444
public:
45-
Abstract_dump_task(Abstract_data_object *related_object);
45+
explicit Abstract_dump_task(Abstract_data_object *related_object);
4646

4747
~Abstract_dump_task() override;
4848

client/dump/abstract_table_dump_task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Dump {
3737
*/
3838
class Abstract_table_dump_task : public Abstract_dump_task {
3939
public:
40-
Abstract_table_dump_task(Table *related_table);
40+
explicit Abstract_table_dump_task(Table *related_table);
4141

4242
/**
4343
Returns table the current task is created for.

client/dump/chain_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace Dump {
3333

3434
class Chain_data {
3535
public:
36-
Chain_data(uint64 chain_id);
36+
explicit Chain_data(uint64 chain_id);
3737

3838
void abort();
3939

client/dump/composite_message_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Composite_message_handler {
4343
&message_handlers);
4444

4545
private:
46-
Composite_message_handler(
46+
explicit Composite_message_handler(
4747
const std::vector<
4848
std::function<bool(const Mysql::Tools::Base::Message_data &)> *>
4949
&message_handlers);

0 commit comments

Comments
 (0)