From 7b4a234f03947fa4bed10c3c641d7acfc72f88c7 Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Mon, 18 Dec 2023 22:20:38 +0100 Subject: [PATCH] Unify coding style Signed-off-by: Thomas Lauf --- src/AtomicFile.cpp | 6 +-- src/CLI.cpp | 28 ++++++------ src/CLI.h | 4 +- src/Chart.cpp | 76 ++++++++++++++++---------------- src/Chart.h | 4 +- src/ChartConfig.h | 2 +- src/Database.cpp | 20 ++++----- src/Database.h | 2 +- src/Datafile.cpp | 2 +- src/DatetimeParser.cpp | 2 +- src/ExtensionsTable.cpp | 6 +-- src/ExtensionsTable.h | 2 +- src/GapsTable.cpp | 10 +++-- src/GapsTable.h | 4 +- src/Interval.cpp | 12 ++--- src/Interval.h | 4 +- src/IntervalFactory.cpp | 6 +-- src/IntervalFilterAllInRange.cpp | 2 +- src/IntervalFilterAllWithIds.h | 4 +- src/IntervalFilterAndGroup.cpp | 4 +- src/IntervalFilterAndGroup.h | 4 +- src/Journal.cpp | 10 ++--- src/Journal.h | 2 +- src/Range.cpp | 6 +-- src/Range.h | 6 +-- src/Rules.cpp | 4 +- src/Rules.h | 25 ++++------- src/SummaryTable.cpp | 2 +- src/SummaryTable.h | 8 ++-- src/TagDescription.h | 2 +- src/Transaction.cpp | 2 +- src/Transaction.h | 4 +- src/TransactionsFactory.cpp | 10 ++--- src/commands/CmdAnnotate.cpp | 4 +- src/commands/CmdCancel.cpp | 2 +- src/commands/CmdChart.cpp | 2 +- src/commands/CmdConfig.cpp | 4 +- src/commands/CmdContinue.cpp | 2 +- src/commands/CmdDefault.cpp | 2 +- src/commands/CmdDelete.cpp | 2 +- src/commands/CmdHelp.cpp | 2 +- src/commands/CmdJoin.cpp | 2 +- src/commands/CmdLengthen.cpp | 2 +- src/commands/CmdModify.cpp | 2 +- src/commands/CmdMove.cpp | 2 +- src/commands/CmdReport.cpp | 2 +- src/commands/CmdResize.cpp | 2 +- src/commands/CmdRetag.cpp | 6 +-- src/commands/CmdShorten.cpp | 2 +- src/commands/CmdSplit.cpp | 2 +- src/commands/CmdSummary.cpp | 2 +- src/commands/CmdTag.cpp | 6 +-- src/commands/CmdUndo.cpp | 2 +- src/commands/CmdUntag.cpp | 6 +-- src/data.cpp | 4 +- src/dom.cpp | 2 +- src/paths.cpp | 32 +++++++------- src/timew.h | 2 +- src/validate.cpp | 4 +- test/AtomicFileTest.cpp | 4 +- test/DatetimeParser.t.cpp | 2 +- test/test.cpp | 10 ++--- test/test.h | 2 +- test/util.t.cpp | 2 +- 64 files changed, 201 insertions(+), 206 deletions(-) diff --git a/src/AtomicFile.cpp b/src/AtomicFile.cpp index 9f9fb5f3..2d200f40 100644 --- a/src/AtomicFile.cpp +++ b/src/AtomicFile.cpp @@ -141,7 +141,7 @@ bool AtomicFile::impl::exists () const //////////////////////////////////////////////////////////////////////////////// bool AtomicFile::impl::open () { - assert (!temp_file._data.empty () && !real_file._data.empty ()); + assert (! temp_file._data.empty () && ! real_file._data.empty ()); return real_file.open (); } @@ -231,7 +231,7 @@ void AtomicFile::impl::append (const std::string& content) { try { - if (!is_temp_active) + if (! is_temp_active) { is_temp_active = true; @@ -435,7 +435,7 @@ void AtomicFile::read (const Path& path, std::vector & lines) // finalize_all - Close / Flush all temporary files and rename to final. void AtomicFile::finalize_all () { - if (!impl::allow_atomics) + if (! impl::allow_atomics) { throw std::string {"Unable to update database."}; } diff --git a/src/CLI.cpp b/src/CLI.cpp index 5a075421..0846ab5b 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -550,7 +550,7 @@ bool CLI::exactMatch ( } //////////////////////////////////////////////////////////////////////////////// -std::set CLI::getIds () const +std::set CLI::getIds () const { std::set ids; @@ -614,9 +614,9 @@ Duration CLI::getDuration () const std::vector CLI::getDomReferences () const { - std::vector references; + std::vector references; - for (auto &arg : _args) + for (auto& arg : _args) { if (arg.hasTag ("DOM")) { @@ -722,7 +722,7 @@ Range CLI::getRange (const Range& default_range) const args[0] == "from" && args[1] == "") { - the_range = Range ({Datetime (start), 0}); + the_range = Range {Datetime (start), 0}; } // to/- else if (args.size () == 3 && @@ -730,7 +730,7 @@ Range CLI::getRange (const Range& default_range) const (args[1] == "to" || args[1] == "-") && args[2] == "") { - the_range = Range ({Datetime (start), Datetime (end)}); + the_range = Range {Datetime (start), Datetime (end)}; } // from to/- else if (args.size () == 4 && @@ -739,7 +739,7 @@ Range CLI::getRange (const Range& default_range) const (args[2] == "to" || args[2] == "-") && args[3] == "") { - the_range = Range ({Datetime (start), Datetime (end)}); + the_range = Range {Datetime (start), Datetime (end)}; } // for else if (args.size () == 3 && @@ -747,7 +747,7 @@ Range CLI::getRange (const Range& default_range) const args[1] == "for" && args[2] == "") { - the_range = Range ({Datetime (start), Datetime (start) + Duration (duration).toTime_t ()}); + the_range = Range {Datetime (start), Datetime (start) + Duration (duration).toTime_t ()}; } // from for else if (args.size () == 4 && @@ -756,7 +756,7 @@ Range CLI::getRange (const Range& default_range) const args[2] == "for" && args[3] == "") { - the_range = Range ({Datetime (start), Datetime (start) + Duration (duration).toTime_t ()}); + the_range = Range {Datetime (start), Datetime (start) + Duration (duration).toTime_t ()}; } // before else if (args.size () == 3 && @@ -764,7 +764,7 @@ Range CLI::getRange (const Range& default_range) const args[1] == "before" && args[2] == "") { - the_range = Range ({Datetime (start) - Duration (duration).toTime_t (), Datetime (start)}); + the_range = Range {Datetime (start) - Duration (duration).toTime_t (), Datetime (start)}; } // after else if (args.size () == 3 && @@ -772,27 +772,27 @@ Range CLI::getRange (const Range& default_range) const args[1] == "after" && args[2] == "") { - the_range = Range ({Datetime (start), Datetime (start) + Duration (duration).toTime_t ()}); + the_range = Range {Datetime (start), Datetime (start) + Duration (duration).toTime_t ()}; } // ago else if (args.size () == 2 && args[0] == "" && args[1] == "ago") { - the_range = Range ({now - Duration (duration).toTime_t (), 0}); + the_range = Range {now - Duration (duration).toTime_t (), 0}; } // for else if (args.size () == 2 && args[0] == "for" && args[1] == "") { - the_range = Range ({now - Duration (duration).toTime_t (), now}); + the_range = Range {now - Duration (duration).toTime_t (), now}; } // else if (args.size () == 1 && args[0] == "") { - the_range = Range ({now - Duration (duration).toTime_t (), now}); + the_range = Range {now - Duration (duration).toTime_t (), now}; } // :all else if (args.size () == 1 && args[0] == "") @@ -844,7 +844,7 @@ bool CLI::getComplementaryHint (const std::string& base, const bool default_valu } //////////////////////////////////////////////////////////////////////////////// -bool CLI::getHint (const std::string &base, const bool default_value) const +bool CLI::getHint (const std::string& base, const bool default_value) const { if (findHint (base)) { diff --git a/src/CLI.h b/src/CLI.h index 3fa349c5..6ee4d5a0 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -73,7 +73,7 @@ public: std::set getTags () const; std::string getAnnotation() const; Duration getDuration() const; - std::vector getDomReferences () const; + std::vector getDomReferences () const; Range getRange (const Range& default_range = {0, 0}) const; std::string dump (const std::string& title = "CLI Parser") const; @@ -86,7 +86,7 @@ private: void identifyFilter (); bool exactMatch (const std::string&, const std::string&) const; - bool findHint (const std::string &hint) const; + bool findHint (const std::string&) const; public: std::multimap _entities {}; diff --git a/src/Chart.cpp b/src/Chart.cpp index 1bbce6e5..466d4789 100644 --- a/src/Chart.cpp +++ b/src/Chart.cpp @@ -62,9 +62,9 @@ Chart::Chart (const ChartConfig& configuration) : std::string Chart::render ( const Range& range, - const std::vector &tracked, - const std::vector &exclusions, - const std::map &holidays) + const std::vector & tracked, + const std::vector & exclusions, + const std::map & holidays) { // Determine hours shown. auto hour_range = determine_hour_range @@ -86,13 +86,13 @@ std::string Chart::render ( out << '\n'; // Render the axis. - if (!with_internal_axis) + if (! with_internal_axis) { out << indent << renderAxis (first_hour, last_hour); } // For rendering labels on edge detection. - Datetime previous{0}; + Datetime previous {0}; // Each day is rendered separately. time_t total_work = 0; @@ -103,7 +103,7 @@ std::string Chart::render ( // Add an empty string with no color, to reserve width, so this function // can simply concatenate to lines[i].str (). - std::vector lines (num_lines); + std::vector lines (num_lines); for (int i = 0; i < num_lines; ++i) { lines[i].add (std::string (total_width, ' '), 0, Color ()); @@ -112,9 +112,9 @@ std::string Chart::render ( renderExclusionBlocks (lines, day, first_hour, last_hour, exclusions); time_t work = 0; - if (!show_intervals) + if (! show_intervals) { - for (auto &track : tracked) + for (auto& track : tracked) { time_t interval_work = 0; renderInterval (lines, day, track, first_hour, interval_work); @@ -171,9 +171,9 @@ unsigned long Chart::getIndentSize () //////////////////////////////////////////////////////////////////////////////// // Scan all tracked intervals, looking for the earliest and latest hour into // which an interval extends. -std::pair Chart::determineHourRange ( +std::pair Chart::determineHourRange ( const Range& range, - const std::vector &tracked) + const std::vector & tracked) { // If there is no data, show the whole day. if (tracked.empty ()) @@ -207,7 +207,7 @@ std::pair Chart::determineHourRange ( first_hour = clipped.start.hour (); } - if (!clipped.is_open () && clipped.end.hour () > last_hour) + if (! clipped.is_open () && clipped.end.hour () > last_hour) { last_hour = clipped.end.hour (); } @@ -251,7 +251,7 @@ std::string Chart::renderAxis (const int first_hour, const int last_hour) } //////////////////////////////////////////////////////////////////////////////// -std::string Chart::renderMonth (const Datetime &previous, const Datetime &day) +std::string Chart::renderMonth (const Datetime& previous, const Datetime& day) { const auto show_month = previous.month () != day.month (); @@ -264,7 +264,7 @@ std::string Chart::renderMonth (const Datetime &previous, const Datetime &day) } //////////////////////////////////////////////////////////////////////////////// -std::string Chart::renderWeek (const Datetime &previous, const Datetime &day) +std::string Chart::renderWeek (const Datetime& previous, const Datetime& day) { const auto show_week = previous.week () != day.week (); @@ -277,7 +277,7 @@ std::string Chart::renderWeek (const Datetime &previous, const Datetime &day) } //////////////////////////////////////////////////////////////////////////////// -std::string Chart::renderWeekday (Datetime &day, const Color &color) +std::string Chart::renderWeekday (Datetime& day, const Color& color) { std::stringstream out; @@ -288,7 +288,7 @@ std::string Chart::renderWeekday (Datetime &day, const Color &color) } //////////////////////////////////////////////////////////////////////////////// -std::string Chart::renderDay (Datetime &day, const Color &color) +std::string Chart::renderDay (Datetime& day, const Color& color) { std::stringstream out; @@ -300,15 +300,15 @@ std::string Chart::renderDay (Datetime &day, const Color &color) //////////////////////////////////////////////////////////////////////////////// Color Chart::getDayColor ( - const Datetime &day, - const std::map &holidays) + const Datetime& day, + const std::map & holidays) { if (day.sameDay (reference_datetime)) { return color_today; } - for (auto &entry : holidays) + for (auto& entry : holidays) { if (day.sameDay (entry.first)) { @@ -346,7 +346,7 @@ std::string Chart::renderTotal (time_t work) //////////////////////////////////////////////////////////////////////////////// std::string Chart::renderSubTotal ( time_t total_work, - const std::string &padding) + const std::string& padding) { std::stringstream out; @@ -366,8 +366,8 @@ std::string Chart::renderSubTotal ( } void Chart::renderExclusionBlocks ( - std::vector &lines, - const Datetime &day, + std::vector & lines, + const Datetime& day, int first_hour, int last_hour, const std::vector & exclusions) @@ -399,7 +399,7 @@ void Chart::renderExclusionBlocks ( int width = end_block - start_block; std::string block (width, ' '); - for (auto &line : lines) + for (auto& line : lines) { line.add (block, offset, color_exclusion); } @@ -420,15 +420,15 @@ void Chart::renderExclusionBlocks ( //////////////////////////////////////////////////////////////////////////////// void Chart::renderInterval ( - std::vector &lines, - const Datetime &day, - const Interval &track, + std::vector & lines, + const Datetime& day, + const Interval& track, const int first_hour, - time_t &work) + time_t& work) { // Ignore any track that doesn't overlap with day. auto day_range = getFullDay (day); - if (!day_range.overlaps (track) || (track.is_open () && day > reference_datetime)) + if (! day_range.overlaps (track) || (track.is_open () && day > reference_datetime)) { return; } @@ -476,9 +476,9 @@ void Chart::renderInterval ( label = format ("@{1}", track.id); } - for (auto &tag : track.tags ()) + for (auto& tag : track.tags ()) { - if (!label.empty ()) + if (! label.empty ()) { label += ' '; } @@ -490,7 +490,7 @@ void Chart::renderInterval ( if (width) { - std::vector text_lines; + std::vector text_lines; // -- // The hang/memory consumption in #309 is due to a bug in libshared's wrapText @@ -531,11 +531,11 @@ void Chart::renderInterval ( } //////////////////////////////////////////////////////////////////////////////// -std::string Chart::renderHolidays (const std::map &holidays) +std::string Chart::renderHolidays (const std::map & holidays) { std::stringstream out; - for (auto &entry : holidays) + for (auto& entry : holidays) { out << entry.first.toString ("Y-M-D") << " " @@ -548,15 +548,15 @@ std::string Chart::renderHolidays (const std::map &holida //////////////////////////////////////////////////////////////////////////////// std::string Chart::renderSummary ( - const std::string &indent, + const std::string& indent, const Range& range, - const std::vector &exclusions, - const std::vector &tracked) + const std::vector & exclusions, + const std::vector & tracked) { std::stringstream out; time_t total_unavailable = 0; - for (auto &exclusion : exclusions) + for (auto& exclusion : exclusions) { if (range.overlaps (exclusion)) { @@ -566,9 +566,9 @@ std::string Chart::renderSummary ( time_t total_worked = 0; - if (!show_intervals) + if (! show_intervals) { - for (auto &interval : tracked) + for (auto& interval : tracked) { if (range.overlaps (interval)) { diff --git a/src/Chart.h b/src/Chart.h index 8196f259..ce04476a 100644 --- a/src/Chart.h +++ b/src/Chart.h @@ -51,7 +51,7 @@ private: std::string renderWeekday (Datetime&, const Color&); void renderExclusionBlocks (std::vector &, const Datetime&, int, int, const std::vector &); - void renderInterval (std::vector&, const Datetime&, const Interval&, int, time_t&); + void renderInterval (std::vector &, const Datetime&, const Interval&, int, time_t&); unsigned long getIndentSize (); @@ -79,7 +79,7 @@ private: const Color color_holiday; const Color color_label; const Color color_exclusion; - const std::map tag_colors; + const std::map tag_colors; const int cell_width; const int reference_hour; diff --git a/src/ChartConfig.h b/src/ChartConfig.h index f6cc7bb1..be81b921 100644 --- a/src/ChartConfig.h +++ b/src/ChartConfig.h @@ -53,7 +53,7 @@ public: Color color_holiday; Color color_label; Color color_exclusion; - std::map tag_colors; + std::map tag_colors; }; #endif diff --git a/src/Database.cpp b/src/Database.cpp index ece4af71..9b2770e9 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -41,7 +41,7 @@ Database::iterator::iterator (files_iterator fbegin, files_iterator fend) : { if (files_end != files_it) { - auto &lines = files_it->allLines (); + auto& lines = files_it->allLines (); lines_it = lines.rbegin (); lines_end = lines.rend (); while ((lines_it == lines_end) && (files_it != files_end)) @@ -49,7 +49,7 @@ Database::iterator::iterator (files_iterator fbegin, files_iterator fend) : ++files_it; if (files_it != files_end) { - auto &lines = files_it->allLines (); + auto& lines = files_it->allLines (); lines_it = lines.rbegin (); lines_end = lines.rend (); } @@ -85,7 +85,7 @@ Database::iterator& Database::iterator::operator++ () } //////////////////////////////////////////////////////////////////////////////// -bool Database::iterator::operator== (const iterator &other) const +bool Database::iterator::operator== (const iterator& other) const { return (other.files_it == other.files_end) ? files_it == files_end : @@ -96,7 +96,7 @@ bool Database::iterator::operator== (const iterator &other) const } //////////////////////////////////////////////////////////////////////////////// -bool Database::iterator::operator!= (const iterator &other) const +bool Database::iterator::operator!= (const iterator& other) const { return ! (*this == other); } @@ -130,7 +130,7 @@ Database::reverse_iterator::reverse_iterator (files_iterator fbegin, ++files_it; if (files_it != files_end) { - auto &lines = files_it->allLines (); + auto& lines = files_it->allLines (); lines_it = lines.begin (); lines_end = lines.end (); } @@ -342,12 +342,12 @@ void Database::deleteInterval (const Interval& interval) // Interval belongs in a different file. void Database::modifyInterval (const Interval& from, const Interval& to, bool verbose) { - if (!from.empty ()) + if (! from.empty ()) { deleteInterval (from); } - if (!to.empty ()) + if (! to.empty ()) { addInterval (to, verbose); } @@ -468,7 +468,7 @@ void Database::initializeTagDatabase () { try { - std::unique_ptr json (dynamic_cast (json::parse (content))); + std::unique_ptr json (dynamic_cast (json::parse (content))); if (content.empty () || (json == nullptr)) { @@ -486,7 +486,7 @@ void Database::initializeTagDatabase () throw format ("Failed to find \"count\" member for tag \"{1}\" in tags database.", key); } - auto number = dynamic_cast (iter->second); + auto number = dynamic_cast (iter->second); _tagInfoDatabase.add (key, TagInfo{(unsigned int) number->_dvalue}); } @@ -515,7 +515,7 @@ void Database::initializeTagDatabase () return; } - if (!exists) + if (! exists) { std::cout << "Tags database does not exist. "; } diff --git a/src/Database.h b/src/Database.h index a428e528..9493e8d6 100644 --- a/src/Database.h +++ b/src/Database.h @@ -103,7 +103,7 @@ public: void addInterval (const Interval&, bool verbose); void deleteInterval (const Interval&); - void modifyInterval (const Interval&, const Interval &, bool verbose); + void modifyInterval (const Interval&, const Interval&, bool verbose); std::string dump () const; diff --git a/src/Datafile.cpp b/src/Datafile.cpp index 9d5adc8e..7811aa30 100644 --- a/src/Datafile.cpp +++ b/src/Datafile.cpp @@ -151,7 +151,7 @@ void Datafile::commit () if (_dirty) { AtomicFile file (_file); - if (!_lines.empty ()) + if (! _lines.empty ()) { if (file.open ()) { diff --git a/src/DatetimeParser.cpp b/src/DatetimeParser.cpp index 64498e22..bad798d7 100644 --- a/src/DatetimeParser.cpp +++ b/src/DatetimeParser.cpp @@ -1179,7 +1179,7 @@ bool DatetimeParser::initializeOrdinal (Pig& pig) y++; } } - else if (!Datetime::timeRelative && (d < number && number <= Datetime::daysInMonth (y, m))) + else if (! Datetime::timeRelative && (d < number && number <= Datetime::daysInMonth (y, m))) { if (--m < 1) { diff --git a/src/ExtensionsTable.cpp b/src/ExtensionsTable.cpp index 518ea5ab..06568926 100644 --- a/src/ExtensionsTable.cpp +++ b/src/ExtensionsTable.cpp @@ -53,7 +53,7 @@ Table ExtensionsTable::Builder::build () table.add ("Extension", true); table.add ("Status", true); - for (auto &ext: _extensions.all ()) + for (auto& ext: _extensions.all ()) { File program (ext); @@ -64,11 +64,11 @@ Table ExtensionsTable::Builder::build () // Show extension status. std::string status; - if (!program.readable ()) + if (! program.readable ()) { status = "Not readable"; } - else if (!program.executable ()) + else if (! program.executable ()) { status = "No executable"; } diff --git a/src/ExtensionsTable.h b/src/ExtensionsTable.h index 9b407e48..22939327 100644 --- a/src/ExtensionsTable.h +++ b/src/ExtensionsTable.h @@ -35,7 +35,7 @@ class ExtensionsTable class Builder { public: - Builder& withExtensions (const Extensions &); + Builder& withExtensions (const Extensions&); Table build (); diff --git a/src/GapsTable.cpp b/src/GapsTable.cpp index 5add61f1..cc829842 100644 --- a/src/GapsTable.cpp +++ b/src/GapsTable.cpp @@ -36,14 +36,14 @@ GapsTable::Builder GapsTable::builder () } /////////////////////////////////////////////////////////////////////////////// -GapsTable::Builder& GapsTable::Builder::withRange (const Range &range) +GapsTable::Builder& GapsTable::Builder::withRange (const Range& range) { _range = range; return *this; } /////////////////////////////////////////////////////////////////////////////// -GapsTable::Builder& GapsTable::Builder::withIntervals (const std::vector &intervals) +GapsTable::Builder& GapsTable::Builder::withIntervals (const std::vector & intervals) { _intervals = intervals; return *this; @@ -68,13 +68,14 @@ Table GapsTable::Builder::build () // Each day is rendered separately. time_t grand_total = 0; Datetime previous; + for (Datetime day = _range.start; day < _range.end; day++) { auto day_range = getFullDay (day); time_t daily_total = 0; - int row = -1; - for (auto &gap: subset (day_range, _intervals)) + + for (auto& gap: subset (day_range, _intervals)) { row = table.addRow (); @@ -88,6 +89,7 @@ Table GapsTable::Builder::build () // Intersect track with day. auto today = day_range.intersect (gap); + if (gap.is_open ()) { today.end = Datetime (); diff --git a/src/GapsTable.h b/src/GapsTable.h index b8ae36f7..6aa49f35 100644 --- a/src/GapsTable.h +++ b/src/GapsTable.h @@ -37,8 +37,8 @@ class GapsTable class Builder { public: - Builder& withRange (const Range &); - Builder& withIntervals (const std::vector &); + Builder& withRange (const Range&); + Builder& withIntervals (const std::vector &); Table build (); diff --git a/src/Interval.cpp b/src/Interval.cpp index eac237ea..203b1e27 100644 --- a/src/Interval.cpp +++ b/src/Interval.cpp @@ -79,7 +79,7 @@ void Interval::tag (const std::string& tag) } //////////////////////////////////////////////////////////////////////////////// -void Interval::tag (const std::set& tags) +void Interval::tag (const std::set & tags) { _tags.insert (tags.begin (), tags.end ()); } @@ -93,7 +93,7 @@ void Interval::untag (const std::string& tag) //////////////////////////////////////////////////////////////////////////////// void Interval::untag (const std::set & tags) { - std::set updated; + std::set updated; std::set_difference ( _tags.begin (), _tags.end (), @@ -144,7 +144,7 @@ std::string Interval::json () const std::stringstream out; out << "{"; - if (!empty ()) + if (! empty ()) { out << "\"id\":" << id; @@ -158,10 +158,10 @@ std::string Interval::json () const out << ",\"end\":\"" << end.toISO () << "\""; } - if (!_tags.empty ()) + if (! _tags.empty ()) { std::string tags; - for (auto &tag : _tags) + for (auto& tag : _tags) { if (tags[0]) tags += ','; @@ -174,7 +174,7 @@ std::string Interval::json () const << ']'; } - if (!annotation.empty ()) + if (! annotation.empty ()) { out << ",\"annotation\":\"" << json::encode (annotation) << "\""; } diff --git a/src/Interval.h b/src/Interval.h index 1580b04d..bc48aaa7 100644 --- a/src/Interval.h +++ b/src/Interval.h @@ -46,9 +46,9 @@ public: bool hasTag (const std::string&) const; const std::set & tags () const; void tag (const std::string&); - void tag (const std::set&); + void tag (const std::set &); void untag (const std::string&); - void untag (const std::set&); + void untag (const std::set &); void clearTags (); void setRange (const Range& range); diff --git a/src/IntervalFactory.cpp b/src/IntervalFactory.cpp index 079b7822..87582883 100644 --- a/src/IntervalFactory.cpp +++ b/src/IntervalFactory.cpp @@ -64,7 +64,7 @@ Interval IntervalFactory::fromSerialization (const std::string& line) std::vector tokens = tokenizeSerialization (line); // Minimal requirement 'inc'. - if (!tokens.empty () && tokens[0] == "inc") + if (! tokens.empty () && tokens[0] == "inc") { Interval interval = Interval (); @@ -125,9 +125,9 @@ Interval IntervalFactory::fromJson (const std::string& jsonString) { Interval interval = Interval (); - if (!jsonString.empty ()) + if (! jsonString.empty ()) { - std::unique_ptr json (dynamic_cast (json::parse (jsonString))); + std::unique_ptr json (dynamic_cast (json::parse (jsonString))); json::array* tags = (json::array*) json->_data["tags"]; diff --git a/src/IntervalFilterAllInRange.cpp b/src/IntervalFilterAllInRange.cpp index a3a11d23..a9f8d0fd 100644 --- a/src/IntervalFilterAllInRange.cpp +++ b/src/IntervalFilterAllInRange.cpp @@ -36,7 +36,7 @@ bool IntervalFilterAllInRange::accepts (const Interval& interval) return false; } - if ((!_range.is_started() && !_range.is_ended()) || interval.intersects (_range)) + if ((! _range.is_started() && ! _range.is_ended()) || interval.intersects (_range)) { return true; } diff --git a/src/IntervalFilterAllWithIds.h b/src/IntervalFilterAllWithIds.h index b28625a6..03acbbf7 100644 --- a/src/IntervalFilterAllWithIds.h +++ b/src/IntervalFilterAllWithIds.h @@ -42,8 +42,8 @@ public: private: const std::set _ids {}; - std::set::iterator _id_it; - std::set::iterator _id_end; + std::set ::iterator _id_it; + std::set ::iterator _id_end; }; #endif //INCLUDE_INTERVALFILTERALLWITHIDS diff --git a/src/IntervalFilterAndGroup.cpp b/src/IntervalFilterAndGroup.cpp index c4f8d570..68ceaec5 100644 --- a/src/IntervalFilterAndGroup.cpp +++ b/src/IntervalFilterAndGroup.cpp @@ -26,10 +26,10 @@ #include -IntervalFilterAndGroup::IntervalFilterAndGroup (std::vector > filters) : _filters (std::move (filters)) +IntervalFilterAndGroup::IntervalFilterAndGroup (std::vector > filters) : _filters (std::move (filters)) {} -bool IntervalFilterAndGroup::accepts (const Interval &interval) +bool IntervalFilterAndGroup::accepts (const Interval& interval) { if (is_done ()) { diff --git a/src/IntervalFilterAndGroup.h b/src/IntervalFilterAndGroup.h index 03c40d98..9e59a447 100644 --- a/src/IntervalFilterAndGroup.h +++ b/src/IntervalFilterAndGroup.h @@ -33,13 +33,13 @@ class IntervalFilterAndGroup : public IntervalFilter { public: - explicit IntervalFilterAndGroup (std::vector > filters); + explicit IntervalFilterAndGroup (std::vector > filters); bool accepts (const Interval&) final; void reset () override; private: - const std::vector> _filters = {}; + const std::vector > _filters = {}; }; #endif //INCLUDED_INTERVALFILTERANDGROUP diff --git a/src/Journal.cpp b/src/Journal.cpp index 8616da04..e0709d23 100644 --- a/src/Journal.cpp +++ b/src/Journal.cpp @@ -39,7 +39,7 @@ bool Journal::enabled () const //////////////////////////////////////////////////////////////////////////////// -std::vector loadJournal (AtomicFile& undo) +std::vector loadJournal (AtomicFile& undo) { std::vector read_lines; undo.read (read_lines); @@ -88,7 +88,7 @@ void Journal::startTransaction () //////////////////////////////////////////////////////////////////////////////// void Journal::endTransaction () { - if (!enabled ()) + if (! enabled ()) { assert (_currentTransaction == nullptr); return; @@ -149,9 +149,9 @@ void Journal::recordIntervalAction (const std::string& before, const std::strin // Actions are only recorded if a transaction is open // void Journal::recordUndoAction ( - const std::string &type, - const std::string &before, - const std::string &after) + const std::string& type, + const std::string& before, + const std::string& after) { if (enabled () && _currentTransaction != nullptr) { diff --git a/src/Journal.h b/src/Journal.h index 9742bccd..4d9d4c29 100644 --- a/src/Journal.h +++ b/src/Journal.h @@ -51,7 +51,7 @@ public: Transaction popLastTransaction(); private: - void recordUndoAction (const std::string &, const std::string &, const std::string &); + void recordUndoAction (const std::string&, const std::string&, const std::string&); std::string _location {}; std::shared_ptr _currentTransaction = nullptr; diff --git a/src/Range.cpp b/src/Range.cpp index 98a0d26c..b4436f19 100644 --- a/src/Range.cpp +++ b/src/Range.cpp @@ -99,7 +99,7 @@ bool Range::is_empty () const } //////////////////////////////////////////////////////////////////////////////// -bool Range::contains (const Datetime &datetime) const +bool Range::contains (const Datetime& datetime) const { return (! is_started () || start < datetime) && (! is_ended () || datetime < end); @@ -130,7 +130,7 @@ bool Range::contains (const Datetime &datetime) const // H [... // I [... // -bool Range::overlaps (const Range &other) const +bool Range::overlaps (const Range& other) const { if (! is_started () || ! other.is_started ()) return false; @@ -234,7 +234,7 @@ Range Range::intersect (const Range& other) const } //////////////////////////////////////////////////////////////////////////////// -bool Range::intersects (const Range &other) const +bool Range::intersects (const Range& other) const { if (overlaps (other)) { return true; diff --git a/src/Range.h b/src/Range.h index 10d2c6b3..7d0c1a68 100644 --- a/src/Range.h +++ b/src/Range.h @@ -50,10 +50,10 @@ public: bool contains (const Datetime&) const; - bool overlaps (const Range &) const; + bool overlaps (const Range&) const; bool encloses (const Range&) const; - bool startsWithin (const Range &) const; - bool endsWithin (const Range &) const; + bool startsWithin (const Range&) const; + bool endsWithin (const Range&) const; Range intersect (const Range&) const; bool intersects (const Range&) const; Range combine (const Range&) const; diff --git a/src/Rules.cpp b/src/Rules.cpp index e59d0a28..05829398 100644 --- a/src/Rules.cpp +++ b/src/Rules.cpp @@ -150,7 +150,7 @@ bool Rules::has (const std::string& key) const //////////////////////////////////////////////////////////////////////////////// // Return the configuration value given the specified key. -std::string Rules::get (const std::string &key, const std::string &defaultValue) const +std::string Rules::get (const std::string& key, const std::string& defaultValue) const { auto found = _settings.find (key); @@ -429,7 +429,7 @@ void Rules::parseRuleSettings ( // If indent decreased. else if (indent < indents.back ()) { - while (!indents.empty () && indent != indents.back ()) + while (! indents.empty () && indent != indents.back ()) { indents.pop_back (); hierarchy.pop_back (); diff --git a/src/Rules.h b/src/Rules.h index 9d804aa9..8db6e249 100644 --- a/src/Rules.h +++ b/src/Rules.h @@ -42,32 +42,25 @@ public: std::string file () const; bool has (const std::string&) const; - std::string get (const std::string &key, const std::string &defaultValue = "") const; - int getInteger (const std::string&, int defaultValue = 0) const; + std::string get (const std::string&, const std::string& = "") const; + int getInteger (const std::string&, int = 0) const; double getReal (const std::string&) const; - bool getBoolean (const std::string&, bool defaultValue = false) const; + bool getBoolean (const std::string&, bool = false) const; - void set (const std::string&, const int); - void set (const std::string&, const double); + void set (const std::string&, int); + void set (const std::string&, double); void set (const std::string&, const std::string&); - std::vector all (const std::string& stem = "") const; + std::vector all (const std::string& = "") const; bool isRuleType (const std::string&) const; std::string dump () const; - static bool setConfigVariable (Journal& journal, - const Rules& rules, - std::string name, - std::string value, - bool confirmation /* = false */); - static int unsetConfigVariable (Journal& journal, - const Rules& rules, - std::string name, - bool confirmation /* = false */); + static bool setConfigVariable (Journal&, const Rules&, std::string, std::string, bool confirmation); + static int unsetConfigVariable (Journal&, const Rules&, std::string, bool confirmation); private: - void parse (const std::string&, int next = 1); + void parse (const std::string&, int = 1); void parseRule (const std::string&); void parseRuleSettings (const std::vector &); diff --git a/src/SummaryTable.cpp b/src/SummaryTable.cpp index 1eed57b8..4ef9b696 100644 --- a/src/SummaryTable.cpp +++ b/src/SummaryTable.cpp @@ -104,7 +104,7 @@ SummaryTable::Builder& SummaryTable::Builder::withRange (const Range& range) } //////////////////////////////////////////////////////////////////////////////// -SummaryTable::Builder & SummaryTable::Builder::withIntervals (const std::vector& tracked) +SummaryTable::Builder & SummaryTable::Builder::withIntervals (const std::vector & tracked) { _tracked = tracked; return *this; diff --git a/src/SummaryTable.h b/src/SummaryTable.h index 21b6a7bd..fa323d72 100644 --- a/src/SummaryTable.h +++ b/src/SummaryTable.h @@ -38,9 +38,9 @@ class SummaryTable class Builder { public: - Builder& withWeekFormat (const std::string &); - Builder& withDateFormat (const std::string &); - Builder& withTimeFormat (const std::string &); + Builder& withWeekFormat (const std::string&); + Builder& withDateFormat (const std::string&); + Builder& withTimeFormat (const std::string&); Builder& withAnnotations (bool); Builder& withIds (bool, Color); @@ -48,7 +48,7 @@ class SummaryTable Builder& withWeeks (bool); Builder& withWeekdays (bool); - Builder& withRange (const Range &); + Builder& withRange (const Range&); Builder& withIntervals (const std::vector &); Table build (); diff --git a/src/TagDescription.h b/src/TagDescription.h index 03c530f7..14b0e998 100644 --- a/src/TagDescription.h +++ b/src/TagDescription.h @@ -32,7 +32,7 @@ class TagDescription { public: - TagDescription (std::string , Color, std::string ); + TagDescription (std::string , Color, std::string); std::string name; Color color; diff --git a/src/Transaction.cpp b/src/Transaction.cpp index 7db06254..77d5fc77 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -34,7 +34,7 @@ void Transaction::addUndoAction ( _actions.emplace_back (type, before, after); } -std::vector Transaction::getActions () const +std::vector Transaction::getActions () const { return _actions; } diff --git a/src/Transaction.h b/src/Transaction.h index ee0838d9..2c32b54e 100644 --- a/src/Transaction.h +++ b/src/Transaction.h @@ -37,10 +37,10 @@ public: std::string toString() const; - std::vector getActions () const; + std::vector getActions () const; private: - std::vector _actions {}; + std::vector _actions {}; }; #endif diff --git a/src/TransactionsFactory.cpp b/src/TransactionsFactory.cpp index 26699159..140d1ea4 100644 --- a/src/TransactionsFactory.cpp +++ b/src/TransactionsFactory.cpp @@ -29,19 +29,19 @@ void TransactionsFactory::parseLine (const std::string& line) { - if (!line.compare (0, 4, "txn:")) + if (! line.compare (0, 4, "txn:")) { _transactions.emplace_back (); } - else if (!line.compare (0, 7, " type:")) + else if (! line.compare (0, 7, " type:")) { _type = line.substr (8, line.size ()); } - else if (!line.compare (0, 9, " before:")) + else if (! line.compare (0, 9, " before:")) { _before = line.substr (10, line.size ()); } - else if (!line.compare (0, 8, " after:")) + else if (! line.compare (0, 8, " after:")) { _after = line.substr (9, line.size ()); _transactions.back ().addUndoAction (_type, _before, _after); @@ -52,7 +52,7 @@ void TransactionsFactory::parseLine (const std::string& line) } } -std::vector TransactionsFactory::get () +std::vector TransactionsFactory::get () { return _transactions; } diff --git a/src/commands/CmdAnnotate.cpp b/src/commands/CmdAnnotate.cpp index 285cb0b3..55d503e5 100644 --- a/src/commands/CmdAnnotate.cpp +++ b/src/commands/CmdAnnotate.cpp @@ -57,7 +57,7 @@ int CmdAnnotate ( { throw std::string ("There is no active time tracking."); } - else if (!intervals.at (0).is_open ()) + else if (! intervals.at (0).is_open ()) { throw std::string ("At least one ID must be specified. See 'timew help annotate'."); } @@ -81,7 +81,7 @@ int CmdAnnotate ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdCancel.cpp b/src/commands/CmdCancel.cpp index 103f9cdf..c455ba74 100644 --- a/src/commands/CmdCancel.cpp +++ b/src/commands/CmdCancel.cpp @@ -39,7 +39,7 @@ int CmdCancel ( // If there is an open interval, cancel it by deleting it auto latest = getLatestInterval (database); - if (!latest.is_open ()) + if (! latest.is_open ()) { if (verbose) std::cout << "There is no active time tracking.\n"; diff --git a/src/commands/CmdChart.cpp b/src/commands/CmdChart.cpp index 1c18f527..7d26936d 100644 --- a/src/commands/CmdChart.cpp +++ b/src/commands/CmdChart.cpp @@ -175,7 +175,7 @@ std::map createHolidayMap (Rules& rules, Range& range) std::map mapping; auto holidays = rules.all ("holidays."); - for (auto &entry : holidays) + for (auto& entry : holidays) { auto first_dot = entry.find ('.'); auto last_dot = entry.rfind ('.'); diff --git a/src/commands/CmdConfig.cpp b/src/commands/CmdConfig.cpp index f754fac2..a3aca20d 100644 --- a/src/commands/CmdConfig.cpp +++ b/src/commands/CmdConfig.cpp @@ -87,7 +87,7 @@ int CmdConfig ( change = Rules::setConfigVariable (journal, rules, name, value, confirmation); - if (!change) + if (! change) { rc = 1; } @@ -107,7 +107,7 @@ int CmdConfig ( found = true; } - if (!found) + if (! found) { throw format ("No entry named '{1}' found.", name); } diff --git a/src/commands/CmdContinue.cpp b/src/commands/CmdContinue.cpp index e399d235..e743aae8 100644 --- a/src/commands/CmdContinue.cpp +++ b/src/commands/CmdContinue.cpp @@ -75,7 +75,7 @@ int CmdContinue ( throw format ("ID '@{1}' does not correspond to any tracking.", *ids.begin ()); } } - else if (!tags.empty ()) + else if (! tags.empty ()) { IntervalFilterFirstOf filtering {std::make_shared (tags)}; intervals = getTracked (database, rules, filtering); diff --git a/src/commands/CmdDefault.cpp b/src/commands/CmdDefault.cpp index eee7763c..1dec3703 100644 --- a/src/commands/CmdDefault.cpp +++ b/src/commands/CmdDefault.cpp @@ -40,7 +40,7 @@ int CmdDefault (Rules& rules, Database& database) IntervalFilterFirstOf filtering (std::make_shared (Range {})); auto latest = getTracked (database, rules, filtering); - if (!latest.empty () && latest.at (0).is_open ()) + if (! latest.empty () && latest.at (0).is_open ()) { if (verbose) { diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index 0ce11786..c90fb246 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -66,7 +66,7 @@ int CmdDelete ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdHelp.cpp b/src/commands/CmdHelp.cpp index 74315629..c3656afa 100644 --- a/src/commands/CmdHelp.cpp +++ b/src/commands/CmdHelp.cpp @@ -69,7 +69,7 @@ int CmdHelpUsage (const Extensions& extensions) << " timew week [] [ ...]\n" << '\n'; - if (!extensions.all ().empty ()) + if (! extensions.all ().empty ()) { std::cout << "Extensions (extensions do not provide help):\n"; diff --git a/src/commands/CmdJoin.cpp b/src/commands/CmdJoin.cpp index 1521b2d3..8277c6b0 100644 --- a/src/commands/CmdJoin.cpp +++ b/src/commands/CmdJoin.cpp @@ -69,7 +69,7 @@ int CmdJoin ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdLengthen.cpp b/src/commands/CmdLengthen.cpp index 9f4c5c0f..7a1b606a 100644 --- a/src/commands/CmdLengthen.cpp +++ b/src/commands/CmdLengthen.cpp @@ -69,7 +69,7 @@ int CmdLengthen ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdModify.cpp b/src/commands/CmdModify.cpp index 09f5f57c..fa64a1b7 100644 --- a/src/commands/CmdModify.cpp +++ b/src/commands/CmdModify.cpp @@ -109,7 +109,7 @@ int CmdModify ( break; } - if (!modified.is_open () && (modified.start > modified.end)) + if (! modified.is_open () && (modified.start > modified.end)) { throw format ("Cannot modify interval @{1} where start is after end.", id); } diff --git a/src/commands/CmdMove.cpp b/src/commands/CmdMove.cpp index acd352f5..ccdae7dd 100644 --- a/src/commands/CmdMove.cpp +++ b/src/commands/CmdMove.cpp @@ -83,7 +83,7 @@ int CmdMove ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdReport.cpp b/src/commands/CmdReport.cpp index 92f27d7e..93a3d20a 100644 --- a/src/commands/CmdReport.cpp +++ b/src/commands/CmdReport.cpp @@ -76,7 +76,7 @@ static std::string findExtension ( return ""; } -std::string basename (const std::string &script_path) +std::string basename (const std::string& script_path) { const auto lastSlash = script_path.find_last_of ('/'); diff --git a/src/commands/CmdResize.cpp b/src/commands/CmdResize.cpp index 0e58b3fb..550531f9 100644 --- a/src/commands/CmdResize.cpp +++ b/src/commands/CmdResize.cpp @@ -68,7 +68,7 @@ int CmdResize ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdRetag.cpp b/src/commands/CmdRetag.cpp index 04ae17a4..c07a3c1e 100644 --- a/src/commands/CmdRetag.cpp +++ b/src/commands/CmdRetag.cpp @@ -43,7 +43,7 @@ int CmdRetag ( // Gather IDs and TAGs. std::set ids = cli.getIds (); - std::set tags = cli.getTags (); + std::set tags = cli.getTags (); if (tags.empty ()) { @@ -64,7 +64,7 @@ int CmdRetag ( { throw std::string ("There is no active time tracking."); } - else if (!latest.at (0).is_open ()) + else if (! latest.at (0).is_open ()) { throw std::string ("At least one ID must be specified. See 'timew help retag'."); } @@ -90,7 +90,7 @@ int CmdRetag ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdShorten.cpp b/src/commands/CmdShorten.cpp index 0a3b9990..e07cd157 100644 --- a/src/commands/CmdShorten.cpp +++ b/src/commands/CmdShorten.cpp @@ -69,7 +69,7 @@ int CmdShorten ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdSplit.cpp b/src/commands/CmdSplit.cpp index bf0d1611..085749d7 100644 --- a/src/commands/CmdSplit.cpp +++ b/src/commands/CmdSplit.cpp @@ -66,7 +66,7 @@ int CmdSplit ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdSummary.cpp b/src/commands/CmdSummary.cpp index 7d97485f..c73bcebd 100644 --- a/src/commands/CmdSummary.cpp +++ b/src/commands/CmdSummary.cpp @@ -123,7 +123,7 @@ int CmdSummary ( } //////////////////////////////////////////////////////////////////////////////// -std::string renderHolidays (const std::map& holidays) +std::string renderHolidays (const std::map & holidays) { std::stringstream out; diff --git a/src/commands/CmdTag.cpp b/src/commands/CmdTag.cpp index 4767ad77..deff4154 100644 --- a/src/commands/CmdTag.cpp +++ b/src/commands/CmdTag.cpp @@ -43,7 +43,7 @@ int CmdTag ( // Gather IDs and TAGs. std::set ids = cli.getIds (); - std::set tags = cli.getTags (); + std::set tags = cli.getTags (); if (tags.empty ()) { @@ -64,7 +64,7 @@ int CmdTag ( { throw std::string ("There is no active time tracking."); } - else if (!latest.at (0).is_open ()) + else if (! latest.at (0).is_open ()) { throw std::string ("At least one ID must be specified. See 'timew help tag'."); } @@ -90,7 +90,7 @@ int CmdTag ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/commands/CmdUndo.cpp b/src/commands/CmdUndo.cpp index d8a439e1..09235806 100644 --- a/src/commands/CmdUndo.cpp +++ b/src/commands/CmdUndo.cpp @@ -37,7 +37,7 @@ static void undoIntervalAction(UndoAction& action, Database& database) database.modifyInterval (after, before, false); } -static void undoConfigAction (UndoAction& action, Rules &rules, Journal& journal) +static void undoConfigAction (UndoAction& action, Rules& rules, Journal& journal) { const std::string& before = action.getBefore (); diff --git a/src/commands/CmdUntag.cpp b/src/commands/CmdUntag.cpp index c1a49537..5f4051a3 100644 --- a/src/commands/CmdUntag.cpp +++ b/src/commands/CmdUntag.cpp @@ -43,7 +43,7 @@ int CmdUntag ( // Gather IDs and TAGs. std::set ids = cli.getIds (); - std::set tags = cli.getTags (); + std::set tags = cli.getTags (); if (tags.empty ()) { @@ -64,7 +64,7 @@ int CmdUntag ( { throw std::string ("There is no active time tracking."); } - else if (!latest.at (0).is_open ()) + else if (! latest.at (0).is_open ()) { throw std::string ("At least one ID must be specified. See 'timew help untag'."); } @@ -90,7 +90,7 @@ int CmdUntag ( break; } } - if (!found) + if (! found) { throw format ("ID '@{1}' does not correspond to any tracking.", id); } diff --git a/src/data.cpp b/src/data.cpp index 7586c00c..00f862f9 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -119,7 +119,7 @@ std::vector getAllExclusions ( { for (auto& r : exclusion.ranges (range)) { - if (!r.is_empty ()) + if (! r.is_empty ()) { exclusionRanges.push_back (r); } @@ -331,7 +331,7 @@ std::vector subtractRanges ( // An interval matches a filter range if the start/end overlaps bool matchesRange (const Interval& interval, const Range& filter) { - return ((!filter.is_started () && !filter.is_ended ()) || interval.intersects (filter)); + return ((! filter.is_started () && ! filter.is_ended ()) || interval.intersects (filter)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/dom.cpp b/src/dom.cpp index 33edc5af..1836d4f1 100644 --- a/src/dom.cpp +++ b/src/dom.cpp @@ -132,7 +132,7 @@ bool domGet ( std::set tags; for (const auto& interval : tracked) { - for (const auto &tag : interval.tags ()) + for (const auto& tag : interval.tags ()) { tags.insert (tag); } diff --git a/src/paths.cpp b/src/paths.cpp index d4713570..6c4620a5 100644 --- a/src/paths.cpp +++ b/src/paths.cpp @@ -73,15 +73,15 @@ std::string configFile () { return configDir () + "/timewarrior.cfg"; } std::string dbDataDir () { return dbDir () + "/data"; } std::string extensionsDir () { return configDir () + "/extensions"; } -void initializeDirs (const CLI &cli, Rules &rules) +void initializeDirs (const CLI& cli, Rules& rules) { Directory configLocation = Directory (configDir ()); bool configDirExists = configLocation.exists (); if (configDirExists && - (!configLocation.readable () || - !configLocation.writable () || - !configLocation.executable ())) + (! configLocation.readable () || + ! configLocation.writable () || + ! configLocation.executable ())) { throw format ("Config is not readable at '{1}'", configLocation._data); } @@ -89,19 +89,19 @@ void initializeDirs (const CLI &cli, Rules &rules) Directory dbLocation = Directory (dbDir ()); bool dataLocationExists = dbLocation.exists (); if (dataLocationExists && - (!dbLocation.readable () || - !dbLocation.writable () || - !dbLocation.executable ())) + (! dbLocation.readable () || + ! dbLocation.writable () || + ! dbLocation.executable ())) { throw format ("Database is not readable at '{1}'", dbLocation._data); } std::string question = ""; - if (!configDirExists) + if (! configDirExists) { question += "Create new config in " + configLocation._data + "?"; } - if (!dataLocationExists && configLocation._data != dbLocation._data) + if (! dataLocationExists && configLocation._data != dbLocation._data) { if (question != "") { question += "\n"; @@ -109,15 +109,15 @@ void initializeDirs (const CLI &cli, Rules &rules) question += "Create new database in " + dbLocation._data + "?"; } - if (!configDirExists || !dataLocationExists) + if (! configDirExists || ! dataLocationExists) { if (cli.getHint ("yes", false) || confirm (question)) { - if (!configDirExists) + if (! configDirExists) { configLocation.create (0700); } - if (!dataLocationExists) + if (! dataLocationExists) { dbLocation.create (0700); } @@ -131,7 +131,7 @@ void initializeDirs (const CLI &cli, Rules &rules) // Create extensions subdirectory if necessary. Directory extensionsLocation (extensionsDir ()); - if (!extensionsLocation.exists ()) + if (! extensionsLocation.exists ()) { extensionsLocation.create (0700); } @@ -139,14 +139,14 @@ void initializeDirs (const CLI &cli, Rules &rules) // Create data subdirectory if necessary. Directory dbDataLocation (dbDataDir ()); - if (!dbDataLocation.exists ()) + if (! dbDataLocation.exists ()) { dbDataLocation.create (0700); } Path configFileLocation (configFile ()); - if (!configFileLocation.exists ()) + if (! configFileLocation.exists ()) { File (configFileLocation).create (0600); } @@ -162,7 +162,7 @@ void initializeDirs (const CLI &cli, Rules &rules) rules.set ("temp.config", configFileLocation); // Perhaps some subsequent code would like to know this is a new db and possibly a first run. - if (!dataLocationExists) + if (! dataLocationExists) rules.set ("temp.shiny", 1); } diff --git a/src/timew.h b/src/timew.h index dde812a9..15a35a56 100644 --- a/src/timew.h +++ b/src/timew.h @@ -90,7 +90,7 @@ void setDebugIndicator (const std::string&); void setDebugColor (const Color&); void debug (const std::string&); -// utiƀ.cpp +// util.cpp std::string escape (const std::string&, int); std::string quoteIfNeeded (const std::string&); std::string join(const std::string& glue, const std::set & array); diff --git a/src/validate.cpp b/src/validate.cpp index 14bf3e6c..153d5a40 100644 --- a/src/validate.cpp +++ b/src/validate.cpp @@ -174,7 +174,7 @@ static bool autoAdjust ( database.modifyInterval (overlap, modified, verbose); } } - else if (!start_within_overlap && end_within_overlap) + else if (! start_within_overlap && end_within_overlap) { // end date of new interval within old interval Interval modified {overlap}; @@ -189,7 +189,7 @@ static bool autoAdjust ( database.modifyInterval (overlap, modified, verbose); } } - else if (!start_within_overlap && !end_within_overlap) + else if (! start_within_overlap && ! end_within_overlap) { // new interval encloses old interval database.deleteInterval (overlap); diff --git a/test/AtomicFileTest.cpp b/test/AtomicFileTest.cpp index f4690384..10777597 100644 --- a/test/AtomicFileTest.cpp +++ b/test/AtomicFileTest.cpp @@ -77,7 +77,7 @@ public: } private: - static const std::vector test_points; + static const std::vector test_points; static std::stringstream cbuffer; static int external_cb_was_called; @@ -98,7 +98,7 @@ private: } }; -const std::vector FIU::test_points { +const std::vector FIU::test_points { "posix/stdio/gp/fputs", "posix/io/rw/write", }; diff --git a/test/DatetimeParser.t.cpp b/test/DatetimeParser.t.cpp index 3106a6b1..9fdd9fbe 100644 --- a/test/DatetimeParser.t.cpp +++ b/test/DatetimeParser.t.cpp @@ -55,7 +55,7 @@ void testParseClosedRange ( auto range = iso.parse_range (input); - t.ok (!range.is_open (), label + "[start,end)"); + t.ok (! range.is_open (), label + "[start,end)"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/test/test.cpp b/test/test.cpp index e01ede3e..aa4d9467 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -132,7 +132,7 @@ void UnitTest::ok (bool expression, const std::string& name) /////////////////////////////////////////////////////////////////////////////// void UnitTest::notok (bool expression, const std::string& name) { - ok (!expression, name); + ok (! expression, name); } /////////////////////////////////////////////////////////////////////////////// @@ -170,7 +170,7 @@ void UnitTest::is (double actual, double expected, double tolerance, const std:: } else { - report_failure (create_message (actual, expected, name)); + report_failure (create_message (actual, expected, name)); } } @@ -203,7 +203,7 @@ void UnitTest::is ( } else { - report_failure (create_message (actual, expected, name)); + report_failure (create_message (actual, expected, name)); } } @@ -219,7 +219,7 @@ void UnitTest::_is (T actual, T expected, const std::string& name) } else { - report_failure (create_message (actual, expected, name)); + report_failure (create_message (actual, expected, name)); } } @@ -259,7 +259,7 @@ void UnitTest::skip (const std::string& text) /////////////////////////////////////////////////////////////////////////////// template -std::string UnitTest::create_message (T actual, T expected, const std::string &name) +std::string UnitTest::create_message (T actual, T expected, const std::string& name) { std::stringstream message; diff --git a/test/test.h b/test/test.h index 2632757f..9b386fca 100644 --- a/test/test.h +++ b/test/test.h @@ -71,7 +71,7 @@ private: void report_skip (const std::string&); void report_status (const std::string&, const std::string&) const; - template void _is (T, T, const std::string &); + template void _is (T, T, const std::string&); template static std::string create_message (T, T, const std::string&); private: diff --git a/test/util.t.cpp b/test/util.t.cpp index c1ea34b9..492252b6 100644 --- a/test/util.t.cpp +++ b/test/util.t.cpp @@ -44,7 +44,7 @@ int main (int, char**) t.is (quoteIfNeeded ("f o o"), "\"f o o\"", "quoteIfNeeded 'f o o' --> '\"f o o\"'"); { - std::set unjoined; + std::set unjoined; std::string joined; joined = join("", unjoined);