From ff6df9f27e187c879b9d0bcff7b99e62ebb9691b Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sat, 23 Apr 2022 23:05:06 +0200 Subject: [PATCH] FileManager: Use VERIFY() instead of if checks with VERIFY_NOT_REACHED Besides micro simplifying the code, this will also show the failed condition in the console, instead of vague 'ASSERTION FAILED: false'. --- Userland/Applications/FileManager/main.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index e4b6898712..52bd8d4311 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -131,8 +131,7 @@ ErrorOr serenity_main(Main::Arguments arguments) void do_copy(Vector const& selected_file_paths, FileOperation file_operation) { - if (selected_file_paths.is_empty()) - VERIFY_NOT_REACHED(); + VERIFY(!selected_file_paths.is_empty()); StringBuilder copy_text; if (file_operation == FileOperation::Move) { @@ -343,9 +342,7 @@ ErrorOr run_in_desktop_mode() auto cut_action = GUI::CommonActions::make_cut_action( [&](auto&) { auto paths = directory_view->selected_file_paths(); - - if (paths.is_empty()) - VERIFY_NOT_REACHED(); + VERIFY(!paths.is_empty()); do_copy(paths, FileOperation::Move); }, @@ -355,9 +352,7 @@ ErrorOr run_in_desktop_mode() auto copy_action = GUI::CommonActions::make_copy_action( [&](auto&) { auto paths = directory_view->selected_file_paths(); - - if (paths.is_empty()) - VERIFY_NOT_REACHED(); + VERIFY(!paths.is_empty()); do_copy(paths, FileOperation::Copy); }, @@ -727,12 +722,9 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& auto cut_action = GUI::CommonActions::make_cut_action( [&](auto&) { auto paths = directory_view->selected_file_paths(); - if (paths.is_empty()) paths = tree_view_selected_file_paths(); - - if (paths.is_empty()) - VERIFY_NOT_REACHED(); + VERIFY(!paths.is_empty()); do_copy(paths, FileOperation::Move); refresh_tree_view(); @@ -743,12 +735,9 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& auto copy_action = GUI::CommonActions::make_copy_action( [&](auto&) { auto paths = directory_view->selected_file_paths(); - if (paths.is_empty()) paths = tree_view_selected_file_paths(); - - if (paths.is_empty()) - VERIFY_NOT_REACHED(); + VERIFY(!paths.is_empty()); do_copy(paths, FileOperation::Copy); refresh_tree_view();