From 702af004351ea516c8c2f63ea6b37e337575d760 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 5 Dec 2020 16:18:15 -0500 Subject: [PATCH] Revert "[clang-tidy] Remove redundant const" This reverts commit 55d103c491994472a3584e986e12f32a2861aa27. --- src/CLI2.cpp | 10 +++++----- src/CLI2.h | 10 +++++----- src/Context.cpp | 2 +- src/Context.h | 2 +- src/Lexer.cpp | 2 +- src/Lexer.h | 2 +- src/TDB2.cpp | 8 ++++---- src/TDB2.h | 8 ++++---- src/Task.cpp | 8 ++++---- src/Task.h | 8 ++++---- src/util.cpp | 6 +++--- src/util.h | 6 +++--- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 263cd3c64..c28138359 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -90,7 +90,7 @@ void A2::attribute (const std::string& name, const std::string& value) //////////////////////////////////////////////////////////////////////////////// // Accessor for attributes. -std::string A2::attribute (const std::string& name) const +const std::string A2::attribute (const std::string& name) const { // Prevent autovivification. auto i = _attributes.find (name); @@ -101,7 +101,7 @@ std::string A2::attribute (const std::string& name) const } //////////////////////////////////////////////////////////////////////////////// -std::string A2::getToken () const +const std::string A2::getToken () const { auto i = _attributes.find ("canonical"); if (i == _attributes.end ()) @@ -175,7 +175,7 @@ void A2::decompose () } //////////////////////////////////////////////////////////////////////////////// -std::string A2::dump () const +const std::string A2::dump () const { auto output = Lexer::typeToString (_lextype); @@ -638,7 +638,7 @@ void CLI2::prepareFilter () //////////////////////////////////////////////////////////////////////////////// // Return all the MISCELLANEOUS args. -std::vector CLI2::getWords () +const std::vector CLI2::getWords () { std::vector words; for (const auto& a : _args) @@ -710,7 +710,7 @@ std::string CLI2::getCommand (bool canonical) const } //////////////////////////////////////////////////////////////////////////////// -std::string CLI2::dump (const std::string& title) const +const std::string CLI2::dump (const std::string& title) const { std::stringstream out; diff --git a/src/CLI2.h b/src/CLI2.h index c61ff193f..c3a4f4e18 100644 --- a/src/CLI2.h +++ b/src/CLI2.h @@ -43,9 +43,9 @@ public: void tag (const std::string&); void unTag (const std::string&); void attribute (const std::string&, const std::string&); - std::string attribute (const std::string&) const; - std::string getToken () const; - std::string dump () const; + const std::string attribute (const std::string&) const; + const std::string getToken () const; + const std::string dump () const; void decompose (); public: @@ -75,11 +75,11 @@ public: void addFilter (const std::string& arg); void addContextFilter (); void prepareFilter (); - std::vector getWords (); + const std::vector getWords (); bool canonicalize (std::string&, const std::string&, const std::string&) const; std::string getBinary () const; std::string getCommand (bool canonical = true) const; - std::string dump (const std::string& title = "CLI2 Parser") const; + const std::string dump (const std::string& title = "CLI2 Parser") const; private: void handleArg0 (); diff --git a/src/Context.cpp b/src/Context.cpp index 386f58170..cc48c5ffd 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -1006,7 +1006,7 @@ bool Context::verbose (const std::string& token) } //////////////////////////////////////////////////////////////////////////////// -std::vector Context::getColumns () const +const std::vector Context::getColumns () const { std::vector output; for (auto& col : columns) diff --git a/src/Context.h b/src/Context.h index a9705cb08..e863e6530 100644 --- a/src/Context.h +++ b/src/Context.h @@ -57,7 +57,7 @@ public: int getWidth (); // determine terminal width int getHeight (); // determine terminal height - std::vector getColumns () const; + const std::vector getColumns () const; void getLimits (int&, int&); bool color (); // TTY or ? diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 1f769b37b..31bd263f1 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -114,7 +114,7 @@ std::vector Lexer::split (const std::string& text) //////////////////////////////////////////////////////////////////////////////// // No L10N - these are for internal purposes. -std::string Lexer::typeName (const Lexer::Type& type) +const std::string Lexer::typeName (const Lexer::Type& type) { switch (type) { diff --git a/src/Lexer.h b/src/Lexer.h index 25a603ebc..7c5cbfd02 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -60,7 +60,7 @@ public: static std::string typeToString (Lexer::Type); // Static helpers. - static std::string typeName (const Lexer::Type&); + static const std::string typeName (const Lexer::Type&); static bool isIdentifierStart (int); static bool isIdentifierNext (int); static bool isSingleCharOperator (int); diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 02b04f4a0..004b30454 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -555,7 +555,7 @@ void TF2::dependency_scan () } //////////////////////////////////////////////////////////////////////////////// -std::string TF2::dump () +const std::string TF2::dump () { Color red ("rgb500 on rgb100"); Color yellow ("rgb550 on rgb220"); @@ -1307,7 +1307,7 @@ int TDB2::latest_id () } //////////////////////////////////////////////////////////////////////////////// -std::vector TDB2::all_tasks () +const std::vector TDB2::all_tasks () { std::vector all (pending._tasks.size () + pending._added_tasks.size () + @@ -1350,7 +1350,7 @@ bool TDB2::has (const std::string& uuid) } //////////////////////////////////////////////////////////////////////////////// -std::vector TDB2::siblings (Task& task) +const std::vector TDB2::siblings (Task& task) { std::vector results; if (task.has ("parent")) @@ -1385,7 +1385,7 @@ std::vector TDB2::siblings (Task& task) } //////////////////////////////////////////////////////////////////////////////// -std::vector TDB2::children (Task& task) +const std::vector TDB2::children (Task& task) { std::vector results; std::string parent = task.get ("uuid"); diff --git a/src/TDB2.h b/src/TDB2.h index 32245aef1..98288e500 100644 --- a/src/TDB2.h +++ b/src/TDB2.h @@ -72,7 +72,7 @@ public: void has_ids (); void auto_dep_scan (); void clear (); - std::string dump (); + const std::string dump (); void dependency_scan (); @@ -121,12 +121,12 @@ public: int latest_id (); // Generalized task accessors. - std::vector all_tasks (); + const std::vector all_tasks (); bool get (int, Task&); bool get (const std::string&, Task&); bool has (const std::string&); - std::vector siblings (Task&); - std::vector children (Task&); + const std::vector siblings (Task&); + const std::vector children (Task&); // ID <--> UUID mapping. std::string uuid (int); diff --git a/src/Task.cpp b/src/Task.cpp index dcd694281..81c4cd57a 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -167,7 +167,7 @@ std::string Task::statusToText (Task::status s) //////////////////////////////////////////////////////////////////////////////// // Returns a proper handle to the task. Tasks should not be referenced by UUIDs // as long as they have non-zero ID. -std::string Task::identifier (bool shortened /* = false */) const +const std::string Task::identifier (bool shortened /* = false */) const { if (id != 0) return format (id); @@ -207,7 +207,7 @@ std::vector Task::all () } //////////////////////////////////////////////////////////////////////////////// -std::string Task::get (const std::string& name) const +const std::string Task::get (const std::string& name) const { auto i = data.find (name); if (i != data.end ()) @@ -1695,7 +1695,7 @@ void Task::validate_before (const std::string& left, const std::string& right) // Encode values prior to serialization. // [ -> &open; // ] -> &close; -std::string Task::encode (const std::string& value) const +const std::string Task::encode (const std::string& value) const { auto modified = str_replace (value, "[", "&open;"); return str_replace (modified, "]", "&close;"); @@ -1705,7 +1705,7 @@ std::string Task::encode (const std::string& value) const // Decode values after parse. // [ <- &open; // ] <- &close; -std::string Task::decode (const std::string& value) const +const std::string Task::decode (const std::string& value) const { if (value.find ('&') == std::string::npos) return value; diff --git a/src/Task.h b/src/Task.h index 06ea4e242..6d8f244c1 100644 --- a/src/Task.h +++ b/src/Task.h @@ -89,8 +89,8 @@ public: void setAsNow (const std::string&); bool has (const std::string&) const; std::vector all (); - std::string identifier (bool shortened = false) const; - std::string get (const std::string&) const; + const std::string identifier (bool shortened = false) const; + const std::string get (const std::string&) const; const std::string& get_ref (const std::string&) const; int get_int (const std::string&) const; unsigned long get_ulong (const std::string&) const; @@ -168,8 +168,8 @@ private: void parseJSON (const json::object*); void parseLegacy (const std::string&); void validate_before (const std::string&, const std::string&); - std::string encode (const std::string&) const; - std::string decode (const std::string&) const; + const std::string encode (const std::string&) const; + const std::string decode (const std::string&) const; public: float urgency_project () const; diff --git a/src/util.cpp b/src/util.cpp index a271385ce..01f83f043 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -159,7 +159,7 @@ void uuid_unparse_lower (uuid_t uu, char *out) } #endif -std::string uuid () +const std::string uuid () { uuid_t id; uuid_generate (id); @@ -198,7 +198,7 @@ std::string uuid () // - delimiter is the character used to split up projects into subprojects. // - defaults to the period, '.' // -std::string indentProject ( +const std::string indentProject ( const std::string& project, const std::string& whitespace /* = " " */, char delimiter /* = '.' */) @@ -226,7 +226,7 @@ std::string indentProject ( } //////////////////////////////////////////////////////////////////////////////// -std::vector extractParents ( +const std::vector extractParents ( const std::string& project, const char& delimiter /* = '.' */) { diff --git a/src/util.h b/src/util.h index fc4589cd9..1ae977695 100644 --- a/src/util.h +++ b/src/util.h @@ -45,14 +45,14 @@ int confirm4 (const std::string&); #ifndef HAVE_UUID_UNPARSE_LOWER void uuid_unparse_lower (uuid_t uu, char *out); #endif -std::string uuid (); +const std::string uuid (); -std::string indentProject ( +const std::string indentProject ( const std::string&, const std::string& whitespace = " ", char delimiter = '.'); -std::vector extractParents ( +const std::vector extractParents ( const std::string&, const char& delimiter = '.');