Skip to content

Commit

Permalink
meta/clang-tidy: Enable a bunch more readability checks
Browse files Browse the repository at this point in the history
  • Loading branch information
robinlinden committed Nov 1, 2023
1 parent f6f4719 commit 458fefe
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,21 @@ Checks: >
modernize-*,
performance-*,
readability-container-size-empty,
readability-duplicate-include,
readability-identifier-naming,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-misleading-indentation,
readability-non-const-parameter,
readability-qualified-auto,
readability-redundant-control-flow,
readability-redundant-preprocessor,
readability-redundant-string-init,
readability-simplify-boolean-expr,
readability-simplify-subscript-expr,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
readability-use-anyofallof,
-bugprone-exception-escape,
-bugprone-narrowing-conversions,
-bugprone-unchecked-optional-access,
Expand Down
4 changes: 4 additions & 0 deletions gfx/opengl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include <cstdlib>
#include <limits>

// NOLINTBEGIN(readability-make-member-function-const): The drawing code
// shouldn't be thought of as const, even if it technically doesn't modify any
// class members.
namespace gfx {

std::optional<OpenGLShader> OpenGLShader::create(std::string_view vertex_src, std::string_view fragment_src) {
Expand Down Expand Up @@ -100,3 +103,4 @@ void OpenGLShader::set_uniform(char const *name, std::span<float const, 4> data)
}

} // namespace gfx
// NOLINTEND(readability-make-member-function-const)
2 changes: 1 addition & 1 deletion html2/character_reference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace {
// print(f'"{key}"sv', *codepoints, sep=', ', end='')
// print('},')
// ```
static constexpr std::array kReferences = std::to_array<CharacterReference>({{"&AElig"sv, 198},
constexpr std::array kReferences = std::to_array<CharacterReference>({{"&AElig"sv, 198},
{"&AElig;"sv, 198},
{"&AMP"sv, 38},
{"&AMP;"sv, 38},
Expand Down
11 changes: 4 additions & 7 deletions html2/parser_states.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "util/string.h"

#include <algorithm>
#include <array>
#include <cassert>
#include <optional>
Expand Down Expand Up @@ -145,14 +146,10 @@ constexpr bool is_quirky_public_identifier(std::string_view identifier) {
return true;
}

for (auto start : kQuirkyStartsOfPublicIdentifier) {
if (identifier.starts_with(start)) {
return true;
}
}

return false;
return std::ranges::any_of(
kQuirkyStartsOfPublicIdentifier, [&](auto start) { return identifier.starts_with(start); });
}

constexpr bool is_quirky_when_system_identifier_is_empty(std::string_view public_identifier) {
return public_identifier.starts_with("-//w3c//dtd html 4.01 frameset//")
|| public_identifier.starts_with("-//w3c//dtd html 4.01 transitional//");
Expand Down
2 changes: 1 addition & 1 deletion html2/tokenizer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace html2;

namespace {

static constexpr char const *kReplacementCharacter = "\xef\xbf\xbd";
constexpr char const *kReplacementCharacter = "\xef\xbf\xbd";

struct ParseErrorWithLocation {
ParseError error{};
Expand Down

0 comments on commit 458fefe

Please sign in to comment.