summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-06-24 04:38:44 -0700
committerFuwn <[email protected]>2022-06-24 04:38:44 -0700
commit6841c656a0c5ead810f50405d4b3ac701380e51b (patch)
tree249fa166cc6c04c44cbbe1bb9f338ebe79dc86ce /src
parentci: push source to remote (diff)
downloadcait-6841c656a0c5ead810f50405d4b3ac701380e51b.tar.xz
cait-6841c656a0c5ead810f50405d4b3ac701380e51b.zip
fix(src): apply clang-tidy fixes
Diffstat (limited to 'src')
-rw-r--r--src/cli.cc10
-rw-r--r--src/context.cc16
-rw-r--r--src/parser.cc8
3 files changed, 17 insertions, 17 deletions
diff --git a/src/cli.cc b/src/cli.cc
index d74e327..b1f4eb4 100644
--- a/src/cli.cc
+++ b/src/cli.cc
@@ -51,18 +51,18 @@ cli::cli(int argc, char **argv) : _argc(argc), _argv(argv) {
auto cli::arg(int i) -> std::optional<std::string> {
if (i < this->_argc) {
return std::string(this->_argv[i]);
- } else {
- return std::nullopt;
}
+
+ return std::nullopt;
}
auto cli::option(const std::string &key)
-> std::optional<std::optional<std::string>> {
if (this->options.contains(key)) {
return this->options[key];
- } else {
- return std::nullopt;
}
+
+ return std::nullopt;
}
auto cli::look() -> int {
@@ -100,7 +100,7 @@ auto cli::look() -> int {
std::cout << "\n\n";
}
- for (auto &token_line : parser.nodes()) {
+ for (const auto &token_line : parser.nodes()) {
std::visit(
[](const auto &node) -> void {
std::cout << node.string() << '\n';
diff --git a/src/context.cc b/src/context.cc
index 1c1dce2..f34d55c 100644
--- a/src/context.cc
+++ b/src/context.cc
@@ -16,8 +16,6 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-#include <iostream>
-#include <optional>
#include <thread>
#include "context.hh"
@@ -27,7 +25,7 @@ namespace cait {
context::context(const parser &parser) {
this->jobs = std::thread::hardware_concurrency() + 2;
- for (auto &parse_node : parser.nodes()) {
+ for (const auto &parse_node : parser.nodes()) {
std::visit(
[this](auto &node) {
using T = std::decay_t<decltype(node)>;
@@ -54,9 +52,9 @@ context::context(const parser &parser) {
if (it == nullptr) {
return std::nullopt;
- } else {
- return *it;
}
+
+ return *it;
}
[[maybe_unused]] auto context::rule(const std::string &variable)
@@ -66,9 +64,9 @@ context::context(const parser &parser) {
if (it == nullptr) {
return std::nullopt;
- } else {
- return *it;
}
+
+ return *it;
}
[[maybe_unused]] auto context::build(const std::string &variable)
@@ -78,9 +76,9 @@ context::context(const parser &parser) {
if (it == nullptr) {
return std::nullopt;
- } else {
- return *it;
}
+
+ return *it;
}
} // namespace cait
diff --git a/src/parser.cc b/src/parser.cc
index e884287..7bbc388 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -32,11 +32,13 @@ token_bundle::token_bundle(std::size_t &_j, token_t &bundle_token,
template <typename T>
range_t<T>::range_t(T begin, T end) : _begin(begin), _end(end) {}
-template <typename T> T range_t<T>::begin() { return this->_begin; }
+template <typename T> auto range_t<T>::begin() -> T { return this->_begin; }
-template <typename T> T range_t<T>::end() { return this->_end; }
+template <typename T> auto range_t<T>::end() -> T { return this->_end; }
-template <typename T> range_t<T> range(T b, T e) { return range_t<T>(b, e); }
+template <typename T> auto range(T b, T e) -> range_t<T> {
+ return range_t<T>(b, e);
+}
parser::parser(token_tree &token_tree) {
this->fix_tree(token_tree);