From 0348ed384d77ef8494b7ece5d8a6d4c12e9d2907 Mon Sep 17 00:00:00 2001 From: CatsDeservePets <145048791+CatsDeservePets@users.noreply.github.com> Date: Fri, 13 Feb 2026 22:37:06 +0100 Subject: [PATCH] refactor: simplify `isValidSortMethod` (#2393) --- opts.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/opts.go b/opts.go index 0b3a3f49..59ad0ae9 100644 --- a/opts.go +++ b/opts.go @@ -22,15 +22,11 @@ const ( ) func isValidSortMethod(method sortMethod) bool { - return method == naturalSort || - method == nameSort || - method == sizeSort || - method == timeSort || - method == atimeSort || - method == btimeSort || - method == ctimeSort || - method == extSort || - method == customSort + switch method { + case naturalSort, nameSort, sizeSort, timeSort, atimeSort, btimeSort, ctimeSort, extSort, customSort: + return true + } + return false } const invalidSortErrorMessage = `sortby: value should either be 'natural', 'name', 'size', 'time', 'atime', 'btime', 'ctime', 'ext' or 'custom'`