@@ -58,7 +58,39 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
58
58
diagnoseLowerCamelCaseViolations (
59
59
pat. identifier, allowUnderscores: false , description: identifierDescription ( for: node) )
60
60
}
61
- return . skipChildren
61
+ return . visitChildren
62
+ }
63
+
64
+ public override func visit( _ node: OptionalBindingConditionSyntax ) -> SyntaxVisitorContinueKind {
65
+ guard let pattern = node. pattern. as ( IdentifierPatternSyntax . self) else {
66
+ return . visitChildren
67
+ }
68
+ diagnoseLowerCamelCaseViolations (
69
+ pattern. identifier, allowUnderscores: false , description: identifierDescription ( for: node) )
70
+ return . visitChildren
71
+ }
72
+
73
+ public override func visit( _ node: ClosureSignatureSyntax ) -> SyntaxVisitorContinueKind {
74
+ if let input = node. input {
75
+ if let closureParamList = input. as ( ClosureParamListSyntax . self) {
76
+ for param in closureParamList {
77
+ diagnoseLowerCamelCaseViolations (
78
+ param. name, allowUnderscores: false , description: identifierDescription ( for: node) )
79
+ }
80
+ } else if let parameterClause = input. as ( ParameterClauseSyntax . self) {
81
+ for param in parameterClause. parameterList {
82
+ if let firstName = param. firstName {
83
+ diagnoseLowerCamelCaseViolations (
84
+ firstName, allowUnderscores: false , description: identifierDescription ( for: node) )
85
+ }
86
+ if let secondName = param. secondName {
87
+ diagnoseLowerCamelCaseViolations (
88
+ secondName, allowUnderscores: false , description: identifierDescription ( for: node) )
89
+ }
90
+ }
91
+ }
92
+ }
93
+ return . visitChildren
62
94
}
63
95
64
96
public override func visit( _ node: FunctionDeclSyntax ) -> SyntaxVisitorContinueKind {
@@ -68,7 +100,19 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
68
100
diagnoseLowerCamelCaseViolations (
69
101
node. identifier, allowUnderscores: allowUnderscores,
70
102
description: identifierDescription ( for: node) )
71
- return . skipChildren
103
+ for param in node. signature. input. parameterList {
104
+ // These identifiers aren't described using `identifierDescription(for:)` because no single
105
+ // node can disambiguate the argument label from the parameter name.
106
+ if let label = param. firstName {
107
+ diagnoseLowerCamelCaseViolations (
108
+ label, allowUnderscores: false , description: " argument label " )
109
+ }
110
+ if let paramName = param. secondName {
111
+ diagnoseLowerCamelCaseViolations (
112
+ paramName, allowUnderscores: false , description: " function parameter " )
113
+ }
114
+ }
115
+ return . visitChildren
72
116
}
73
117
74
118
public override func visit( _ node: EnumCaseElementSyntax ) -> SyntaxVisitorContinueKind {
@@ -97,8 +141,11 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
97
141
/// - Returns: A human readable description of the node and its identifier.
98
142
fileprivate func identifierDescription< NodeType: SyntaxProtocol > ( for node: NodeType ) -> String {
99
143
switch Syntax ( node) . as ( SyntaxEnum . self) {
144
+ case . closureSignature: return " closure parameter "
100
145
case . enumCaseElement: return " enum case "
101
146
case . functionDecl: return " function "
147
+ case . optionalBindingCondition( let binding) :
148
+ return binding. letOrVarKeyword. tokenKind == . varKeyword ? " variable " : " constant "
102
149
case . variableDecl( let variableDecl) :
103
150
return variableDecl. letOrVarKeyword. tokenKind == . varKeyword ? " variable " : " constant "
104
151
default :
0 commit comments