Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftLint enable attributes rule #1339

Merged
merged 9 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ identifier_name:
excluded:
- CodeEditModules/.build # Where Swift Package Manager checks out dependency sources
- DerivedData

opt_in_rules:
- attributes
- empty_count
- closure_spacing
- contains_over_first_not_nil
Expand Down
3 changes: 2 additions & 1 deletion CodeEdit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {

// MARK: NSDocumentController delegate

@objc func documentController(_ docController: NSDocumentController, didCloseAll: Bool, contextInfo: Any) {
@objc
func documentController(_ docController: NSDocumentController, didCloseAll: Bool, contextInfo: Any) {
NSApplication.shared.reply(toApplicationShouldTerminate: didCloseAll)
}
}
Expand Down
3 changes: 2 additions & 1 deletion CodeEdit/CodeEditApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ struct CodeEditApp: App {
@NSApplicationDelegateAdaptor var appdelegate: AppDelegate
@ObservedObject var settings = Settings.shared

@Environment(\.openWindow) var openWindow
@Environment(\.openWindow)
var openWindow

let updater: SoftwareUpdater = SoftwareUpdater()

Expand Down
4 changes: 3 additions & 1 deletion CodeEdit/Features/About/Views/AboutDefaultView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ struct AboutDefaultView: View {

@Binding var aboutMode: AboutMode
var namespace: Namespace.ID
@Environment(\.colorScheme) var colorScheme

@Environment(\.colorScheme)
var colorScheme

private static var licenseURL = URL(string: "https://github.com/CodeEditApp/CodeEdit/blob/main/LICENSE.md")!

Expand Down
3 changes: 1 addition & 2 deletions CodeEdit/Features/About/Views/AboutDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ struct AboutDetailView<Content: View>: View {

var namespace: Namespace.ID

@ViewBuilder
var content: Content
@ViewBuilder var content: Content

let smallTitlebarHeight: CGFloat = 28
let mediumTitlebarHeight: CGFloat = 113
Expand Down
9 changes: 6 additions & 3 deletions CodeEdit/Features/About/Views/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ enum AboutMode: String, CaseIterable {
}

public struct AboutView: View {
@Environment(\.openURL) private var openURL
@Environment(\.colorScheme) private var colorScheme
@Environment(\.dismiss) private var dismiss
@Environment(\.openURL)
matthijseikelenboom marked this conversation as resolved.
Show resolved Hide resolved
private var openURL
@Environment(\.colorScheme)
private var colorScheme
@Environment(\.dismiss)
private var dismiss

@State var aboutMode: AboutMode = .about

Expand Down
6 changes: 4 additions & 2 deletions CodeEdit/Features/About/Views/BlurButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ extension ButtonStyle where Self == BlurButtonStyle {
}

struct BlurButtonStyle: ButtonStyle {
@Environment(\.controlSize) var controlSize
@Environment(\.controlSize)
var controlSize

var height: CGFloat {
switch controlSize {
Expand All @@ -23,7 +24,8 @@ struct BlurButtonStyle: ButtonStyle {
}
}

@Environment(\.colorScheme) var colorScheme
@Environment(\.colorScheme)
var colorScheme

func makeBody(configuration: Configuration) -> some View {
configuration.label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import SwiftUI

final class AcknowledgementsViewModel: ObservableObject {

@Published
private (set) var acknowledgements: [AcknowledgementDependency]
@Published private (set) var acknowledgements: [AcknowledgementDependency]

var indexedAcknowledgements: [(index: Int, acknowledgement: AcknowledgementDependency)] {
return Array(zip(acknowledgements.indices, acknowledgements))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import SwiftUI

struct AcknowledgementRowView: View {
@Environment(\.openURL) private var openURL
@Environment(\.openURL)
private var openURL

let acknowledgement: AcknowledgementDependency

Expand Down
3 changes: 2 additions & 1 deletion CodeEdit/Features/CodeEditUI/Views/AreaTabBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ protocol AreaTab: View, Identifiable, Hashable {
}

struct AreaTabBar<Tab: AreaTab>: View {
@Environment(\.controlActiveState) private var activeState
@Environment(\.controlActiveState)
private var activeState

var items: [Tab]

Expand Down
3 changes: 1 addition & 2 deletions CodeEdit/Features/CodeEditUI/Views/OverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ struct OverlayView<RowView: View, PreviewView: View, Option: Identifiable & Hash
)
}

@ViewBuilder
var keyHandlers: some View {
@ViewBuilder var keyHandlers: some View {
Button {
onClose()
} label: { EmptyView() }
Expand Down
12 changes: 4 additions & 8 deletions CodeEdit/Features/CodeEditUI/Views/SegmentedControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ struct SegmentedControl: View {
private var options: [String]
private var prominent: Bool

@Binding
private var preselectedIndex: Int
@Binding private var preselectedIndex: Int

/// A view that creates a segmented control from an array of text labels.
/// - Parameters:
Expand Down Expand Up @@ -62,11 +61,9 @@ struct SegmentedControlItem: View {
@Environment(\.controlActiveState)
private var activeState

@State
var isHovering: Bool = false
@State var isHovering: Bool = false

@State
var isPressing: Bool = false
@State var isPressing: Bool = false

var body: some View {
Text(label)
Expand Down Expand Up @@ -113,8 +110,7 @@ struct SegmentedControlItem: View {
}
}

@ViewBuilder
private var background: some View {
@ViewBuilder private var background: some View {
if prominent {
if active {
Color.accentColor.opacity(activeState != .inactive ? 1 : 0.5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ struct XcodeButtonStyle: ButtonStyle {
var isHovering: Bool
var namespace: Namespace.ID

@Environment(\.controlSize) var controlSize
@Environment(\.controlSize)
var controlSize

@Environment(\.colorScheme) var colorScheme
@Environment(\.colorScheme)
var colorScheme

@Environment(\.controlActiveState) private var activeState
@Environment(\.controlActiveState)
private var activeState

func makeBody(configuration: Configuration) -> some View {
configuration.label
Expand Down
6 changes: 2 additions & 4 deletions CodeEdit/Features/CodeEditUI/Views/SettingsTextEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import Foundation
import SwiftUI

struct SettingsTextEditor: View {
@State
private var isFocus: Bool = false
@State private var isFocus: Bool = false

@Binding
var text: String
@Binding var text: String

init(text: Binding<String>) {
self._text = text
Expand Down
15 changes: 5 additions & 10 deletions CodeEdit/Features/CodeEditUI/Views/ToolbarBranchPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ struct ToolbarBranchPicker: View {
@Environment(\.controlActiveState)
private var controlActive

@State
matthijseikelenboom marked this conversation as resolved.
Show resolved Hide resolved
private var isHovering: Bool = false
@State private var isHovering: Bool = false

@State
private var displayPopover: Bool = false
@State private var displayPopover: Bool = false

@State
private var currentBranch: String?
@State private var currentBranch: String?

/// Initializes the ``ToolbarBranchPicker`` with an instance of a `WorkspaceClient`
/// - Parameter shellClient: An instance of the current `ShellClient`
Expand Down Expand Up @@ -105,8 +102,7 @@ struct ToolbarBranchPicker: View {
private struct PopoverView: View {
var gitClient: GitClient?

@Binding
var currentBranch: String?
@Binding var currentBranch: String?

var body: some View {
VStack(alignment: .leading) {
Expand Down Expand Up @@ -154,8 +150,7 @@ struct ToolbarBranchPicker: View {
@Environment(\.dismiss)
private var dismiss

@State
private var isHovering: Bool = false
@State private var isHovering: Bool = false

var body: some View {
Button {
Expand Down
18 changes: 6 additions & 12 deletions CodeEdit/Features/CodeFile/CodeFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,19 @@ enum CodeFileError: Error {
@objc(CodeFileDocument)
final class CodeFileDocument: NSDocument, ObservableObject, QLPreviewItem {

@Published
matthijseikelenboom marked this conversation as resolved.
Show resolved Hide resolved
var content = ""
@Published var content = ""

/// Used to override detected languages.
@Published
var language: CodeLanguage?
@Published var language: CodeLanguage?

/// Document-specific overriden indent option.
@Published
var indentOption: SettingsData.TextEditingSettings.IndentOption?
@Published var indentOption: SettingsData.TextEditingSettings.IndentOption?

/// Document-specific overriden tab width.
@Published
var defaultTabWidth: Int?
@Published var defaultTabWidth: Int?

/// Document-specific overriden line wrap preference.
@Published
var wrapLines: Bool?
@Published var wrapLines: Bool?

/*
This is the main type of the document.
Expand Down Expand Up @@ -74,8 +69,7 @@ final class CodeFileDocument: NSDocument, ObservableObject, QLPreviewItem {
fileURL
}

@Published
var cursorPosition = (1, 1)
@Published var cursorPosition = (1, 1)

// MARK: - NSDocument

Expand Down
47 changes: 25 additions & 22 deletions CodeEdit/Features/CodeFile/CodeFileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,31 @@ import Combine

/// CodeFileView is just a wrapper of the `CodeEditor` dependency
struct CodeFileView: View {
@ObservedObject
private var codeFile: CodeFileDocument

@AppSettings(\.textEditing.defaultTabWidth) var defaultTabWidth
@AppSettings(\.textEditing.indentOption) var indentOption
@AppSettings(\.textEditing.lineHeightMultiple) var lineHeightMultiple
@AppSettings(\.textEditing.wrapLinesToEditorWidth) var wrapLinesToEditorWidth
@AppSettings(\.textEditing.font) var settingsFont
@AppSettings(\.theme.useThemeBackground) var useThemeBackground
@AppSettings(\.theme.matchAppearance) var matchAppearance
@AppSettings(\.textEditing.letterSpacing) var letterSpacing
@AppSettings(\.textEditing.bracketHighlight) var bracketHighlight
@ObservedObject private var codeFile: CodeFileDocument

@AppSettings(\.textEditing.defaultTabWidth)
var defaultTabWidth
@AppSettings(\.textEditing.indentOption)
var indentOption
@AppSettings(\.textEditing.lineHeightMultiple)
var lineHeightMultiple
@AppSettings(\.textEditing.wrapLinesToEditorWidth)
var wrapLinesToEditorWidth
@AppSettings(\.textEditing.font)
var settingsFont
@AppSettings(\.theme.useThemeBackground)
var useThemeBackground
@AppSettings(\.theme.matchAppearance)
var matchAppearance
@AppSettings(\.textEditing.letterSpacing)
var letterSpacing
@AppSettings(\.textEditing.bracketHighlight)
var bracketHighlight

@Environment(\.colorScheme)
private var colorScheme

@StateObject
private var themeModel: ThemeModel = .shared
@StateObject private var themeModel: ThemeModel = .shared

private var cancellables = [AnyCancellable]()

Expand Down Expand Up @@ -64,16 +71,13 @@ struct CodeFileView: View {
.store(in: &cancellables)
}

@State
private var selectedTheme = ThemeModel.shared.selectedTheme ?? ThemeModel.shared.themes.first!
@State private var selectedTheme = ThemeModel.shared.selectedTheme ?? ThemeModel.shared.themes.first!

@State
private var font: NSFont = {
@State private var font: NSFont = {
return Settings[\.textEditing].font.current()
}()

@State
private var bracketPairHighlight: BracketPairHighlight? = {
@State private var bracketPairHighlight: BracketPairHighlight? = {
let theme = ThemeModel.shared.selectedTheme ?? ThemeModel.shared.themes.first!
let color = Settings[\.textEditing].bracketHighlight.useCustomColor
? Settings[\.textEditing].bracketHighlight.color.nsColor
Expand All @@ -93,8 +97,7 @@ struct CodeFileView: View {
@Environment(\.edgeInsets)
private var edgeInsets

@EnvironmentObject
private var tabgroup: TabGroupData
@EnvironmentObject private var tabgroup: TabGroupData

var body: some View {
CodeEditTextView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ import Foundation
/// query text and list of filtered commands
final class CommandPaletteViewModel: ObservableObject {

@Published
var commandQuery: String = ""
@Published var commandQuery: String = ""

@Published
var selected: Command?
@Published var selected: Command?

@Published
var isShowingCommandsList: Bool = true
@Published var isShowingCommandsList: Bool = true

@Published
var filteredCommands: [Command] = []
@Published var filteredCommands: [Command] = []

init() {}

Expand Down
12 changes: 4 additions & 8 deletions CodeEdit/Features/Commands/Views/CommandPaletteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ struct CommandPaletteView: View {
@Environment(\.colorScheme)
private var colorScheme: ColorScheme

@ObservedObject
private var state: CommandPaletteViewModel
@ObservedObject private var state: CommandPaletteViewModel

@ObservedObject
private var commandManager: CommandManager = .shared
@ObservedObject private var commandManager: CommandManager = .shared

@State
private var monitor: Any?
@State private var monitor: Any?

@State
private var selectedItem: Command?
@State private var selectedItem: Command?

private let closePalette: () -> Void

Expand Down
Loading