Clean up some Cppcheck warnings by passing args as const refs (#4364)

This commit is contained in:
Steve Cotton 2019-09-20 09:34:19 +02:00 committed by GitHub
parent f5b6b50565
commit 5dcd2d301d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 22 additions and 22 deletions

View file

@ -168,7 +168,7 @@ bool check_names_legal_internal(const config& dir, std::string current_prefix, s
return badlist ? badlist->empty() : true;
}
bool check_case_insensitive_duplicates_internal(const config& dir, std::string prefix, std::vector<std::string>* badlist){
bool check_case_insensitive_duplicates_internal(const config& dir, const std::string& prefix, std::vector<std::string>* badlist){
typedef std::pair<bool, std::string> printed_and_original;
std::map<std::string, printed_and_original> filenames;
bool inserted;

View file

@ -1408,8 +1408,8 @@ public:
unsigned int rounds,
double a_hit_chance,
double b_hit_chance,
std::vector<combat_slice> a_split,
std::vector<combat_slice> b_split,
const std::vector<combat_slice>& a_split,
const std::vector<combat_slice>& b_split,
double a_initially_slowed_chance,
double b_initially_slowed_chance);
@ -1464,8 +1464,8 @@ monte_carlo_combat_matrix::monte_carlo_combat_matrix(unsigned int a_max_hp,
unsigned int rounds,
double a_hit_chance,
double b_hit_chance,
std::vector<combat_slice> a_split,
std::vector<combat_slice> b_split,
const std::vector<combat_slice>& a_split,
const std::vector<combat_slice>& b_split,
double a_initially_slowed_chance,
double b_initially_slowed_chance)
: combat_matrix(a_max_hp,

View file

@ -46,7 +46,7 @@ bool kde_style = false;
struct wnotify
{
wnotify(uint32_t id_arg, std::string owner_arg, std::string message_arg)
wnotify(uint32_t id_arg, const std::string & owner_arg, const std::string & message_arg)
: id(id_arg)
, owner(owner_arg)
, message(message_arg)

View file

@ -920,7 +920,7 @@ void display::render_buttons()
}
gui::button::TYPE display::string_to_button_type(std::string type)
gui::button::TYPE display::string_to_button_type(const std::string& type)
{
gui::button::TYPE res = gui::button::TYPE_PRESS;
if (type == "checkbox") { res = gui::button::TYPE_CHECK; }

View file

@ -392,7 +392,7 @@ public:
std::shared_ptr<gui::button> find_action_button(const std::string& id);
std::shared_ptr<gui::button> find_menu_button(const std::string& id);
static gui::button::TYPE string_to_button_type(std::string type);
static gui::button::TYPE string_to_button_type(const std::string& type);
void create_buttons();
void layout_buttons();

View file

@ -140,12 +140,12 @@ public:
// Setter methods
//
void set_game_name(std::string name)
void set_game_name(const std::string& name)
{
parameters_.name = name;
}
void set_game_password(std::string name)
void set_game_password(const std::string& name)
{
parameters_.password = name;
}

View file

@ -184,7 +184,7 @@ std::string make_short_name(const std::string& long_name)
return ss.str();
}
std::string make_game_type_marker(std::string text, bool color_for_missing)
std::string make_game_type_marker(const std::string& text, bool color_for_missing)
{
if(color_for_missing) {
return formatter() << "<b><span color='#f00'>[" << text << "]</span></b> ";

View file

@ -82,7 +82,7 @@ public:
bool jump_to_editor() const { return jump_to_editor_; }
void select_mp_server(std::string server) { multiplayer_server_ = server; }
void select_mp_server(const std::string& server) { multiplayer_server_ = server; }
bool play_multiplayer(mp_selection res);
bool play_multiplayer_commandline();
bool change_language();

View file

@ -67,7 +67,7 @@ static std::string format_level_string(const int level)
}
static std::string format_if_leader(unit_const_ptr u, const std::string str)
static std::string format_if_leader(unit_const_ptr u, const std::string& str)
{
return (*u).can_recruit() ? "<span color='#cdad00'>" + str + "</span>" : str;
}

View file

@ -251,7 +251,7 @@ public:
keycode_ = keycode;
}
void set_text(std::string text)
void set_text(const std::string& text)
{
text_ = text;
boost::algorithm::to_lower(text_);

View file

@ -128,8 +128,8 @@ public:
std::string help; //long help text
std::string usage; //only args info
std::string flags;
explicit command(command_handler h, const std::string help = "",
const std::string& usage = "", const std::string flags = "")
explicit command(command_handler h, const std::string& help = "",
const std::string& usage = "", const std::string& flags = "")
: handler(h), help(help), usage(usage), flags(flags)
{
}
@ -354,7 +354,7 @@ protected:
help_on_unknown_ = value;
}
//this is display-only
static void set_cmd_prefix(std::string value)
static void set_cmd_prefix(const std::string& value)
{
cmd_prefix_ = value;
}

View file

@ -59,7 +59,7 @@ void playturn_network_adapter::read_from_network()
//there should be no attributes left.
}
bool playturn_network_adapter::is_at_end()
bool playturn_network_adapter::is_at_end() const
{
assert(!data_.empty());
if (data_.size() > 1) return false;

View file

@ -33,7 +33,7 @@ public:
//after the call dst contains one child when returned true otherwise it's empty.
bool read(config& dst);
//returns false if there is still data in the internal buffer.
bool is_at_end();
bool is_at_end() const;
void set_source(source_type source);
//returns a function to be passed to set_source.
static source_type get_source_from_config(config& src);

View file

@ -62,7 +62,7 @@ static std::string get_calling_file(lua_State* L)
}
/// resolves @a filename to an absolute path
/// @returns true if the filename was successfully resolved.
static bool canonical_path(std::string& filename, std::string currentdir)
static bool canonical_path(std::string& filename, const std::string& currentdir)
{
if(filename.size() < 2) {
return false;
@ -109,7 +109,7 @@ static bool canonical_path(std::string& filename, std::string currentdir)
/// resolves @a filename to an absolute path
/// @returns true if the filename was successfully resolved.
static bool resolve_filename(std::string& filename, std::string currentdir, std::string* rel = nullptr)
static bool resolve_filename(std::string& filename, const std::string& currentdir, std::string* rel = nullptr)
{
if(!canonical_path(filename, currentdir)) {
return false;

View file

@ -971,7 +971,7 @@ struct dialog_tester<screenshot_notification>
template<>
struct dialog_tester<theme_list>
{
static theme_info make_theme(std::string name)
static theme_info make_theme(const std::string& name)
{
theme_info ti;
ti.id = name;