diff --git a/.clang-tidy b/.clang-tidy index 75262a658..fd47b8fc5 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,cert-*,performance-*,portability-*,modernize-use-auto,modernize-loop-convert,modernize-use-bool-literals,modernize-use-using,hicpp-uppercase-literal-suffix' +Checks: 'clang-diagnostic-*,clang-analyzer-*,cert-*,performance-*,portability-*,modernize-use-auto,modernize-loop-convert,modernize-use-bool-literals,modernize-use-using,hicpp-uppercase-literal-suffix,readability-make-member-function-const' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 3fab6cabc..423a53953 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -1288,7 +1288,7 @@ class universal_notifier_named_pipe_t : public universal_notifier_t { void make_pipe(const wchar_t *test_path); - void drain_excessive_data() { + void drain_excessive_data() const { // The pipe seems to have data on it, that won't go away. Read a big chunk out of it. We // don't read until it's exhausted, because if someone were to pipe say /dev/null, that // would cause us to hang! diff --git a/src/history_file.cpp b/src/history_file.cpp index 66cc2f548..75b905bf6 100644 --- a/src/history_file.cpp +++ b/src/history_file.cpp @@ -161,7 +161,7 @@ history_item_t history_file_contents_t::decode_item(size_t offset) const { return history_item_t{}; } -maybe_t history_file_contents_t::offset_of_next_item(size_t *cursor, time_t cutoff) { +maybe_t history_file_contents_t::offset_of_next_item(size_t *cursor, time_t cutoff) const { auto offset = size_t(-1); switch (this->type()) { case history_type_fish_2_0: diff --git a/src/history_file.h b/src/history_file.h index bc5992011..bdd24cfc8 100644 --- a/src/history_file.h +++ b/src/history_file.h @@ -29,7 +29,7 @@ class history_file_contents_t { /// The cursor should initially be 0. /// If cutoff is nonzero, skip items whose timestamp is newer than cutoff. /// \return the offset of the next item, or none() on end. - maybe_t offset_of_next_item(size_t *cursor, time_t cutoff); + maybe_t offset_of_next_item(size_t *cursor, time_t cutoff) const; /// Get the file type. history_file_type_t type() const { return type_; } diff --git a/src/signal.cpp b/src/signal.cpp index c17587cea..e4d1f1d7a 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -407,7 +407,7 @@ bool sigint_checker_t::check() { return changed; } -void sigint_checker_t::wait() { +void sigint_checker_t::wait() const { auto &tm = topic_monitor_t::principal(); generation_list_t gens{}; gens[topic_t::sighupint] = this->gen_; diff --git a/src/signal.h b/src/signal.h index af284f36c..88bec4c2a 100644 --- a/src/signal.h +++ b/src/signal.h @@ -45,7 +45,7 @@ class sigint_checker_t { bool check(); /// Wait until a sigint is delivered. - void wait(); + void wait() const; }; #endif diff --git a/src/wgetopt.cpp b/src/wgetopt.cpp index f64515763..127f8e919 100644 --- a/src/wgetopt.cpp +++ b/src/wgetopt.cpp @@ -302,7 +302,7 @@ void wgetopter_t::_update_long_opt(int argc, wchar_t **argv, const struct woptio // Find a matching long opt. const struct woption *wgetopter_t::_find_matching_long_opt(const struct woption *longopts, wchar_t *nameend, int *exact, int *ambig, - int *indfound) { + int *indfound) const { const struct woption *pfound = nullptr; int option_index = 0; diff --git a/src/wgetopt.h b/src/wgetopt.h index ae5ed0b21..496c27285 100644 --- a/src/wgetopt.h +++ b/src/wgetopt.h @@ -54,7 +54,7 @@ class wgetopter_t { bool _handle_long_opt(int argc, wchar_t **argv, const struct woption *longopts, int *longind, int long_only, int *retval); const struct woption *_find_matching_long_opt(const struct woption *longopts, wchar_t *nameend, - int *exact, int *ambig, int *indfound); + int *exact, int *ambig, int *indfound) const; void _update_long_opt(int argc, wchar_t **argv, const struct woption *pfound, wchar_t *nameend, int *longind, int option_index, int *retval); bool initialized = false; diff --git a/src/wutil.cpp b/src/wutil.cpp index 427260d1d..3eb90c507 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -206,7 +206,7 @@ dir_t::~dir_t() { bool dir_t::valid() const { return this->dir != nullptr; } -bool dir_t::read(wcstring &name) { return wreaddir(this->dir, name); } +bool dir_t::read(wcstring &name) const { return wreaddir(this->dir, name); } int wstat(const wcstring &file_name, struct stat *buf) { const cstring tmp = wcs2string(file_name); diff --git a/src/wutil.h b/src/wutil.h index c142e6853..db98b7221 100644 --- a/src/wutil.h +++ b/src/wutil.h @@ -173,7 +173,7 @@ struct file_id_t { struct dir_t { DIR *dir; bool valid() const; - bool read(wcstring &name); + bool read(wcstring &name) const; dir_t(const wcstring &path); ~dir_t(); };