mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 09:27:38 +00:00
[clang-tidy] Simplify boolean expressions
Found with readability-simplify-boolean-expr Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
4087b2ee15
commit
7d1cc992e5
9 changed files with 9 additions and 19 deletions
|
@ -299,7 +299,7 @@ int builtin_functions(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
}
|
||||
|
||||
// Erase, desc, query, copy and list are mutually exclusive.
|
||||
bool describe = opts.description ? true : false;
|
||||
bool describe = opts.description != nullptr;
|
||||
if (describe + opts.erase + opts.list + opts.query + opts.copy > 1) {
|
||||
streams.err.append_format(BUILTIN_ERR_COMBO, cmd);
|
||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||
|
|
|
@ -60,10 +60,7 @@ static bool any_jobs_finished(size_t jobs_len, const parser_t &parser) {
|
|||
no_jobs_running = false;
|
||||
}
|
||||
}
|
||||
if (no_jobs_running) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return no_jobs_running;
|
||||
}
|
||||
|
||||
static int wait_for_backgrounds(parser_t &parser, bool any_flag) {
|
||||
|
|
|
@ -174,7 +174,7 @@ wcstring_list_t rgb_color_t::named_color_names() {
|
|||
wcstring_list_t result;
|
||||
result.reserve(1 + count);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (named_colors[i].hidden == false) {
|
||||
if (!named_colors[i].hidden) {
|
||||
result.push_back(named_colors[i].name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -902,7 +902,7 @@ bool completer_t::complete_param(const wcstring &cmd_orig, const wcstring &popt,
|
|||
// FLOGF(error, L"\nThinking about looking up completions for %ls\n", cmd.c_str());
|
||||
bool head_exists = builtin_exists(cmd);
|
||||
// Only reload environment variables if builtin_exists returned false, as an optimization
|
||||
if (head_exists == false) {
|
||||
if (!head_exists) {
|
||||
head_exists = function_exists_no_autoload(cmd);
|
||||
// While it may seem like first testing `path_get_path` before resorting to an env lookup
|
||||
// may be faster, path_get_path can potentially do a lot of FS/IO access, so env.get() +
|
||||
|
|
|
@ -1128,7 +1128,7 @@ bool exec_job(parser_t &parser, shared_ptr<job_t> j) {
|
|||
internal_exec(parser.vars(), j.get(), all_ios);
|
||||
// internal_exec only returns if it failed to set up redirections.
|
||||
// In case of an successful exec, this code is not reached.
|
||||
bool status = j->flags().negate ? false : true;
|
||||
bool status = !j->flags().negate;
|
||||
parser.set_last_statuses(statuses_t::just(status));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -671,8 +671,7 @@ static bool expand_cmdsubst(wcstring input, parser_t &parser, std::vector<comple
|
|||
}
|
||||
}
|
||||
|
||||
if (parser.get_last_status() == STATUS_READ_TOO_MUCH) return false;
|
||||
return true;
|
||||
return parser.get_last_status() != STATUS_READ_TOO_MUCH;
|
||||
}
|
||||
|
||||
// Given that input[0] is HOME_DIRECTORY or tilde (ugh), return the user's name. Return the empty
|
||||
|
|
|
@ -1239,10 +1239,7 @@ bool all_paths_are_valid(const path_list_t &paths, const wcstring &working_direc
|
|||
|
||||
static bool string_could_be_path(const wcstring &potential_path) {
|
||||
// Assume that things with leading dashes aren't paths.
|
||||
if (potential_path.empty() || potential_path.at(0) == L'-') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(potential_path.empty() || potential_path.at(0) == L'-');
|
||||
}
|
||||
|
||||
/// Very simple, just mark that we have no more pending items.
|
||||
|
|
|
@ -2240,9 +2240,7 @@ static bool selection_is_at_top() {
|
|||
if (row != 0 && row != PAGER_SELECTION_NONE) return false;
|
||||
|
||||
size_t col = pager->get_selected_column(data->current_page_rendering);
|
||||
if (col != 0 && col != PAGER_SELECTION_NONE) return false;
|
||||
|
||||
return true;
|
||||
return !(col != 0 && col != PAGER_SELECTION_NONE);
|
||||
}
|
||||
|
||||
static relaxed_atomic_t<uint64_t> run_count{0};
|
||||
|
|
|
@ -127,8 +127,7 @@ bool wreaddir_for_dirs(DIR *dir, wcstring *out_name) {
|
|||
if (result && out_name) {
|
||||
*out_name = str2wcstring(result->d_name);
|
||||
}
|
||||
if (!result) return false;
|
||||
return true;
|
||||
return result != nullptr;
|
||||
}
|
||||
|
||||
const wcstring wgetcwd() {
|
||||
|
|
Loading…
Reference in a new issue