srctree

Robin Linden parent d298c142 f1b6b05d
meta: Enable the readability-qualified-auto clang-tidy check

inlinesplit
.clang-tidy added: 25, removed: 22, total 3
@@ -45,6 +45,7 @@ Checks: >
misc-*,
modernize-*,
readability-identifier-naming,
readability-qualified-auto,
-bugprone-exception-escape,
-bugprone-narrowing-conversions,
-bugprone-unchecked-optional-access,
 
css/rule_test.cpp added: 25, removed: 22, total 3
@@ -16,7 +16,7 @@ int main() {
rule.selectors.emplace_back("div");
rule.declarations.emplace(css::PropertyId::BackgroundColor, "black");
 
auto expected =
auto const *expected =
"Selectors: div\n"
"Declarations:\n"
" background-color: black\n";
@@ -31,7 +31,7 @@ int main() {
rule.declarations.emplace(css::PropertyId::FontFamily, "Arial");
rule.declarations.emplace(css::PropertyId::TextAlign, "center");
 
auto expected =
auto const *expected =
"Selectors: h1, h2\n"
"Declarations:\n"
" color: blue\n"
@@ -47,7 +47,7 @@ int main() {
rule.declarations.emplace(css::PropertyId::TextAlign, "center");
rule.media_query = "screen and (min-width: 900px)";
 
auto expected =
auto const *expected =
"Selectors: h1\n"
"Declarations:\n"
" color: blue\n"
 
dom/dom.h added: 25, removed: 22, total 3
@@ -80,7 +80,7 @@ inline std::vector<T const *> nodes_by_xpath(T const &root, std::string_view xpa
 
auto search_children = [&] {
xpath.remove_prefix(1);
for (auto node : searching) {
for (auto const *node : searching) {
auto name = dom_name(*node);
if (xpath == name) {
goal_nodes.push_back(node);
 
dom2/node.cpp added: 25, removed: 22, total 3
@@ -21,7 +21,7 @@ std::shared_ptr<Node> Node::pre_insert(std::shared_ptr<Node> node, Node const *c
// TODO(robinlinden): Ensure pre-insertion validity.
 
// 2. Let referenceChild be child.
auto reference_child = child;
auto const *reference_child = child;
 
// 3. If referenceChild is node, then set referenceChild to node's next sibling.
if (reference_child == node.get()) {
 
engine/engine.cpp added: 25, removed: 22, total 3
@@ -135,7 +135,7 @@ void Engine::on_navigation_success() {
// Start downloading all stylesheets.
spdlog::info("Loading {} stylesheets", head_links.size());
std::vector<std::future<std::vector<css::Rule>>> future_new_rules;
for (auto link : head_links) {
for (auto const *link : head_links) {
future_new_rules.push_back(std::async(std::launch::async, [=, this]() -> std::vector<css::Rule> {
auto const &href = link->attributes.at("href");
auto stylesheet_url = uri::Uri::parse(href, uri_);
 
layout/layout.cpp added: 25, removed: 22, total 3
@@ -359,7 +359,7 @@ LayoutBox const *box_at_position(LayoutBox const &box, geom::Position p) {
}
 
for (auto const &child : box.children) {
if (auto maybe = box_at_position(child, p)) {
if (auto const *maybe = box_at_position(child, p)) {
return maybe;
}
}
 
layout/layout_test.cpp added: 25, removed: 22, total 3
@@ -941,7 +941,7 @@ int main() {
},
};
 
auto expected =
auto const *expected =
"html\n"
"block {0,0,0,30} {0,0,0,0} {0,0,0,0}\n"
" body\n"
 
os/linux.cpp added: 25, removed: 22, total 3
@@ -34,7 +34,7 @@ std::vector<std::string> font_paths() {
unsigned active_window_scale_factor() {
// Hastur, Qt, Gnome, and Elementary in that order.
// Environment variables from https://wiki.archlinux.org/title/HiDPI#GUI_toolkits
for (auto *env_var : std::array{"HST_SCALE", "QT_SCALE_FACTOR", "GDK_SCALE", "ELM_SCALE"}) {
for (auto const *env_var : std::array{"HST_SCALE", "QT_SCALE_FACTOR", "GDK_SCALE", "ELM_SCALE"}) {
if (char const *scale = std::getenv(env_var)) {
int result{};
if (std::from_chars(scale, scale + std::strlen(scale), result).ec == std::errc{}) {
 
style/style_test.cpp added: 25, removed: 22, total 3
@@ -63,7 +63,7 @@ int main() {
});
 
// These are 100% identical right now as we treat all links as unvisited links.
for (auto const pc : std::array{"link", "any-link"}) {
for (auto const *pc : std::array{"link", "any-link"}) {
etest::test(fmt::format("is_match: psuedo-class, {}", pc), [pc] {
expect(style::is_match(dom::Element{"a", {{"href", ""}}}, fmt::format(":{}", pc)));
 
 
tui/tui.cpp added: 25, removed: 22, total 3
@@ -29,7 +29,7 @@ ftxui::Elements parse_children(layout::LayoutBox const &box) {
ftxui::Element element_from_node(layout::LayoutBox const &box) {
switch (box.type) {
case layout::LayoutType::Inline: {
if (auto text = std::get_if<dom::Text>(&box.node->node)) {
if (auto const *text = std::get_if<dom::Text>(&box.node->node)) {
return ftxui::paragraph(text->text);
}
return hbox(parse_children(box));
 
util/string.h added: 25, removed: 22, total 3
@@ -105,6 +105,8 @@ constexpr bool is_whitespace(char ch) {
}
 
constexpr std::string_view trim_start(std::string_view s) {
// clang-tidy says this is pointer-ish, but msvc disagrees.
// NOLINTNEXTLINE(readability-qualified-auto)
auto it = std::ranges::find_if(s, [](char ch) { return !is_whitespace(ch); });
s.remove_prefix(std::distance(cbegin(s), it));
return s;