@@ -58,7 +58,39 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
5858 diagnoseLowerCamelCaseViolations (
5959 pat. identifier, allowUnderscores: false , description: identifierDescription ( for: node) )
6060 }
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
6294 }
6395
6496 public override func visit( _ node: FunctionDeclSyntax ) -> SyntaxVisitorContinueKind {
@@ -68,7 +100,19 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
68100 diagnoseLowerCamelCaseViolations (
69101 node. identifier, allowUnderscores: allowUnderscores,
70102 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
72116 }
73117
74118 public override func visit( _ node: EnumCaseElementSyntax ) -> SyntaxVisitorContinueKind {
@@ -97,8 +141,11 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
97141/// - Returns: A human readable description of the node and its identifier.
98142fileprivate func identifierDescription< NodeType: SyntaxProtocol > ( for node: NodeType ) -> String {
99143 switch Syntax ( node) . as ( SyntaxEnum . self) {
144+ case . closureSignature: return " closure parameter "
100145 case . enumCaseElement: return " enum case "
101146 case . functionDecl: return " function "
147+ case . optionalBindingCondition( let binding) :
148+ return binding. letOrVarKeyword. tokenKind == . varKeyword ? " variable " : " constant "
102149 case . variableDecl( let variableDecl) :
103150 return variableDecl. letOrVarKeyword. tokenKind == . varKeyword ? " variable " : " constant "
104151 default :
0 commit comments