From 55d103c491994472a3584e986e12f32a2861aa27 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 27 Sep 2019 20:40:09 -0700 Subject: [PATCH] [clang-tidy] Remove redundant const Found with readability-const-return-type Signed-off-by: Rosen Penev --- 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 c28138359..263cd3c64 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. -const std::string A2::attribute (const std::string& name) const +std::string A2::attribute (const std::string& name) const { // Prevent autovivification. auto i = _attributes.find (name); @@ -101,7 +101,7 @@ const std::string A2::attribute (const std::string& name) const } //////////////////////////////////////////////////////////////////////////////// -const std::string A2::getToken () const +std::string A2::getToken () const { auto i = _attributes.find ("canonical"); if (i == _attributes.end ()) @@ -175,7 +175,7 @@ void A2::decompose () } //////////////////////////////////////////////////////////////////////////////// -const std::string A2::dump () const +std::string A2::dump () const { auto output = Lexer::typeToString (_lextype); @@ -638,7 +638,7 @@ void CLI2::prepareFilter () //////////////////////////////////////////////////////////////////////////////// // Return all the MISCELLANEOUS args. -const std::vector CLI2::getWords () +std::vector CLI2::getWords () { std::vector words; for (const auto& a : _args) @@ -710,7 +710,7 @@ std::string CLI2::getCommand (bool canonical) const } //////////////////////////////////////////////////////////////////////////////// -const std::string CLI2::dump (const std::string& title) const +std::string CLI2::dump (const std::string& title) const { std::stringstream out; diff --git a/src/CLI2.h b/src/CLI2.h index c3a4f4e18..c61ff193f 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&); - const std::string attribute (const std::string&) const; - const std::string getToken () const; - const std::string dump () const; + std::string attribute (const std::string&) const; + std::string getToken () const; + std::string dump () const; void decompose (); public: @@ -75,11 +75,11 @@ public: void addFilter (const std::string& arg); void addContextFilter (); void prepareFilter (); - const std::vector getWords (); + 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; - const std::string dump (const std::string& title = "CLI2 Parser") 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 cc48c5ffd..386f58170 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -1006,7 +1006,7 @@ bool Context::verbose (const std::string& token) } //////////////////////////////////////////////////////////////////////////////// -const std::vector Context::getColumns () const +std::vector Context::getColumns () const { std::vector output; for (auto& col : columns) diff --git a/src/Context.h b/src/Context.h index e863e6530..a9705cb08 100644 --- a/src/Context.h +++ b/src/Context.h @@ -57,7 +57,7 @@ public: int getWidth (); // determine terminal width int getHeight (); // determine terminal height - const std::vector getColumns () const; + std::vector getColumns () const; void getLimits (int&, int&); bool color (); // TTY or ? diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 31bd263f1..1f769b37b 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. -const std::string Lexer::typeName (const Lexer::Type& type) +std::string Lexer::typeName (const Lexer::Type& type) { switch (type) { diff --git a/src/Lexer.h b/src/Lexer.h index 7c5cbfd02..25a603ebc 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -60,7 +60,7 @@ public: static std::string typeToString (Lexer::Type); // Static helpers. - static const std::string typeName (const Lexer::Type&); + static 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 004b30454..02b04f4a0 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -555,7 +555,7 @@ void TF2::dependency_scan () } //////////////////////////////////////////////////////////////////////////////// -const std::string TF2::dump () +std::string TF2::dump () { Color red ("rgb500 on rgb100"); Color yellow ("rgb550 on rgb220"); @@ -1307,7 +1307,7 @@ int TDB2::latest_id () } //////////////////////////////////////////////////////////////////////////////// -const std::vector TDB2::all_tasks () +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) } //////////////////////////////////////////////////////////////////////////////// -const std::vector TDB2::siblings (Task& task) +std::vector TDB2::siblings (Task& task) { std::vector results; if (task.has ("parent")) @@ -1385,7 +1385,7 @@ const std::vector TDB2::siblings (Task& task) } //////////////////////////////////////////////////////////////////////////////// -const std::vector TDB2::children (Task& task) +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 98288e500..32245aef1 100644 --- a/src/TDB2.h +++ b/src/TDB2.h @@ -72,7 +72,7 @@ public: void has_ids (); void auto_dep_scan (); void clear (); - const std::string dump (); + std::string dump (); void dependency_scan (); @@ -121,12 +121,12 @@ public: int latest_id (); // Generalized task accessors. - const std::vector all_tasks (); + std::vector all_tasks (); bool get (int, Task&); bool get (const std::string&, Task&); bool has (const std::string&); - const std::vector siblings (Task&); - const std::vector children (Task&); + std::vector siblings (Task&); + std::vector children (Task&); // ID <--> UUID mapping. std::string uuid (int); diff --git a/src/Task.cpp b/src/Task.cpp index 81c4cd57a..dcd694281 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. -const std::string Task::identifier (bool shortened /* = false */) const +std::string Task::identifier (bool shortened /* = false */) const { if (id != 0) return format (id); @@ -207,7 +207,7 @@ std::vector Task::all () } //////////////////////////////////////////////////////////////////////////////// -const std::string Task::get (const std::string& name) 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; -const std::string Task::encode (const std::string& value) 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 @@ const std::string Task::encode (const std::string& value) const // Decode values after parse. // [ <- &open; // ] <- &close; -const std::string Task::decode (const std::string& value) 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 6d8f244c1..06ea4e242 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 (); - const std::string identifier (bool shortened = false) const; - const std::string get (const std::string&) const; + std::string identifier (bool shortened = false) 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&); - const std::string encode (const std::string&) const; - const std::string decode (const std::string&) const; + std::string encode (const std::string&) const; + std::string decode (const std::string&) const; public: float urgency_project () const; diff --git a/src/util.cpp b/src/util.cpp index 01f83f043..a271385ce 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -159,7 +159,7 @@ void uuid_unparse_lower (uuid_t uu, char *out) } #endif -const std::string uuid () +std::string uuid () { uuid_t id; uuid_generate (id); @@ -198,7 +198,7 @@ const std::string uuid () // - delimiter is the character used to split up projects into subprojects. // - defaults to the period, '.' // -const std::string indentProject ( +std::string indentProject ( const std::string& project, const std::string& whitespace /* = " " */, char delimiter /* = '.' */) @@ -226,7 +226,7 @@ const std::string indentProject ( } //////////////////////////////////////////////////////////////////////////////// -const std::vector extractParents ( +std::vector extractParents ( const std::string& project, const char& delimiter /* = '.' */) { diff --git a/src/util.h b/src/util.h index 1ae977695..fc4589cd9 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 -const std::string uuid (); +std::string uuid (); -const std::string indentProject ( +std::string indentProject ( const std::string&, const std::string& whitespace = " ", char delimiter = '.'); -const std::vector extractParents ( +std::vector extractParents ( const std::string&, const char& delimiter = '.');