chore: address linter warnings

Signed-off-by: Toni Förster <toni.foerster@gmail.com>
This commit is contained in:
Toni Förster
2024-08-18 14:46:51 +02:00
parent af75afa912
commit 94577332a1
30 changed files with 164 additions and 103 deletions

View File

@@ -607,7 +607,7 @@ enum SponsorBlockColors: String {
case music_offtopic = "#FF9900" // Orange
// Define all cases, can be used to iterate over the colors
static let allCases: [SponsorBlockColors] = [.sponsor, .selfpromo, .interaction, .intro, .outro, .preview, .filler, .music_offtopic]
static let allCases: [SponsorBlockColors] = [Self.sponsor, Self.selfpromo, Self.interaction, Self.intro, Self.outro, Self.preview, Self.filler, Self.music_offtopic]
// Create a dictionary with the category names as keys and colors as values
static let dictionary: [String: String] = {

View File

@@ -51,59 +51,108 @@ enum LanguageCodes: String, CaseIterable {
var description: String {
switch self {
case .Afrikaans: return "Afrikaans"
case .Arabic: return "Arabic"
case .Azerbaijani: return "Azerbaijani"
case .Bengali: return "Bengali"
case .Catalan: return "Catalan"
case .Czech: return "Czech"
case .Welsh: return "Welsh"
case .Danish: return "Danish"
case .German: return "German"
case .Greek: return "Greek"
case .English: return "English"
case .English_GB: return "English (United Kingdom)"
case .Spanish: return "Spanish"
case .Persian: return "Persian"
case .Finnish: return "Finnish"
case .Filipino: return "Filipino"
case .French: return "French"
case .Irish: return "Irish"
case .Hebrew: return "Hebrew"
case .Hindi: return "Hindi"
case .Hungarian: return "Hungarian"
case .Indonesian: return "Indonesian"
case .Italian: return "Italian"
case .Japanese: return "Japanese"
case .Javanese: return "Javanese"
case .Korean: return "Korean"
case .Lithuanian: return "Lithuanian"
case .Malay: return "Malay"
case .Maltese: return "Maltese"
case .Dutch: return "Dutch"
case .Norwegian: return "Norwegian"
case .Polish: return "Polish"
case .Portuguese: return "Portuguese"
case .Romanian: return "Romanian"
case .Russian: return "Russian"
case .Slovak: return "Slovak"
case .Slovene: return "Slovene"
case .Swedish: return "Swedish"
case .Swahili: return "Swahili"
case .Thai: return "Thai"
case .Tagalog: return "Tagalog"
case .Turkish: return "Turkish"
case .Ukrainian: return "Ukrainian"
case .Urdu: return "Urdu"
case .Uzbek: return "Uzbek"
case .Vietnamese: return "Vietnamese"
case .Xhosa: return "Xhosa"
case .Chinese: return "Chinese"
case .Zulu: return "Zulu"
case .Afrikaans:
return "Afrikaans"
case .Arabic:
return "Arabic"
case .Azerbaijani:
return "Azerbaijani"
case .Bengali:
return "Bengali"
case .Catalan:
return "Catalan"
case .Czech:
return "Czech"
case .Welsh:
return "Welsh"
case .Danish:
return "Danish"
case .German:
return "German"
case .Greek:
return "Greek"
case .English:
return "English"
case .English_GB:
return "English (United Kingdom)"
case .Spanish:
return "Spanish"
case .Persian:
return "Persian"
case .Finnish:
return "Finnish"
case .Filipino:
return "Filipino"
case .French:
return "French"
case .Irish:
return "Irish"
case .Hebrew:
return "Hebrew"
case .Hindi:
return "Hindi"
case .Hungarian:
return "Hungarian"
case .Indonesian:
return "Indonesian"
case .Italian:
return "Italian"
case .Japanese:
return "Japanese"
case .Javanese:
return "Javanese"
case .Korean:
return "Korean"
case .Lithuanian:
return "Lithuanian"
case .Malay:
return "Malay"
case .Maltese:
return "Maltese"
case .Dutch:
return "Dutch"
case .Norwegian:
return "Norwegian"
case .Polish:
return "Polish"
case .Portuguese:
return "Portuguese"
case .Romanian:
return "Romanian"
case .Russian:
return "Russian"
case .Slovak:
return "Slovak"
case .Slovene:
return "Slovene"
case .Swedish:
return "Swedish"
case .Swahili:
return "Swahili"
case .Thai:
return "Thai"
case .Tagalog:
return "Tagalog"
case .Turkish:
return "Turkish"
case .Ukrainian:
return "Ukrainian"
case .Urdu:
return "Urdu"
case .Uzbek:
return "Uzbek"
case .Vietnamese:
return "Vietnamese"
case .Xhosa:
return "Xhosa"
case .Chinese:
return "Chinese"
case .Zulu:
return "Zulu"
}
}
static func languageName(for code: String) -> String {
return LanguageCodes(rawValue: code)?.description ?? "Unknown"
return Self(rawValue: code)?.description ?? "Unknown"
}
}

View File

@@ -209,7 +209,7 @@ struct OpenURLHandler {
return accounts.api.channelByName(name)
}
if let instance = InstancesModel.shared.all.first(where: { $0.app.supportsOpeningChannelsByName }) {
if let instance = InstancesModel.shared.all.first(where: \.app.supportsOpeningChannelsByName) {
return instance.anonymous.channelByName(name)
}
@@ -223,7 +223,7 @@ struct OpenURLHandler {
return accounts.api.channelByUsername(username)
}
if let instance = InstancesModel.shared.all.first(where: { $0.app.supportsOpeningChannelsByName }) {
if let instance = InstancesModel.shared.all.first(where: \.app.supportsOpeningChannelsByName) {
return instance.anonymous.channelByUsername(username)
}

View File

@@ -61,7 +61,8 @@ final class AppleAVPlayerViewController: UIViewController {
_ sections: [NowPlayingView.ViewSection],
title: String
) -> UIHostingController<AnyView> {
let controller = UIHostingController(rootView:
let controller = UIHostingController(
rootView:
AnyView(
NowPlayingView(sections: sections, inInfoViewController: true)
.frame(maxHeight: 600)

View File

@@ -33,7 +33,7 @@ struct TimelineView: View {
@State private var dragOffset: Double = 0
@State private var draggedFrom: Double = 0
private var start: Double = 0.0
private var start = 0.0
private var height = 8.0
var cornerRadius: Double

View File

@@ -90,8 +90,9 @@ final class PlayerViewController: UIViewController {
_ sections: [NowPlayingView.ViewSection],
title: String
) -> UIHostingController<AnyView> {
let controller = UIHostingController(rootView:
AnyView(
let controller = UIHostingController(
rootView:
AnyView(
NowPlayingView(sections: sections, inInfoViewController: true)
.frame(maxHeight: 600)
.environmentObject(commentsModel)

View File

@@ -208,6 +208,7 @@ struct VideoDetails: View {
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
.padding(.horizontal, 16)
// swiftlint:disable trailing_closure
#if !os(tvOS)
.tapRecognizer(
tapSensitivity: 0.2,
@@ -218,6 +219,7 @@ struct VideoDetails: View {
}
)
#endif
// swiftlint:enable trailing_closure
VideoActions(video: player.videoForDisplay)
.padding(.vertical, 5)

View File

@@ -281,7 +281,7 @@ struct VideoPlayerView: View {
}
.gesture(player.controls.presentingOverlays ? nil : playerDragGesture)
#if os(macOS)
.onAppear(perform: {
.onAppear {
NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
hoverThrottle.execute {
if !player.currentItem.isNil, hoveringPlayer {
@@ -291,7 +291,7 @@ struct VideoPlayerView: View {
return $0
}
})
}
#endif
.background(Color.black)

View File

@@ -15,7 +15,7 @@ struct SearchTextField: View {
#if os(macOS)
Image(systemName: "magnifyingglass")
.resizable()
.aspectRatio(contentMode: .fill)
.scaledToFill()
.frame(width: 12, height: 12)
.padding(.horizontal, 8)
.opacity(0.8)

View File

@@ -380,7 +380,7 @@ struct QualityProfileForm: View {
func submitForm() {
guard valid else { return }
let activeFormats = orderedFormats.filter { $0.isActive }.map { $0.format }
let activeFormats = orderedFormats.filter(\.isActive).map(\.format)
let formProfile = QualityProfile(
id: qualityProfile?.id ?? UUID().uuidString,

View File

@@ -15,7 +15,7 @@ struct FeedView: View {
#endif
var videos: [ContentItem] {
guard let selectedChannel = selectedChannel else {
guard let selectedChannel else {
return ContentItem.array(of: feed.videos)
}
return ContentItem.array(of: feed.videos.filter {
@@ -24,9 +24,7 @@ struct FeedView: View {
}
var channels: [Channel] {
feed.videos.map {
$0.channel
}.unique()
feed.videos.map(\.channel).unique()
}
@State private var selectedChannel: Channel?
@@ -272,7 +270,7 @@ struct FeedView: View {
}
var channelHeaderView: some View {
guard let selectedChannel = selectedChannel else {
guard let selectedChannel else {
return AnyView(
Text("All Channels")
.font(.caption)

View File

@@ -6,7 +6,7 @@ struct TrendingCountry: View {
@StateObject private var store = Store(Country.allCases)
@State private var query: String = ""
@State private var query = ""
@State private var selection: Country?
@Environment(\.colorScheme) private var colorScheme

View File

@@ -26,8 +26,7 @@ struct URLParser {
urlString.contains("youtube.com") ||
urlString.contains("youtu.be") ||
urlString.contains("youtube-nocookie.com"),
let url = URL(string: "https://\(urlString)"
)
let url = URL(string: "https://\(urlString)")
{
self.url = url
}
@@ -176,10 +175,8 @@ struct URLParser {
private func removePrefixes(_ value: String, _ prefixes: [String]) -> String {
var value = value
for prefix in prefixes {
if value.hasPrefix(prefix) {
value.removeFirst(prefix.count)
}
for prefix in prefixes where value.hasPrefix(prefix) {
value.removeFirst(prefix.count)
}
return value

View File

@@ -100,7 +100,7 @@ struct YatteeApp: App {
.commands {
SidebarCommands()
CommandGroup(replacing: .newItem, addition: {})
CommandGroup(replacing: .newItem) {}
MenuCommands(model: Binding<MenuModel>(get: { MenuModel.shared }, set: { _ in }))
}