[pre-commit.ci] pre-commit autoupdate (#3942)
Some checks are pending
checks / Check & Clippy (push) Waiting to run
checks / Formatting (push) Waiting to run
checks / Cargo Metadata (push) Waiting to run
release-tests / check-tarball (push) Waiting to run
tests / coverage (push) Waiting to run
tests / tests (Mac OS 12.latest) (push) Blocked by required conditions
tests / tests (Mac OS 13.latest) (push) Blocked by required conditions
tests / Cargo Test (push) Waiting to run
tests / tests (arch, Archlinux Base (Rolling), ubuntu-latest) (push) Blocked by required conditions
tests / tests (debiantesting, Debian Testing, ubuntu-latest) (push) Blocked by required conditions
tests / tests (fedora40, Fedora 40, ubuntu-latest) (push) Blocked by required conditions
tests / tests (fedora41, Fedora 41, ubuntu-latest) (push) Blocked by required conditions
tests / tests (opensuse, OpenSUSE Tumbleweed (Rolling), ubuntu-latest) (push) Blocked by required conditions
tests / tests (ubuntu2004, Ubuntu 20.04, ubuntu-latest) (push) Blocked by required conditions
tests / tests (ubuntu2204, Ubuntu 22.04, ubuntu-latest) (push) Blocked by required conditions

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/mirrors-clang-format: v20.1.8 → v21.1.0](https://github.com/pre-commit/mirrors-clang-format/compare/v20.1.8...v21.1.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
pre-commit-ci[bot] 2025-09-01 16:31:25 -04:00 committed by GitHub
parent f41a16a0a5
commit ed5e0a52a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 114 additions and 114 deletions

View file

@ -9,7 +9,7 @@ repos:
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.8
rev: v21.1.0
hooks:
- id: clang-format
types_or: [c++, c]

View file

@ -46,36 +46,36 @@ class Context {
Context() = default; // Default constructor
~Context(); // Destructor
Context(const Context &);
Context &operator=(const Context &);
Context(const Context&);
Context& operator=(const Context&);
static Context &getContext();
static void setContext(Context *);
static Context& getContext();
static void setContext(Context*);
int initialize(int, const char **); // all startup
int initialize(int, const char**); // all startup
int run();
int dispatch(std::string &); // command handler dispatch
int dispatch(std::string&); // command handler dispatch
int getWidth(); // determine terminal width
int getHeight(); // determine terminal height
std::string getTaskContext(const std::string &, std::string, bool fallback = true);
std::string getTaskContext(const std::string&, std::string, bool fallback = true);
const std::vector<std::string> getColumns() const;
void getLimits(int &, int &);
void getLimits(int&, int&);
bool color(); // TTY or <other>?
bool verbose(const std::string &); // Verbosity control
bool color(); // TTY or <other>?
bool verbose(const std::string&); // Verbosity control
void header(const std::string &); // Header message sink
void footnote(const std::string &); // Footnote message sink
void debug(const std::string &); // Debug message sink
void error(const std::string &); // Error message sink - non-maskable
void header(const std::string&); // Header message sink
void footnote(const std::string&); // Footnote message sink
void debug(const std::string&); // Debug message sink
void error(const std::string&); // Error message sink - non-maskable
void decomposeSortField(const std::string &, std::string &, bool &, bool &);
void debugTiming(const std::string &, const Timer &);
void decomposeSortField(const std::string&, std::string&, bool&, bool&);
void debugTiming(const std::string&, const Timer&);
CurrentTask withCurrentTask(const Task *);
CurrentTask withCurrentTask(const Task*);
friend class CurrentTask;
private:
@ -86,7 +86,7 @@ class Context {
void loadAliases();
void propagateDebug();
static Context *context;
static Context* context;
public:
CLI2 cli2{};
@ -104,8 +104,8 @@ class Context {
std::vector<std::string> footnotes{};
std::vector<std::string> errors{};
std::vector<std::string> debugMessages{};
std::map<std::string, Command *> commands{};
std::map<std::string, Column *> columns{};
std::map<std::string, Command*> commands{};
std::map<std::string, Column*> columns{};
int terminal_width{0};
int terminal_height{0};
@ -121,7 +121,7 @@ class Context {
long time_hooks_us{0};
// the current task for DOM references, or NULL if there is no task
const Task *currentTask{NULL};
const Task* currentTask{NULL};
};
////////////////////////////////////////////////////////////////////////////////
@ -132,10 +132,10 @@ class CurrentTask {
~CurrentTask();
private:
CurrentTask(Context &context, const Task *previous);
CurrentTask(Context& context, const Task* previous);
Context &context;
const Task *previous;
Context& context;
const Task* previous;
friend class Context;
};

View file

@ -33,43 +33,43 @@
#include <string>
#include <vector>
bool domSource(const std::string &, Variant &);
bool domSource(const std::string&, Variant&);
class Eval {
public:
Eval();
void addSource(bool (*fn)(const std::string &, Variant &));
void evaluateInfixExpression(const std::string &, Variant &) const;
void evaluatePostfixExpression(const std::string &, Variant &) const;
void compileExpression(const std::vector<std::pair<std::string, Lexer::Type>> &);
void evaluateCompiledExpression(Variant &);
void addSource(bool (*fn)(const std::string&, Variant&));
void evaluateInfixExpression(const std::string&, Variant&) const;
void evaluatePostfixExpression(const std::string&, Variant&) const;
void compileExpression(const std::vector<std::pair<std::string, Lexer::Type>>&);
void evaluateCompiledExpression(Variant&);
void debug(bool);
static std::vector<std::string> getOperators();
static std::vector<std::string> getBinaryOperators();
private:
void evaluatePostfixStack(const std::vector<std::pair<std::string, Lexer::Type>> &,
Variant &) const;
void infixToPostfix(std::vector<std::pair<std::string, Lexer::Type>> &) const;
void infixParse(std::vector<std::pair<std::string, Lexer::Type>> &) const;
bool parseLogical(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool parseRegex(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool parseEquality(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool parseComparative(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool parseArithmetic(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool parseGeometric(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool parseTag(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool parseUnary(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool parseExponent(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool parsePrimitive(std::vector<std::pair<std::string, Lexer::Type>> &, unsigned int &) const;
bool identifyOperator(const std::string &, char &, unsigned int &, char &) const;
void evaluatePostfixStack(const std::vector<std::pair<std::string, Lexer::Type>>&,
Variant&) const;
void infixToPostfix(std::vector<std::pair<std::string, Lexer::Type>>&) const;
void infixParse(std::vector<std::pair<std::string, Lexer::Type>>&) const;
bool parseLogical(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseRegex(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseEquality(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseComparative(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseArithmetic(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseGeometric(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseTag(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseUnary(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parseExponent(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool parsePrimitive(std::vector<std::pair<std::string, Lexer::Type>>&, unsigned int&) const;
bool identifyOperator(const std::string&, char&, unsigned int&, char&) const;
std::string dump(std::vector<std::pair<std::string, Lexer::Type>> &) const;
std::string dump(std::vector<std::pair<std::string, Lexer::Type>>&) const;
private:
std::vector<bool (*)(const std::string &, Variant &)> _sources{};
std::vector<bool (*)(const std::string&, Variant&)> _sources{};
bool _debug{false};
std::vector<std::pair<std::string, Lexer::Type>> _compiled{};
};

View file

@ -39,14 +39,14 @@
// type.
class Operation {
public:
explicit Operation(const tc::Operation &);
explicit Operation(const tc::Operation&);
Operation(const Operation &other) = default;
Operation &operator=(const Operation &other);
Operation(const Operation& other) = default;
Operation& operator=(const Operation& other);
// Create a vector of Operations given the result of `Replica::get_undo_operations` or
// `Replica::get_task_operations`. The resulting vector must not outlive the input `rust::Vec`.
static std::vector<Operation> operations(const rust::Vec<tc::Operation> &);
static std::vector<Operation> operations(const rust::Vec<tc::Operation>&);
// Methods from the underlying `tc::Operation`.
bool is_create() const { return op->is_create(); }
@ -79,10 +79,10 @@ class Operation {
// Define a partial order on Operations:
// - Create < Update < Delete < UndoPoint
// - Given two updates, sort by timestamp
bool operator<(const Operation &other) const;
bool operator<(const Operation& other) const;
private:
const tc::Operation *op;
const tc::Operation* op;
};
#endif

View file

@ -44,12 +44,12 @@ class TDB2 {
TDB2() = default;
void open_replica(const std::string &, bool create_if_missing, bool read_write);
void open_replica(const std::string&, bool create_if_missing, bool read_write);
void open_replica_in_memory();
void add(Task &);
void modify(Task &);
void purge(Task &);
void get_changes(std::vector<Task> &);
void add(Task&);
void modify(Task&);
void purge(Task&);
void get_changes(std::vector<Task>&);
void gc();
void expire_tasks();
int latest_id();
@ -58,20 +58,20 @@ class TDB2 {
const std::vector<Task> all_tasks();
const std::vector<Task> pending_tasks();
const std::vector<Task> completed_tasks();
bool get(int, Task &);
bool get(const std::string &, Task &);
bool has(const std::string &);
const std::vector<Task> siblings(Task &);
const std::vector<Task> children(Task &);
bool get(int, Task&);
bool get(const std::string&, Task&);
bool has(const std::string&);
const std::vector<Task> siblings(Task&);
const std::vector<Task> children(Task&);
// ID <--> UUID mapping.
std::string uuid(int);
int id(const std::string &);
int id(const std::string&);
int num_local_changes();
int num_reverts_possible();
rust::Box<tc::Replica> &replica();
rust::Box<tc::Replica>& replica();
private:
std::optional<rust::Box<tc::Replica>> _replica;
@ -85,8 +85,8 @@ class TDB2 {
// UUID -> Task containing all tasks modified in this invocation.
std::map<std::string, Task> changes;
const rust::Box<tc::WorkingSet> &working_set();
void maybe_add_undo_point(rust::Vec<tc::Operation> &);
const rust::Box<tc::WorkingSet>& working_set();
void maybe_add_undo_point(rust::Vec<tc::Operation>&);
};
#endif

View file

@ -66,32 +66,32 @@ Version Version::Current() { return Version(PACKAGE_VERSION); }
bool Version::is_valid() const { return major >= 0; }
////////////////////////////////////////////////////////////////////////////////
bool Version::operator<(const Version &other) const {
bool Version::operator<(const Version& other) const {
return std::tie(major, minor, patch) < std::tie(other.major, other.minor, other.patch);
}
////////////////////////////////////////////////////////////////////////////////
bool Version::operator<=(const Version &other) const {
bool Version::operator<=(const Version& other) const {
return std::tie(major, minor, patch) <= std::tie(other.major, other.minor, other.patch);
}
////////////////////////////////////////////////////////////////////////////////
bool Version::operator>(const Version &other) const {
bool Version::operator>(const Version& other) const {
return std::tie(major, minor, patch) > std::tie(other.major, other.minor, other.patch);
}
////////////////////////////////////////////////////////////////////////////////
bool Version::operator>=(const Version &other) const {
bool Version::operator>=(const Version& other) const {
return std::tie(major, minor, patch) >= std::tie(other.major, other.minor, other.patch);
}
////////////////////////////////////////////////////////////////////////////////
bool Version::operator==(const Version &other) const {
bool Version::operator==(const Version& other) const {
return std::tie(major, minor, patch) == std::tie(other.major, other.minor, other.patch);
}
////////////////////////////////////////////////////////////////////////////////
bool Version::operator!=(const Version &other) const {
bool Version::operator!=(const Version& other) const {
return std::tie(major, minor, patch) != std::tie(other.major, other.minor, other.patch);
}
@ -107,7 +107,7 @@ Version::operator std::string() const {
}
////////////////////////////////////////////////////////////////////////////////
std::ostream &operator<<(std::ostream &os, const Version &version) {
std::ostream& operator<<(std::ostream& os, const Version& version) {
os << std::string(version);
return os;
}

View file

@ -39,10 +39,10 @@ class Version {
// Create an invalid version.
Version() = default;
Version(const Version &other) = default;
Version(Version &&other) = default;
Version &operator=(const Version &) = default;
Version &operator=(Version &&) = default;
Version(const Version& other) = default;
Version(Version&& other) = default;
Version& operator=(const Version&) = default;
Version& operator=(Version&&) = default;
// Return a version representing the release being built.
static Version Current();
@ -50,17 +50,17 @@ class Version {
bool is_valid() const;
// Compare versions.
bool operator<(const Version &) const;
bool operator<=(const Version &) const;
bool operator>(const Version &) const;
bool operator>=(const Version &) const;
bool operator==(const Version &) const;
bool operator!=(const Version &) const;
bool operator<(const Version&) const;
bool operator<=(const Version&) const;
bool operator>(const Version&) const;
bool operator>=(const Version&) const;
bool operator==(const Version&) const;
bool operator!=(const Version&) const;
// Convert back to a string.
operator std::string() const;
friend std::ostream &operator<<(std::ostream &os, const Version &version);
friend std::ostream& operator<<(std::ostream& os, const Version& version);
private:
int major = -1;

View file

@ -35,10 +35,10 @@
class CmdImportV2 : public Command {
public:
CmdImportV2();
int execute(std::string &);
int execute(std::string&);
private:
int import(const std::vector<std::map<std::string, std::string>> &task_data);
int import(const std::vector<std::map<std::string, std::string>>& task_data);
};
#endif

View file

@ -58,7 +58,7 @@ CmdModify::CmdModify() {
}
////////////////////////////////////////////////////////////////////////////////
int CmdModify::execute(std::string &) {
int CmdModify::execute(std::string&) {
auto rc = 0;
// Apply filter.
@ -77,7 +77,7 @@ int CmdModify::execute(std::string &) {
if (filtered.size() > 1) {
feedback_affected("This command will alter {1} tasks.", filtered.size());
}
for (auto &task : filtered) {
for (auto& task : filtered) {
Task before(task);
task.modify(Task::modReplace);
@ -99,7 +99,7 @@ int CmdModify::execute(std::string &) {
}
// Now list the project changes.
for (const auto &change : projectChanges)
for (const auto& change : projectChanges)
if (change.first != "") Context::getContext().footnote(change.second);
feedback_affected(count == 1 ? "Modified {1} task." : "Modified {1} tasks.", count);
@ -108,7 +108,7 @@ int CmdModify::execute(std::string &) {
////////////////////////////////////////////////////////////////////////////////
// TODO Why is this not in Task::validate?
void CmdModify::checkConsistency(Task &before, Task &after) {
void CmdModify::checkConsistency(Task& before, Task& after) {
// Perform some logical consistency checks.
if (after.has("recur") && !after.has("due") && !before.has("due"))
throw std::string("You cannot specify a recurring task without a due date.");
@ -126,8 +126,8 @@ void CmdModify::checkConsistency(Task &before, Task &after) {
}
////////////////////////////////////////////////////////////////////////////////
int CmdModify::modifyAndUpdate(Task &before, Task &after,
std::map<std::string, std::string> *projectChanges /* = NULL */) {
int CmdModify::modifyAndUpdate(Task& before, Task& after,
std::map<std::string, std::string>* projectChanges /* = NULL */) {
// This task.
auto count = 1;
@ -150,14 +150,14 @@ int CmdModify::modifyAndUpdate(Task &before, Task &after,
////////////////////////////////////////////////////////////////////////////////
int CmdModify::modifyRecurrenceSiblings(
Task &task, std::map<std::string, std::string> *projectChanges /* = NULL */) {
Task& task, std::map<std::string, std::string>* projectChanges /* = NULL */) {
auto count = 0;
if ((Context::getContext().config.get("recurrence.confirmation") == "prompt" &&
confirm(STRING_CMD_MODIFY_RECUR)) ||
Context::getContext().config.getBoolean("recurrence.confirmation")) {
std::vector<Task> siblings = Context::getContext().tdb2.siblings(task);
for (auto &sibling : siblings) {
for (auto& sibling : siblings) {
Task alternate(sibling);
sibling.modify(Task::modReplace);
updateRecurrenceMask(sibling);
@ -181,7 +181,7 @@ int CmdModify::modifyRecurrenceSiblings(
////////////////////////////////////////////////////////////////////////////////
int CmdModify::modifyRecurrenceParent(
Task &task, std::map<std::string, std::string> *projectChanges /* = NULL */) {
Task& task, std::map<std::string, std::string>* projectChanges /* = NULL */) {
auto count = 0;
auto children = Context::getContext().tdb2.children(task);
@ -189,7 +189,7 @@ int CmdModify::modifyRecurrenceParent(
((Context::getContext().config.get("recurrence.confirmation") == "prompt" &&
confirm(STRING_CMD_MODIFY_RECUR)) ||
Context::getContext().config.getBoolean("recurrence.confirmation"))) {
for (auto &child : children) {
for (auto& child : children) {
Task alternate(child);
child.modify(Task::modReplace);
updateRecurrenceMask(child);

View file

@ -34,14 +34,14 @@
class CmdModify : public Command {
public:
CmdModify();
int execute(std::string &);
void checkConsistency(Task &before, Task &after);
int modifyAndUpdate(Task &before, Task &after,
std::map<std::string, std::string> *projectChanges = nullptr);
int modifyRecurrenceSiblings(Task &task,
std::map<std::string, std::string> *projectChanges = nullptr);
int modifyRecurrenceParent(Task &task,
std::map<std::string, std::string> *projectChanges = nullptr);
int execute(std::string&);
void checkConsistency(Task& before, Task& after);
int modifyAndUpdate(Task& before, Task& after,
std::map<std::string, std::string>* projectChanges = nullptr);
int modifyRecurrenceSiblings(Task& task,
std::map<std::string, std::string>* projectChanges = nullptr);
int modifyRecurrenceParent(Task& task,
std::map<std::string, std::string>* projectChanges = nullptr);
};
#endif

View file

@ -36,10 +36,10 @@
class CmdUndo : public Command {
public:
CmdUndo();
int execute(std::string &);
int execute(std::string&);
private:
bool confirm_revert(const std::vector<Operation> &);
bool confirm_revert(const std::vector<Operation>&);
};
#endif

View file

@ -46,11 +46,11 @@ int usage() {
} // namespace
////////////////////////////////////////////////////////////////////////////////
int main(int argc, char **argv) {
int main(int argc, char** argv) {
if (!--argc) {
return usage();
}
char *datadir = *++argv;
char* datadir = *++argv;
auto replica = tc::new_replica_on_disk(datadir, /*create_if_missing=*/true, /*read_write=*/true);
auto uuid = tc::uuid_v4();

View file

@ -41,7 +41,7 @@ std::string uuid2str(tc::Uuid uuid) { return static_cast<std::string>(uuid.to_st
// Tests for the basic cxxbridge functionality. This focuses on the methods with
// complex cxxbridge implementations, rather than those with complex Rust
// implementations but simple APIs, like sync.
int TEST_NAME(int, char **) {
int TEST_NAME(int, char**) {
UnitTest t;
std::string str;
@ -94,7 +94,7 @@ int TEST_NAME(int, char **) {
auto old_task = ops[5].get_old_task();
// old_task is in arbitrary order, so just check that status is in there.
bool found = false;
for (auto &pv : old_task) {
for (auto& pv : old_task) {
std::string p = static_cast<std::string>(pv.prop);
if (p == "status") {
std::string v = static_cast<std::string>(pv.value);
@ -131,7 +131,7 @@ int TEST_NAME(int, char **) {
auto all_tasks = replica->all_task_data();
t.is(all_tasks.size(), (size_t)2, "now there are 2 tasks");
for (auto &maybe_task : all_tasks) {
for (auto& maybe_task : all_tasks) {
t.ok(maybe_task.is_some(), "all_tasks is fully populated");
auto task = maybe_task.take();
if (task->get_uuid() == uuid) {
@ -144,7 +144,7 @@ int TEST_NAME(int, char **) {
try {
replica->sync_to_local("/does/not/exist", false);
// tc::new_replica_on_disk("/does/not/exist", false);
} catch (rust::Error &err) {
} catch (rust::Error& err) {
t.is(err.what(),
"unable to open database file: /does/not/exist/taskchampion-local-sync-server.sqlite3: "
"Error code 14: Unable to open the database file",