diff --git a/src/AtomicFile.cpp b/src/AtomicFile.cpp index 48d28814..92f722ee 100644 --- a/src/AtomicFile.cpp +++ b/src/AtomicFile.cpp @@ -51,7 +51,7 @@ struct AtomicFile::impl // the temp file until finalization. bool is_temp_active {false}; - impl (const Path& path); + explicit impl (const Path& path); ~impl (); std::string name () const; diff --git a/src/AtomicFile.h b/src/AtomicFile.h index 53a4deea..412677a8 100644 --- a/src/AtomicFile.h +++ b/src/AtomicFile.h @@ -34,8 +34,8 @@ class Path; class AtomicFile { public: - AtomicFile (const Path& path); - AtomicFile (std::string path); + explicit AtomicFile (const Path& path); + explicit AtomicFile (std::string path); AtomicFile (const AtomicFile&) = delete; AtomicFile (AtomicFile&&); AtomicFile& operator= (const AtomicFile&) = delete; diff --git a/src/CLI.cpp b/src/CLI.cpp index 2695c05c..0f61768e 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -557,7 +557,7 @@ std::set CLI::getIds() const for (auto& arg : _args) { if (arg.hasTag ("ID")) - ids.insert (strtol (arg.attribute ("value").c_str (), NULL, 10)); + ids.insert (strtol (arg.attribute ("value").c_str (), nullptr, 10)); } return ids; @@ -666,16 +666,16 @@ Interval CLI::getFilter (const Range& default_range) const { if (range.is_empty ()) { - args.emplace_back(""); + args.emplace_back (""); } else { start = range.start.toISO (); end = range.end.toISO (); - args.emplace_back(""); - args.emplace_back("-"); - args.emplace_back(""); + args.emplace_back (""); + args.emplace_back ("-"); + args.emplace_back (""); } } @@ -688,14 +688,14 @@ Interval CLI::getFilter (const Range& default_range) const else if (end.empty ()) end = raw; - args.emplace_back(""); + args.emplace_back (""); } else if (arg._lextype == Lexer::Type::duration) { if (duration.empty ()) duration = raw; - args.emplace_back(""); + args.emplace_back (""); } else if (arg.hasTag ("KEYWORD")) { diff --git a/src/Database.cpp b/src/Database.cpp index 94728dae..7f7f5c17 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -547,8 +547,8 @@ void Database::initializeDatafiles () file.find (".data") == file.length () - 5) { auto basename = Path (file).name (); - auto year = strtol (basename.substr (0, 4).c_str (), NULL, 10); - auto month = strtol (basename.substr (5, 2).c_str (), NULL, 10); + auto year = strtol (basename.substr (0, 4).c_str (), nullptr, 10); + auto month = strtol (basename.substr (5, 2).c_str (), nullptr, 10); getDatafile (year, month); } } diff --git a/src/Datafile.cpp b/src/Datafile.cpp index e1b23bc3..ee2f3328 100644 --- a/src/Datafile.cpp +++ b/src/Datafile.cpp @@ -41,8 +41,8 @@ void Datafile::initialize (const std::string& name) // From the name, which is of the form YYYY-MM.data, extract the YYYY and MM. auto basename = _file.name (); - auto year = strtol (basename.substr (0, 4).c_str (), NULL, 10); - auto month = strtol (basename.substr (5, 2).c_str (), NULL, 10); + auto year = strtol (basename.substr (0, 4).c_str (), nullptr, 10); + auto month = strtol (basename.substr (5, 2).c_str (), nullptr, 10); // The range is a month: [start, end). Datetime start (year, month, 1, 0, 0, 0); @@ -151,7 +151,7 @@ void Datafile::commit () if (_dirty) { AtomicFile file (_file); - if (_lines.size () > 0) + if (!_lines.empty ()) { if (file.open ()) { diff --git a/src/Range.cpp b/src/Range.cpp index cfc775e5..9da31df5 100644 --- a/src/Range.cpp +++ b/src/Range.cpp @@ -316,12 +316,12 @@ std::vector Range::subtract (const Range& other) const { if (start < other.start) { - results.emplace_back(start, other.start); + results.emplace_back (start, other.start); if (other.is_ended () && (! is_ended () || end > other.end)) { - results.emplace_back(other.end, end); + results.emplace_back (other.end, end); } } else @@ -331,11 +331,11 @@ std::vector Range::subtract (const Range& other) const if (is_ended ()) { if (end > other.end) - results.emplace_back(other.end, end); + results.emplace_back (other.end, end); } else { - results.emplace_back(other.end, end); + results.emplace_back (other.end, end); } } } diff --git a/src/Rules.cpp b/src/Rules.cpp index 3bca04c1..4c5ca6ad 100644 --- a/src/Rules.cpp +++ b/src/Rules.cpp @@ -605,7 +605,7 @@ bool Rules::setConfigVariable ( { // Add blank line required by rules. if (lines.empty () || lines.back ().empty ()) - lines.emplace_back(""); + lines.emplace_back (""); // Add new line. lines.push_back (name + " = " + json::encode (value)); @@ -626,7 +626,7 @@ bool Rules::setConfigVariable ( // Add blank line required by rules. if (lines.empty () || lines.back ().empty ()) - lines.emplace_back(""); + lines.emplace_back (""); // Add new line. lines.push_back (name + " = " + json::encode (value)); diff --git a/src/commands/CmdDiagnostics.cpp b/src/commands/CmdDiagnostics.cpp index d7966fd7..b07f7881 100644 --- a/src/commands/CmdDiagnostics.cpp +++ b/src/commands/CmdDiagnostics.cpp @@ -179,9 +179,9 @@ int CmdDiagnostics ( // Determine rc.editor/$EDITOR/$VISUAL. char* peditor; - if ((peditor = getenv ("VISUAL")) != NULL) + if ((peditor = getenv ("VISUAL")) != nullptr) out << " $VISUAL: " << peditor << '\n'; - else if ((peditor = getenv ("EDITOR")) != NULL) + else if ((peditor = getenv ("EDITOR")) != nullptr) out << " $EDITOR: " << peditor << '\n'; // Theme description, if present. diff --git a/src/commands/CmdGaps.cpp b/src/commands/CmdGaps.cpp index 479159fd..330a0099 100644 --- a/src/commands/CmdGaps.cpp +++ b/src/commands/CmdGaps.cpp @@ -84,7 +84,7 @@ int CmdGaps ( { table.set (row, 0, format ("W{1}", day.week ())); table.set (row, 1, day.toString ("Y-M-D")); - table.set (row, 2, day.dayNameShort (day.dayOfWeek ())); + table.set (row, 2, Datetime::dayNameShort (day.dayOfWeek ())); previous = day; } diff --git a/src/commands/CmdReport.cpp b/src/commands/CmdReport.cpp index 4de24864..30003717 100644 --- a/src/commands/CmdReport.cpp +++ b/src/commands/CmdReport.cpp @@ -161,7 +161,7 @@ int CmdReport ( // Run the extensions. std::vector output; int rc = extensions.callExtension (script_path, split (input, '\n'), output); - if (rc != 0 && output.size () == 0) + if (rc != 0 && output.empty ()) { throw format ("'{1}' returned {2} without producing output.", script_path, rc); } diff --git a/src/data.cpp b/src/data.cpp index 0904acfb..20f91e64 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -80,7 +80,7 @@ std::vector getAllExclusions ( // Load all exclusions from configuration. std::vector exclusions; for (auto& name : rules.all ("exclusions.")) - exclusions.emplace_back(lowerCase (name), rules.get (name)); + exclusions.emplace_back (lowerCase (name), rules.get (name)); debug (format ("Found {1} exclusions", exclusions.size ())); // Find exclusions 'exc day on ' and remove from holidays. diff --git a/test/test.h b/test/test.h index d06acc1b..f5f1e67e 100644 --- a/test/test.h +++ b/test/test.h @@ -33,7 +33,7 @@ class UnitTest { public: UnitTest (); - UnitTest (int); + explicit UnitTest (int); ~UnitTest (); void plan (int);