macos: swiftlint 'opening_brace' rule

This commit is contained in:
Jon Parise
2026-02-19 18:53:13 -05:00
parent b10dcc9629
commit 6052f664cf
10 changed files with 14 additions and 20 deletions

View File

@@ -21,7 +21,6 @@ disabled_rules:
- mark
- multiple_closures_with_trailing_closure
- no_fallthrough_only
- opening_brace
- orphaned_doc_comment
- private_over_fileprivate
- shorthand_operator

View File

@@ -9,8 +9,7 @@ class AppDelegate: NSObject,
ObservableObject,
NSApplicationDelegate,
UNUserNotificationCenterDelegate,
GhosttyAppDelegate
{
GhosttyAppDelegate {
// The application logger. We should probably move this at some point to a dedicated
// class/struct but for now it lives here! 🤷
static let logger = Logger(
@@ -948,7 +947,7 @@ class AppDelegate: NSObject,
// Using AppIconActor to ensure this work
// happens synchronously in the background
@AppIconActor
private func updateAppIcon(from config: Ghostty.Config) async {
private func updateAppIcon(from config: Ghostty.Config) async {
var appIcon: NSImage?
var appIconName: String? = config.macosIcon.rawValue

View File

@@ -21,8 +21,7 @@ struct AboutView: View {
init(material: NSVisualEffectView.Material,
blendingMode: NSVisualEffectView.BlendingMode = .behindWindow,
isEmphasized: Bool = false)
{
isEmphasized: Bool = false) {
self.material = material
self.blendingMode = blendingMode
self.isEmphasized = isEmphasized

View File

@@ -340,8 +340,7 @@ class QuickTerminalController: BaseTerminalController {
// we want to store it so we can restore state later.
if !NSApp.isActive {
if let previousApp = NSWorkspace.shared.frontmostApplication,
previousApp.bundleIdentifier != Bundle.main.bundleIdentifier
{
previousApp.bundleIdentifier != Bundle.main.bundleIdentifier {
self.previousApp = previousApp
}
}

View File

@@ -31,8 +31,7 @@ class BaseTerminalController: NSWindowController,
TerminalViewDelegate,
TerminalViewModel,
ClipboardConfirmationViewDelegate,
FullscreenDelegate
{
FullscreenDelegate {
/// The app instance that this terminal view will represent.
let ghostty: Ghostty.App

View File

@@ -449,8 +449,7 @@ class TerminalWindow: NSWindow {
let forceOpaque = terminalController?.isBackgroundOpaque ?? false
if !styleMask.contains(.fullScreen) &&
!forceOpaque &&
(surfaceConfig.backgroundOpacity < 1 || surfaceConfig.backgroundBlur.isGlassStyle)
{
(surfaceConfig.backgroundOpacity < 1 || surfaceConfig.backgroundBlur.isGlassStyle) {
isOpaque = false
// This is weird, but we don't use ".clear" because this creates a look that

View File

@@ -1993,8 +1993,7 @@ extension Ghostty {
private static func configReload(
_ app: ghostty_app_t,
target: ghostty_target_s,
v: ghostty_action_reload_config_s)
{
v: ghostty_action_reload_config_s) {
logger.info("config reload notification")
guard let app_ud = ghostty_app_userdata(app) else { return }

View File

@@ -39,8 +39,7 @@ extension NSEvent {
key_ev.unshifted_codepoint = 0
if type == .keyDown || type == .keyUp {
if let chars = characters(byApplyingModifiers: []),
let codepoint = chars.unicodeScalars.first
{
let codepoint = chars.unicodeScalars.first {
key_ev.unshifted_codepoint = codepoint.value
}
}

View File

@@ -965,8 +965,7 @@ extension Ghostty {
!controller.commandPaletteIsShowing,
window.isKeyWindow &&
!self.focused &&
controller.focusFollowsMouse
{
controller.focusFollowsMouse {
Ghostty.moveFocus(to: self)
}
}
@@ -1944,8 +1943,7 @@ extension Ghostty.SurfaceView: NSTextInputClient {
// we send it back through the event system so it can be encoded.
if let lastPerformKeyEvent,
let current = NSApp.currentEvent,
lastPerformKeyEvent == current.timestamp
{
lastPerformKeyEvent == current.timestamp {
NSApp.sendEvent(current)
return
}

View File

@@ -5,11 +5,13 @@ import SwiftUI
extension EventModifiers {
init(nsFlags: NSEvent.ModifierFlags) {
var result: SwiftUI.EventModifiers = []
// swiftlint:disable opening_brace
if nsFlags.contains(.shift) { result.insert(.shift) }
if nsFlags.contains(.control) { result.insert(.control) }
if nsFlags.contains(.option) { result.insert(.option) }
if nsFlags.contains(.command) { result.insert(.command) }
if nsFlags.contains(.capsLock) { result.insert(.capsLock) }
// swiftlint:enable opening_brace
self = result
}
}
@@ -17,11 +19,13 @@ extension EventModifiers {
extension NSEvent.ModifierFlags {
init(swiftUIFlags: SwiftUI.EventModifiers) {
var result: NSEvent.ModifierFlags = []
// swiftlint:disable opening_brace
if swiftUIFlags.contains(.shift) { result.insert(.shift) }
if swiftUIFlags.contains(.control) { result.insert(.control) }
if swiftUIFlags.contains(.option) { result.insert(.option) }
if swiftUIFlags.contains(.command) { result.insert(.command) }
if swiftUIFlags.contains(.capsLock) { result.insert(.capsLock) }
// swiftlint:enable opening_brace
self = result
}
}