From 334be56021add94abb8938deb99d435e50b7fae9 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 27 Sep 2020 17:36:23 -0700 Subject: [PATCH] run codebase through clang-tidy Signed-off-by: Rosen Penev --- src/builtin_complete.cpp | 2 +- src/complete.cpp | 11 +++++------ src/complete.h | 2 +- src/env_dispatch.cpp | 2 +- src/env_universal_common.cpp | 5 ++--- src/fish_tests.cpp | 2 +- src/history.cpp | 2 +- src/parse_execution.h | 2 +- src/wildcard.cpp | 2 +- src/wutil.h | 2 +- 10 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/builtin_complete.cpp b/src/builtin_complete.cpp index 64a8f4d3d..a2d44b348 100644 --- a/src/builtin_complete.cpp +++ b/src/builtin_complete.cpp @@ -108,7 +108,7 @@ static void builtin_complete_remove(const wcstring_list_t &cmds, const wcstring_ } } -static void builtin_complete_print(const wcstring cmd, io_streams_t &streams, parser_t &parser) { +static void builtin_complete_print(const wcstring &cmd, io_streams_t &streams, parser_t &parser) { const wcstring repr = complete_print(cmd); // colorize if interactive diff --git a/src/complete.cpp b/src/complete.cpp index 106923e54..981152c8a 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -404,10 +404,10 @@ class completer_t { std::set visited_wrapped_commands{}; }; - void complete_custom(const wcstring &cmd, const wcstring &cmdline, custom_arg_data_t *arg_data); + void complete_custom(const wcstring &cmd, const wcstring &cmdline, custom_arg_data_t *ad); - void walk_wrap_chain(const wcstring &cmd, const wcstring &cmdline, source_range_t cmd_range, - custom_arg_data_t *arg_data); + void walk_wrap_chain(const wcstring &cmd, const wcstring &cmdline, source_range_t cmdrange, + custom_arg_data_t *ad); cleanup_t apply_var_assignments(const wcstring_list_t &var_assignments); @@ -432,7 +432,7 @@ static owning_lock completion_autoloader{autoload_t(L"fish_complete_ /// Create a new completion entry. void append_completion(completion_list_t *completions, wcstring comp, wcstring desc, - complete_flags_t flags, string_fuzzy_match_t &&match) { + complete_flags_t flags, string_fuzzy_match_t match) { completions->emplace_back(std::move(comp), std::move(desc), match, flags); } @@ -1224,8 +1224,7 @@ bool completer_t::complete_variable(const wcstring &str, size_t start_offset) { } // Append matching environment variables - append_completion(&this->completions, std::move(comp), std::move(desc), flags, - std::move(match)); + append_completion(&this->completions, std::move(comp), std::move(desc), flags, match); res = true; } diff --git a/src/complete.h b/src/complete.h index ede677931..c060177d0 100644 --- a/src/complete.h +++ b/src/complete.h @@ -197,7 +197,7 @@ bool complete_is_valid_argument(const wcstring &str, const wcstring &opt, const /// \param flags completion flags void append_completion(completion_list_t *completions, wcstring comp, wcstring desc = wcstring(), int flags = 0, - string_fuzzy_match_t &&match = string_fuzzy_match_t(fuzzy_match_exact)); + string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact)); /// Support for "wrap targets." A wrap target is a command that completes like another command. bool complete_add_wrapper(const wcstring &command, const wcstring &new_target); diff --git a/src/env_dispatch.cpp b/src/env_dispatch.cpp index 6a57e40e0..cb8a08d48 100644 --- a/src/env_dispatch.cpp +++ b/src/env_dispatch.cpp @@ -402,7 +402,7 @@ static void update_fish_color_support(const environment_t &vars) { // Supporting versions of iTerm include a colon here. // We assume that if this is iTerm, it can't also be st, so having this check // inside is okay. - if (it->as_string().find(L":") != wcstring::npos) { + if (it->as_string().find(L':') != wcstring::npos) { FLOGF(term_support, L"Truecolor support: Enabling for ITERM"); support_term24bit = true; } diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index c47d22e4f..56758ac7c 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -444,9 +444,8 @@ std::string env_universal_t::serialize_with_vars(const var_table_t &vars) { contents.append("# VERSION: " UVARS_VERSION_3_0 "\n"); // Preserve legacy behavior by sorting the values first - typedef std::pair, - std::reference_wrapper> - env_pair_t; + using env_pair_t = + std::pair, std::reference_wrapper>; std::vector cloned(vars.begin(), vars.end()); std::sort(cloned.begin(), cloned.end(), [](const env_pair_t &p1, const env_pair_t &p2) { return p1.first.get() < p2.first.get(); diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 933afe96b..f1860afe1 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -1815,7 +1815,7 @@ static void test_escape_sequences() { class test_lru_t : public lru_cache_t { public: static constexpr size_t test_capacity = 16; - typedef std::pair value_type; + using value_type = std::pair; test_lru_t() : lru_cache_t(test_capacity) {} diff --git a/src/history.cpp b/src/history.cpp index e9d06cdc2..272dc370f 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1118,7 +1118,7 @@ static bool should_import_bash_history_line(const wcstring &line) { if (line.find(L"))") != std::string::npos) return false; // Skip lines with literal tabs since we don't handle them well and we don't know what they mean. // It could just be whitespace or it's actually passed somewhere (like e.g. `sed`). - if (line.find(L"\t") != std::string::npos) return false; + if (line.find(L'\t') != std::string::npos) return false; // Skip lines that end with a backslash. We do not handle multiline commands from bash history. if (line.back() == L'\\') return false; diff --git a/src/parse_execution.h b/src/parse_execution.h index 3c7428b06..5220d7937 100644 --- a/src/parse_execution.h +++ b/src/parse_execution.h @@ -87,7 +87,7 @@ class parse_execution_context_t { enum process_type_t process_type_for_command(const ast::decorated_statement_t &statement, const wcstring &cmd) const; end_execution_reason_t apply_variable_assignments( - process_t *proc, const ast::variable_assignment_list_t &variable_assignments, + process_t *proc, const ast::variable_assignment_list_t &variable_assignment_list, const block_t **block); // These create process_t structures from statements. diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 9cb3aaf0b..70e650ae5 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -268,7 +268,7 @@ static bool wildcard_complete_internal(const wchar_t *const str, size_t str_len, // Note: out_completion may be empty if the completion really is empty, e.g. tab-completing // 'foo' when a file 'foo' exists. complete_flags_t local_flags = flags | (full_replacement ? COMPLETE_REPLACES_TOKEN : 0); - append_completion(out, out_completion, out_desc, local_flags, std::move(match)); + append_completion(out, out_completion, out_desc, local_flags, match); return match_acceptable; } else if (next_wc_char_pos > 0) { // The literal portion of a wildcard cannot be longer than the string itself, diff --git a/src/wutil.h b/src/wutil.h index 7bb0f995d..54f5e8055 100644 --- a/src/wutil.h +++ b/src/wutil.h @@ -117,7 +117,7 @@ int wrename(const wcstring &oldName, const wcstring &newv); /// This does NOT retry on EINTR or EAGAIN, it simply returns. /// \return -1 on error in which case errno will have been set. In this event, the number of bytes /// actually written cannot be obtained. -ssize_t wwrite_to_fd(const wchar_t *s, size_t len, int fd); +ssize_t wwrite_to_fd(const wchar_t *input, size_t len, int fd); /// Variant of above that accepts a wcstring. inline ssize_t wwrite_to_fd(const wcstring &s, int fd) {