From 1355efc3fc8fb3740afc60bda3aa99dbdbf2015f Mon Sep 17 00:00:00 2001 From: sfdd Date: Fri, 15 Nov 2024 23:03:42 +0200 Subject: [PATCH] Browser: Fix clang-tidy issues --- .../Browser/BookmarksBarWidget.cpp | 4 +-- .../Applications/Browser/BrowserTabWidget.cpp | 2 +- .../Applications/Browser/DownloadWidget.cpp | 8 ++--- .../Browser/EditBookmarkDialog.cpp | 4 +-- .../Applications/Browser/EditBookmarkDialog.h | 34 +++++++++---------- .../Applications/Browser/EditBookmarkWidget.h | 14 ++++---- Userland/Applications/Browser/IconBag.cpp | 2 +- .../Applications/Browser/StorageModel.cpp | 1 - Userland/Applications/Browser/URLBox.cpp | 3 +- .../Applications/Browser/WindowActions.cpp | 3 +- 10 files changed, 35 insertions(+), 40 deletions(-) diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp index bc72158244d66f..ee0492c2f24269 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.cpp +++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp @@ -7,9 +7,9 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include "BookmarksBarWidget.h" +#include "Browser.h" #include "EditBookmarkDialog.h" -#include -#include #include #include #include diff --git a/Userland/Applications/Browser/BrowserTabWidget.cpp b/Userland/Applications/Browser/BrowserTabWidget.cpp index c662f90ff288fe..d67ec1d14af29d 100644 --- a/Userland/Applications/Browser/BrowserTabWidget.cpp +++ b/Userland/Applications/Browser/BrowserTabWidget.cpp @@ -14,7 +14,7 @@ #include "Browser.h" #include "BrowserWindow.h" #include "DownloadWidget.h" -#include +#include "URLBox.h" #include #include #include diff --git a/Userland/Applications/Browser/DownloadWidget.cpp b/Userland/Applications/Browser/DownloadWidget.cpp index e2a51a32528640..7f9103a116ae5b 100644 --- a/Userland/Applications/Browser/DownloadWidget.cpp +++ b/Userland/Applications/Browser/DownloadWidget.cpp @@ -8,7 +8,6 @@ #include "DownloadWidget.h" #include #include -#include #include #include #include @@ -20,7 +19,6 @@ #include #include #include -#include #include #include @@ -114,7 +112,7 @@ DownloadWidget::DownloadWidget(const URL::URL& url) m_cancel_button = button_container.add("Cancel"_string); m_cancel_button->set_fixed_size(100, 22); m_cancel_button->on_click = [this](auto) { - bool success = m_download->stop(); + bool const success = m_download->stop(); VERIFY(success); window()->close(); }; @@ -129,9 +127,9 @@ DownloadWidget::DownloadWidget(const URL::URL& url) void DownloadWidget::did_progress(Optional total_size, u64 downloaded_size) { - int percent = 0; + int percent { 0 }; if (total_size.has_value()) { - percent = downloaded_size * 100 / total_size.value(); + percent = static_cast(downloaded_size * 100 / total_size.value()); window()->set_progress(percent); m_progressbar->set_value(percent); } diff --git a/Userland/Applications/Browser/EditBookmarkDialog.cpp b/Userland/Applications/Browser/EditBookmarkDialog.cpp index 1c20b2e42057b5..dcbc9a16ac84ae 100644 --- a/Userland/Applications/Browser/EditBookmarkDialog.cpp +++ b/Userland/Applications/Browser/EditBookmarkDialog.cpp @@ -13,7 +13,7 @@ namespace Browser { Vector EditBookmarkDialog::edit_bookmark(GUI::Window* parent_window, RefPtr icon, StringView title, StringView url, PerformEditOn perform_edit_on) { - auto editor_or_error = EditBookmarkDialog::try_create(parent_window, move(title), move(url)); + auto editor_or_error = EditBookmarkDialog::try_create(parent_window, title, url); if (editor_or_error.is_error()) { GUI::MessageBox::show(parent_window, "Couldn't load \"edit bookmark\" dialog"sv, "Error while opening \"edit bookmark\" dialog"sv, GUI::MessageBox::Type::Error); return {}; @@ -40,7 +40,7 @@ EditBookmarkDialog::try_create(GUI::Window* parent_window, StringView title, Str { auto edit_bookmark_widget = TRY(EditBookmarkWidget::try_create()); auto edit_bookmark_dialog = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) - EditBookmarkDialog(parent_window, move(title), move(url), edit_bookmark_widget))); + EditBookmarkDialog(parent_window, title, url, edit_bookmark_widget))); return edit_bookmark_dialog; } diff --git a/Userland/Applications/Browser/EditBookmarkDialog.h b/Userland/Applications/Browser/EditBookmarkDialog.h index 5896a78a84678c..ddc39d196bf29b 100644 --- a/Userland/Applications/Browser/EditBookmarkDialog.h +++ b/Userland/Applications/Browser/EditBookmarkDialog.h @@ -7,34 +7,34 @@ #pragma once #include "EditBookmarkWidget.h" +#include #include #include -#include namespace Browser { - enum class PerformEditOn { - NewBookmark, - ExistingBookmark - }; +enum class PerformEditOn { + NewBookmark, + ExistingBookmark +}; - class EditBookmarkDialog final : public GUI::Dialog { +class EditBookmarkDialog final : public GUI::Dialog { C_OBJECT_ABSTRACT(EditBookmarkDialog) - public: - static Vector - edit_bookmark(GUI::Window *parent_window, RefPtr icon, StringView title, StringView url, PerformEditOn perform_edit_on); - static ErrorOr> try_create(Window* parent_window, StringView title, StringView url); +public: + static Vector + edit_bookmark(GUI::Window* parent_window, RefPtr icon, StringView title, StringView url, PerformEditOn perform_edit_on); + static ErrorOr> try_create(Window* parent_window, StringView title, StringView url); - private: - EditBookmarkDialog(GUI::Window* parent_window, StringView title, StringView url, NonnullRefPtr edit_bookmark_widget); +private: + EditBookmarkDialog(GUI::Window* parent_window, StringView title, StringView url, NonnullRefPtr edit_bookmark_widget); - ByteString title() const; + ByteString title() const; - ByteString url() const; + ByteString url() const; - RefPtr m_title_textbox; - RefPtr m_url_textbox; - }; + RefPtr m_title_textbox; + RefPtr m_url_textbox; +}; } diff --git a/Userland/Applications/Browser/EditBookmarkWidget.h b/Userland/Applications/Browser/EditBookmarkWidget.h index 3eb5442f7e1190..43d31870bfa274 100644 --- a/Userland/Applications/Browser/EditBookmarkWidget.h +++ b/Userland/Applications/Browser/EditBookmarkWidget.h @@ -10,14 +10,14 @@ namespace Browser { - class EditBookmarkWidget : public GUI::Widget { +class EditBookmarkWidget : public GUI::Widget { C_OBJECT_ABSTRACT(EditBookmarkWidget) - public: - static ErrorOr> try_create(); - virtual ~EditBookmarkWidget() override = default; +public: + static ErrorOr> try_create(); + virtual ~EditBookmarkWidget() override = default; - private: - EditBookmarkWidget() = default; - }; +private: + EditBookmarkWidget() = default; +}; } diff --git a/Userland/Applications/Browser/IconBag.cpp b/Userland/Applications/Browser/IconBag.cpp index 55896b96300369..dd976e973b8fb5 100644 --- a/Userland/Applications/Browser/IconBag.cpp +++ b/Userland/Applications/Browser/IconBag.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include "IconBag.h" namespace Browser { ErrorOr IconBag::try_create() diff --git a/Userland/Applications/Browser/StorageModel.cpp b/Userland/Applications/Browser/StorageModel.cpp index 42cca352aea920..fd3c32d1d720cf 100644 --- a/Userland/Applications/Browser/StorageModel.cpp +++ b/Userland/Applications/Browser/StorageModel.cpp @@ -5,7 +5,6 @@ */ #include "StorageModel.h" - #include namespace Browser { diff --git a/Userland/Applications/Browser/URLBox.cpp b/Userland/Applications/Browser/URLBox.cpp index 29249fbfc5cc13..0a3ddfe141119b 100644 --- a/Userland/Applications/Browser/URLBox.cpp +++ b/Userland/Applications/Browser/URLBox.cpp @@ -4,10 +4,9 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include "URLBox.h" #include #include -#include #include namespace Browser { diff --git a/Userland/Applications/Browser/WindowActions.cpp b/Userland/Applications/Browser/WindowActions.cpp index 1d927f57237480..9062cbfe96a891 100644 --- a/Userland/Applications/Browser/WindowActions.cpp +++ b/Userland/Applications/Browser/WindowActions.cpp @@ -6,10 +6,9 @@ */ #include "WindowActions.h" -#include +#include "Browser.h" #include #include -#include namespace Browser {