Skip to content

Commit

Permalink
Address issues found by Periphery
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Sep 14, 2024
1 parent 28fd68c commit e056650
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 61 deletions.
6 changes: 6 additions & 0 deletions .periphery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project: Maccy.xcodeproj
retain_objc_accessible: true
schemes:
- Maccy
targets:
- Maccy
1 change: 0 additions & 1 deletion Maccy/Clipboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Clipboard {
.concealed,
.transient
]
private let modifiedTypes: Set<NSPasteboard.PasteboardType> = [.modified]

private var enabledTypes: Set<NSPasteboard.PasteboardType> { Defaults[.enabledPasteboardTypes] }
private var disabledTypes: Set<NSPasteboard.PasteboardType> { supportedTypes.subtracting(enabledTypes) }
Expand Down
8 changes: 0 additions & 8 deletions Maccy/Extensions/NSApplication+Windows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,4 @@ import AppKit
extension NSApplication {
var alertWindow: NSWindow? { windows.first { $0.className == "_NSAlertPanel" } }
var characterPickerWindow: NSWindow? { windows.first { $0.className == "NSPanelViewBridge" } }
var menuWindow: NSWindow? {
windows.first { window in
window.className == "NSPopupMenuWindow" // macOS 14 and later
|| window.className == "NSMenuWindowManagerWindow" // macOS 13 - 14
|| window.className == "NSCarbonMenuWindow" // macOS 12 and earlier
}
}
var statusBarWindow: NSWindow? { windows.first { $0.className == "NSStatusBarWindow" } }
}
39 changes: 0 additions & 39 deletions Maccy/KeyChord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ enum KeyChord: CaseIterable {
case moveToPrevious
case moveToFirst
case openPreferences
case paste
case pinOrUnpin
case selectCurrentItem
case close
Expand Down Expand Up @@ -80,42 +79,4 @@ enum KeyChord: CaseIterable {
}
}
// swiftlint:enable cyclomatic_complexity

static let keysToSkip = [
Key.home,
Key.pageUp,
Key.pageDown,
Key.end,
Key.downArrow,
Key.leftArrow,
Key.rightArrow,
Key.upArrow,
Key.tab,
Key.f1,
Key.f2,
Key.f3,
Key.f4,
Key.f5,
Key.f6,
Key.f7,
Key.f8,
Key.f9,
Key.f10,
Key.f11,
Key.f12,
Key.f13,
Key.f14,
Key.f15,
Key.f16,
Key.f17,
Key.f18,
Key.f19,
Key.eisu,
Key.kana
]
private static let modifiersToSkip = NSEvent.ModifierFlags([
.command,
.control,
.option
])
}
2 changes: 1 addition & 1 deletion Maccy/Settings/AppearanceSettingsPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct AppearanceSettingsPane: View {

Settings.Section(label: { Text("NumberOfItems", tableName: "AppearanceSettings") }) {
HStack {
TextField("", value: $numberOfItems, formatter: imageHeightFormatter)
TextField("", value: $numberOfItems, formatter: numberOfItemsFormatter)
.frame(width: 120)
.help(Text("NumberOfItemsTooltip", tableName: "AppearanceSettings"))
Stepper("", value: $numberOfItems, in: 0...100)
Expand Down
18 changes: 14 additions & 4 deletions Maccy/Settings/GeneralSettingsPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ struct GeneralSettingsPane: View {
ForEach(Search.Mode.allCases) { mode in
Text(mode.description)
}
}.labelsHidden().frame(width: 180)
}
.labelsHidden()
.frame(width: 180)
}

Settings.Section(
Expand All @@ -65,15 +67,23 @@ struct GeneralSettingsPane: View {
) {
Defaults.Toggle(key: .pasteByDefault) {
Text("PasteAutomatically", tableName: "GeneralSettings")
}.onChange(refreshModifiers).fixedSize()
}
.onChange(refreshModifiers)
.fixedSize()

Defaults.Toggle(key: .removeFormattingByDefault) {
Text("PasteWithoutFormatting", tableName: "GeneralSettings")
}.onChange(refreshModifiers).fixedSize()
}
.onChange(refreshModifiers)
.fixedSize()

Text(String(
format: NSLocalizedString("Modifiers", tableName: "GeneralSettings", comment: ""),
copyModifier, pasteModifier, pasteWithoutFormatting
)).fixedSize(horizontal: false, vertical: true).foregroundStyle(.gray).controlSize(.small)
))
.fixedSize(horizontal: false, vertical: true)
.foregroundStyle(.gray)
.controlSize(.small)
}

Settings.Section(title: "") {
Expand Down
3 changes: 0 additions & 3 deletions Maccy/Views/FooterItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import SwiftUI
struct FooterItemView: View {
@Bindable var item: FooterItem

@Environment(AppState.self) private var appState
@Environment(ModifierFlags.self) private var modifierFlags

var body: some View {
ConfirmationView(item: item) {
ListItemView(id: item.id, shortcuts: item.shortcuts, isSelected: item.isSelected) {
Expand Down
3 changes: 1 addition & 2 deletions Maccy/Views/KeyboardShortcutView.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import SwiftUI

struct KeyboardShortcutView: View {
@Environment(ModifierFlags.self) private var modifierFlags

var shortcut: KeyShortcut?

var modifiers: String {
Expand All @@ -12,6 +10,7 @@ struct KeyboardShortcutView: View {
}
return ""
}

var character: String {
return shortcut?.description.last?.description ?? ""
}
Expand Down
1 change: 0 additions & 1 deletion Maccy/Views/ListItemTitleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import SwiftUI

struct ListItemTitleView<Title: View>: View {
var attributedTitle: AttributedString? = nil
var isSelected: Bool
@ViewBuilder var title: () -> Title

var body: some View {
Expand Down
3 changes: 1 addition & 2 deletions Maccy/Views/ListItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ struct ListItemView<Title: View>: View {

@Environment(AppState.self) private var appState
@Environment(ModifierFlags.self) private var modifierFlags
@Default(.imageMaxHeight) private var imageMaxHeight

var body: some View {
HStack(spacing: 0) {
Expand All @@ -21,7 +20,7 @@ struct ListItemView<Title: View>: View {
.padding(.leading, 10)
.padding(.vertical, 5)
}
ListItemTitleView(attributedTitle: attributedTitle, isSelected: isSelected, title: title)
ListItemTitleView(attributedTitle: attributedTitle, title: title)
Spacer()
if !shortcuts.isEmpty {
ZStack {
Expand Down

0 comments on commit e056650

Please sign in to comment.