Skip to content

Commit 677eae6

Browse files
leogdionclaude
andcommitted
Fix type_contents_order violations in multiple files
- Reorder type members to follow SwiftLint type_contents_order rule - Move properties before initializers and other methods - Fixed violations in: * NormalizeOptions.swift * LetBindingPattern.swift * Throw.swift * TypeAlias.swift * Break.swift * Continue.swift 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c12ced3 commit 677eae6

File tree

7 files changed

+46
-45
lines changed

7 files changed

+46
-45
lines changed

.swiftlint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ opt_in_rules:
7777
- strong_iboutlet
7878
- toggle_bool
7979
# - trailing_closure
80-
# - type_contents_order
80+
- type_contents_order
8181
- unavailable_function
8282
- unneeded_parentheses_in_closure_argument
8383
- unowned_variable_capture
@@ -137,3 +137,4 @@ disabled_rules:
137137
- trailing_comma
138138
- opening_brace
139139
- optional_data_string_conversion
140+
- todo

Sources/SyntaxKit/Declarations/TypeAlias.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,6 @@ public struct TypeAlias: CodeBlock, Sendable {
3535
private let existingType: String
3636
private var attributes: [AttributeInfo] = []
3737

38-
/// Creates a `typealias` declaration.
39-
/// - Parameters:
40-
/// - name: The new name that will alias the existing type.
41-
/// - type: The existing type that is being aliased.
42-
public init(_ name: String, equals type: String) {
43-
self.name = name
44-
self.existingType = type
45-
}
46-
47-
/// Adds an attribute to the typealias declaration.
48-
/// - Parameters:
49-
/// - attribute: The attribute name (without the @ symbol).
50-
/// - arguments: The arguments for the attribute, if any.
51-
/// - Returns: A copy of the typealias with the attribute added.
52-
public func attribute(_ attribute: String, arguments: [String] = []) -> Self {
53-
var copy = self
54-
copy.attributes.append(AttributeInfo(name: attribute, arguments: arguments))
55-
return copy
56-
}
57-
5838
public var syntax: any SyntaxProtocol {
5939
// `typealias` keyword token
6040
let keyword = TokenSyntax.keyword(.typealias, trailingTrivia: .space)
@@ -76,6 +56,26 @@ public struct TypeAlias: CodeBlock, Sendable {
7656
)
7757
}
7858

59+
/// Creates a `typealias` declaration.
60+
/// - Parameters:
61+
/// - name: The new name that will alias the existing type.
62+
/// - type: The existing type that is being aliased.
63+
public init(_ name: String, equals type: String) {
64+
self.name = name
65+
self.existingType = type
66+
}
67+
68+
/// Adds an attribute to the typealias declaration.
69+
/// - Parameters:
70+
/// - attribute: The attribute name (without the @ symbol).
71+
/// - arguments: The arguments for the attribute, if any.
72+
/// - Returns: A copy of the typealias with the attribute added.
73+
public func attribute(_ attribute: String, arguments: [String] = []) -> Self {
74+
var copy = self
75+
copy.attributes.append(AttributeInfo(name: attribute, arguments: arguments))
76+
return copy
77+
}
78+
7979
private func buildAttributeList(from attributes: [AttributeInfo]) -> AttributeListSyntax {
8080
if attributes.isEmpty {
8181
return AttributeListSyntax([])

Sources/SyntaxKit/ErrorHandling/Throw.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ public import SwiftSyntax
3434
public struct Throw: CodeBlock {
3535
private let expr: any CodeBlock
3636

37-
public init(_ expr: any CodeBlock) {
38-
self.expr = expr
39-
}
40-
4137
public var syntax: any SyntaxProtocol {
4238
let expression: ExprSyntax
4339
if let enumCase = expr as? EnumCase {
@@ -54,4 +50,8 @@ public struct Throw: CodeBlock {
5450
)
5551
)
5652
}
53+
54+
public init(_ expr: any CodeBlock) {
55+
self.expr = expr
56+
}
5757
}

Sources/SyntaxKit/Patterns/LetBindingPattern.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ public enum Pattern {
4545
internal struct LetBindingPattern: PatternConvertible {
4646
private let identifier: String
4747

48-
internal init(identifier: String) {
49-
self.identifier = identifier
50-
}
51-
5248
/// SwiftSyntax representation of the let binding pattern.
5349
internal var patternSyntax: PatternSyntax {
5450
PatternSyntax(
@@ -58,4 +54,8 @@ internal struct LetBindingPattern: PatternConvertible {
5854
)
5955
)
6056
}
57+
58+
internal init(identifier: String) {
59+
self.identifier = identifier
60+
}
6161
}

Sources/SyntaxKit/Utilities/Break.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ public import SwiftSyntax
3333
public struct Break: CodeBlock {
3434
private let label: String?
3535

36-
/// Creates a `break` statement.
37-
/// - Parameter label: An optional label to break from a specific loop or switch.
38-
public init(_ label: String? = nil) {
39-
self.label = label
40-
}
41-
4236
public var syntax: any SyntaxProtocol {
4337
let breakStmt = BreakStmtSyntax(
4438
breakKeyword: .keyword(.break, trailingTrivia: .newline)
@@ -55,4 +49,10 @@ public struct Break: CodeBlock {
5549
return StmtSyntax(breakStmt)
5650
}
5751
}
52+
53+
/// Creates a `break` statement.
54+
/// - Parameter label: An optional label to break from a specific loop or switch.
55+
public init(_ label: String? = nil) {
56+
self.label = label
57+
}
5858
}

Sources/SyntaxKit/Utilities/Continue.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ public import SwiftSyntax
3333
public struct Continue: CodeBlock {
3434
private let label: String?
3535

36-
/// Creates a `continue` statement.
37-
/// - Parameter label: An optional label to continue to a specific loop.
38-
public init(_ label: String? = nil) {
39-
self.label = label
40-
}
41-
4236
public var syntax: any SyntaxProtocol {
4337
let continueStmt = ContinueStmtSyntax(
4438
continueKeyword: .keyword(.continue, trailingTrivia: .newline)
@@ -55,4 +49,10 @@ public struct Continue: CodeBlock {
5549
return StmtSyntax(continueStmt)
5650
}
5751
}
52+
53+
/// Creates a `continue` statement.
54+
/// - Parameter label: An optional label to continue to a specific loop.
55+
public init(_ label: String? = nil) {
56+
self.label = label
57+
}
5858
}

Tests/SyntaxKitTests/Unit/Utilities/NormalizeOptions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import Foundation
44
public struct NormalizeOptions: OptionSet, Sendable {
55
public let rawValue: Int
66

7-
public init(rawValue: Int) {
8-
self.rawValue = rawValue
9-
}
10-
117
/// Preserve newlines between sibling elements (useful for SwiftUI)
128
public static let preserveSiblingNewlines = NormalizeOptions(rawValue: 1 << 0)
139

@@ -25,4 +21,8 @@ public struct NormalizeOptions: OptionSet, Sendable {
2521

2622
/// Options for structural comparison (ignores all formatting)
2723
public static let structural: NormalizeOptions = []
24+
25+
public init(rawValue: Int) {
26+
self.rawValue = rawValue
27+
}
2828
}

0 commit comments

Comments
 (0)