summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2026-04-28 22:42:48 +0200
committerJoel Klinghed <the_jk@spawned.biz>2026-04-28 22:43:08 +0200
commit665bb6a5202ad0ca30e60bec338ca65853c1b131 (patch)
tree4d938a3f1bc3160ac065d9a437f2c1b6eb724864
parent2f43e9123dc406112d0802a82698cd124f42a794 (diff)
Make clang-tidy happy
-rw-r--r--.clang-tidy2
-rw-r--r--src/args.hh8
-rw-r--r--src/buffer.hh4
-rw-r--r--src/csv.hh5
-rw-r--r--src/errors.cc4
-rw-r--r--src/errors.hh12
-rw-r--r--src/grammar.hh5
-rw-r--r--src/io.hh9
-rw-r--r--src/java_tokens.cc2
-rw-r--r--src/java_tokens.hh6
-rw-r--r--src/java_uescape.cc2
-rw-r--r--src/line.hh5
-rw-r--r--src/prefix_tree.hh5
-rw-r--r--src/u.hh2
-rw-r--r--src/uio.hh2
-rw-r--r--src/uline.hh10
-rw-r--r--src/unique_fd.hh5
17 files changed, 42 insertions, 46 deletions
diff --git a/.clang-tidy b/.clang-tidy
index bd4deb9..656d8ea 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,2 +1,2 @@
---
-Checks: 'bugprone-*,misc-*,modernize-*,performance-*,portability-*,readability-*,-bugprone-easily-swappable-parameters,-bugprone-unchecked-optional-access,-misc-non-private-member-variables-in-classes,-misc-const-correctness,-misc-no-recursion,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-magic-numbers,-readability-identifier-length,-readability-braces-around-statements,-readability-function-cognitive-complexity,-readability-redundant-inline-specifier,-readability-implicit-bool-conversion,-readability-qualified-auto'
+Checks: 'bugprone-*,misc-*,modernize-*,performance-*,portability-*,readability-*,-bugprone-easily-swappable-parameters,-bugprone-unchecked-optional-access,-misc-non-private-member-variables-in-classes,-misc-const-correctness,-misc-multiple-inheritance,-misc-no-recursion,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-magic-numbers,-readability-identifier-length,-readability-braces-around-statements,-readability-function-cognitive-complexity,-readability-redundant-inline-specifier,-readability-implicit-bool-conversion,-readability-qualified-auto'
diff --git a/src/args.hh b/src/args.hh
index 14f3716..c17bf9a 100644
--- a/src/args.hh
+++ b/src/args.hh
@@ -11,17 +11,19 @@
class Args {
public:
virtual ~Args() = default;
+ Args(Args const&) = delete;
+ Args& operator=(Args const&) = delete;
class Option {
public:
virtual ~Option() = default;
+ Option(Option const&) = delete;
+ Option& operator=(Option const&) = delete;
[[nodiscard]] virtual bool is_set() const = 0;
protected:
Option() = default;
- Option(Option const&) = delete;
- Option& operator=(Option const&) = delete;
};
class OptionArgument : public Option {
@@ -57,8 +59,6 @@ class Args {
protected:
Args() = default;
- Args(Args const&) = delete;
- Args& operator=(Args const&) = delete;
};
#endif // ARGS_HH
diff --git a/src/buffer.hh b/src/buffer.hh
index 685cd36..c1fb8e3 100644
--- a/src/buffer.hh
+++ b/src/buffer.hh
@@ -7,6 +7,8 @@
class Buffer {
public:
virtual ~Buffer() = default;
+ Buffer(Buffer const&) = delete;
+ Buffer& operator=(Buffer const&) = delete;
virtual void const* rptr(size_t& avail, size_t need = 1) = 0;
virtual void consume(size_t size) = 0;
@@ -24,8 +26,6 @@ class Buffer {
protected:
Buffer() = default;
- Buffer(Buffer const&) = delete;
- Buffer& operator=(Buffer const&) = delete;
};
#endif // BUFFER_HH
diff --git a/src/csv.hh b/src/csv.hh
index de9ed8c..28a7d34 100644
--- a/src/csv.hh
+++ b/src/csv.hh
@@ -16,6 +16,8 @@ namespace csv {
class Reader {
public:
virtual ~Reader() = default;
+ Reader(Reader const&) = delete;
+ Reader& operator=(Reader const&) = delete;
// Returned span is only valid until next call to read.
// Returns empty span at end-of-file and only then.
@@ -28,9 +30,6 @@ class Reader {
protected:
Reader() = default;
-
- Reader(Reader const&) = delete;
- Reader& operator=(Reader const&) = delete;
};
[[nodiscard]] std::unique_ptr<Reader> open(std::unique_ptr<line::Reader> reader,
diff --git a/src/errors.cc b/src/errors.cc
index 7122a9a..7d77d96 100644
--- a/src/errors.cc
+++ b/src/errors.cc
@@ -32,7 +32,7 @@ class FileErrors : public Errors {
loc.column, msg));
}
-#if !defined(NDEBUG)
+#ifndef NDEBUG
void dbg(Location loc, std::string_view msg) override {
output_->println(std::format("{}:{}:{}: Debug: {}", filename_, loc.line,
loc.column, msg));
@@ -63,7 +63,7 @@ class IgnoreErrors : public Errors {
void err(Location /* loc */, std::string_view /* msg */) override {}
void warn(Location /* loc */, std::string_view /* msg */) override {}
-#if !defined(NDEBUG)
+#ifndef NDEBUG
void dbg(Location /* loc */, std::string_view /* msg */) override {}
#endif
diff --git a/src/errors.hh b/src/errors.hh
index d8b3d60..b7b0143 100644
--- a/src/errors.hh
+++ b/src/errors.hh
@@ -13,12 +13,14 @@ namespace src {
class Errors {
public:
virtual ~Errors() = default;
+ Errors(Errors const&) = delete;
+ Errors& operator=(Errors const&) = delete;
virtual void err(Location loc, std::string_view msg) = 0;
virtual void warn(Location loc, std::string_view msg) = 0;
-#if !defined(NDEBUG)
+#ifndef NDEBUG
virtual void dbg(Location loc, std::string_view msg) = 0;
#else
void dbg(Location, std::string_view) {}
@@ -31,22 +33,18 @@ class Errors {
protected:
Errors() = default;
-
- Errors(Errors const&) = delete;
- Errors& operator=(Errors const&) = delete;
};
class ErrorsOutput {
public:
virtual ~ErrorsOutput() = default;
+ ErrorsOutput(ErrorsOutput const&) = delete;
+ ErrorsOutput& operator=(ErrorsOutput const&) = delete;
virtual void println(std::string_view line) = 0;
protected:
ErrorsOutput() = default;
-
- ErrorsOutput(ErrorsOutput const&) = delete;
- ErrorsOutput& operator=(ErrorsOutput const&) = delete;
};
[[nodiscard]]
diff --git a/src/grammar.hh b/src/grammar.hh
index 13beec4..4a638ac 100644
--- a/src/grammar.hh
+++ b/src/grammar.hh
@@ -60,15 +60,14 @@ struct Element {
class Grammar {
public:
virtual ~Grammar() = default;
+ Grammar(Grammar const&) = delete;
+ Grammar& operator=(Grammar const&) = delete;
[[nodiscard]]
virtual Element const& root() const = 0;
protected:
Grammar() = default;
-
- Grammar(Grammar const&) = delete;
- Grammar& operator=(Grammar const&) = delete;
};
std::unique_ptr<Grammar> load(std::unique_ptr<io::Reader> reader,
diff --git a/src/io.hh b/src/io.hh
index 7c21028..edaa93e 100644
--- a/src/io.hh
+++ b/src/io.hh
@@ -8,14 +8,14 @@
namespace io {
-enum class ReadError {
+enum class ReadError : uint8_t {
Error,
Eof,
InvalidData, // invalid data read (not used by raw file)
MaxTooSmall, // max argument needs to be bigger (not used by raw file)
};
-enum class OpenError {
+enum class OpenError : uint8_t {
NoSuchFile,
NoAccess,
Error,
@@ -24,6 +24,8 @@ enum class OpenError {
class Reader {
public:
virtual ~Reader() = default;
+ Reader(Reader const&) = delete;
+ Reader& operator=(Reader const&) = delete;
[[nodiscard]] virtual std::expected<size_t, ReadError> read(void* dst,
size_t max) = 0;
@@ -35,9 +37,6 @@ class Reader {
protected:
Reader() = default;
-
- Reader(Reader const&) = delete;
- Reader& operator=(Reader const&) = delete;
};
[[nodiscard]] std::expected<std::unique_ptr<Reader>, OpenError> open(
diff --git a/src/java_tokens.cc b/src/java_tokens.cc
index 42c310b..ebf7e93 100644
--- a/src/java_tokens.cc
+++ b/src/java_tokens.cc
@@ -212,7 +212,7 @@ class TokensImpl : public Tokens {
break;
}
std::optional<char> suffix;
- if (token.str.find('_') == std::string_view::npos) {
+ if (!token.str.contains('_')) {
auto ret = std::from_chars(token.str.data() + prefix,
token.str.data() + token.str.size(),
token.int_value, base);
diff --git a/src/java_tokens.hh b/src/java_tokens.hh
index e8b32fe..4000c98 100644
--- a/src/java_tokens.hh
+++ b/src/java_tokens.hh
@@ -77,17 +77,17 @@ struct TokensConfig {
class Tokens {
public:
virtual ~Tokens() = default;
+ Tokens(Tokens const&) = delete;
+ Tokens& operator=(Tokens const&) = delete;
virtual std::expected<Token, io::ReadError> read() = 0;
protected:
Tokens() = default;
- Tokens(Tokens const&) = delete;
- Tokens& operator=(Tokens const&) = delete;
};
[[nodiscard]] std::unique_ptr<Tokens> open(std::unique_ptr<io::Reader> reader,
- std::unique_ptr<src::Errors>,
+ std::unique_ptr<src::Errors> errors,
TokensConfig config = {});
} // namespace java
diff --git a/src/java_uescape.cc b/src/java_uescape.cc
index 3951b5f..98b4b28 100644
--- a/src/java_uescape.cc
+++ b/src/java_uescape.cc
@@ -41,7 +41,7 @@ class UnicodeEscapeReader {
state.wstart = reinterpret_cast<T*>(dst);
state.wptr = state.wstart;
// NOLINTNEXTLINE(bugprone-sizeof-expression)
- state.wend = state.wstart + max / sizeof(T);
+ state.wend = state.wstart + (max / sizeof(T));
if (fill_ == 0) {
// Optimize for the case when there are no unicode escapes.
diff --git a/src/line.hh b/src/line.hh
index a8eeea8..456c2b8 100644
--- a/src/line.hh
+++ b/src/line.hh
@@ -14,6 +14,8 @@ namespace line {
class Reader {
public:
virtual ~Reader() = default;
+ Reader(Reader const&) = delete;
+ Reader& operator=(Reader const&) = delete;
// Returned view is only valid until next call to read.
[[nodiscard]]
@@ -24,9 +26,6 @@ class Reader {
protected:
Reader() = default;
-
- Reader(Reader const&) = delete;
- Reader& operator=(Reader const&) = delete;
};
[[nodiscard]] std::unique_ptr<Reader> open(std::unique_ptr<io::Reader> reader,
diff --git a/src/prefix_tree.hh b/src/prefix_tree.hh
index 6e4c792..608e081 100644
--- a/src/prefix_tree.hh
+++ b/src/prefix_tree.hh
@@ -11,6 +11,8 @@ namespace prefix_tree {
class Builder {
public:
virtual ~Builder() = default;
+ Builder(Builder const&) = delete;
+ Builder& operator=(Builder const&) = delete;
virtual void add(std::string_view str) = 0;
[[nodiscard]]
@@ -18,9 +20,6 @@ class Builder {
protected:
Builder() = default;
-
- Builder(Builder const&) = delete;
- Builder& operator=(Builder const&) = delete;
};
[[nodiscard]]
diff --git a/src/u.hh b/src/u.hh
index 524b2ff..4e037de 100644
--- a/src/u.hh
+++ b/src/u.hh
@@ -16,6 +16,7 @@ enum class ReadErrorReplace : uint8_t {
Incomplete, // Too few bytes
};
+// NOLINTBEGIN(readability-enum-initial-value)
enum class Version : uint8_t {
u6_2_0,
u8_0_0,
@@ -29,6 +30,7 @@ enum class Version : uint8_t {
u16_0_0,
LATEST = u16_0_0,
};
+// NOLINTEND(readability-enum-initial-value)
GeneralCategory lookup_gc(uint32_t code, Version version = Version::LATEST);
diff --git a/src/uio.hh b/src/uio.hh
index 8a55f03..091d0ce 100644
--- a/src/uio.hh
+++ b/src/uio.hh
@@ -9,7 +9,7 @@
namespace u {
-enum class ReaderInputFormat {
+enum class ReaderInputFormat : uint8_t {
UTF8,
UTF16_BE,
UTF16_LE,
diff --git a/src/uline.hh b/src/uline.hh
index e6ad9c1..6778600 100644
--- a/src/uline.hh
+++ b/src/uline.hh
@@ -13,6 +13,8 @@ namespace u8::line {
class Reader {
public:
virtual ~Reader() = default;
+ Reader(Reader const&) = delete;
+ Reader& operator=(Reader const&) = delete;
// Returned view is only valid until next call to read.
[[nodiscard]]
@@ -24,9 +26,6 @@ class Reader {
protected:
Reader() = default;
-
- Reader(Reader const&) = delete;
- Reader& operator=(Reader const&) = delete;
};
[[nodiscard]] std::unique_ptr<Reader> open(std::unique_ptr<u8::Reader> reader,
@@ -39,6 +38,8 @@ namespace u16::line {
class Reader {
public:
virtual ~Reader() = default;
+ Reader(Reader const&) = delete;
+ Reader& operator=(Reader const&) = delete;
// Returned view is only valid until next call to read.
[[nodiscard]]
@@ -50,9 +51,6 @@ class Reader {
protected:
Reader() = default;
-
- Reader(Reader const&) = delete;
- Reader& operator=(Reader const&) = delete;
};
[[nodiscard]] std::unique_ptr<Reader> open(std::unique_ptr<u16::Reader> reader,
diff --git a/src/unique_fd.hh b/src/unique_fd.hh
index 2950905..3668f79 100644
--- a/src/unique_fd.hh
+++ b/src/unique_fd.hh
@@ -17,7 +17,10 @@ class unique_fd {
bool operator==(unique_fd const& fd) const { return get() == fd.get(); }
bool operator!=(unique_fd const& fd) const { return get() != fd.get(); }
- int get() const { return fd_; }
+ [[nodiscard]]
+ int get() const {
+ return fd_;
+ }
explicit operator bool() const { return fd_ != -1; }
int operator*() const { return fd_; }