Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit831bf3b

Browse files
committed
Address review comments
1 parentc53e3be commit831bf3b

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

‎Source/SwiftLintBuiltInRules/Rules/Idiomatic/StaticOverFinalClassRule.swift‎

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -73,51 +73,29 @@ struct StaticOverFinalClassRule: Rule {
7373
)
7474
}
7575

76-
// Stack of flags indicating whether each level in the tree is a final class
77-
privatetypealiasLevelIsFinalClassStack=Stack<Bool>
78-
79-
privateextensionLevelIsFinalClassStack{
80-
varlastIsFinalClass:Bool{peek()==true}
81-
}
82-
8376
privateextensionStaticOverFinalClassRule{
8477
finalclassVisitor:ViolationsSyntaxVisitor<ConfigurationType>{
85-
privatevarlevels=LevelIsFinalClassStack()
78+
privatevarclassContexts=Stack<Bool>()
8679

8780
overridefunc visit(_ node:ClassDeclSyntax)->SyntaxVisitorContinueKind{
88-
levels.push(node.modifiers.contains(keyword:.final))
81+
classContexts.push(node.modifiers.contains(keyword:.final))
8982
return.visitChildren
9083
}
9184

9285
overridefunc visitPost(_ node:ClassDeclSyntax){
93-
levels.pop()
94-
}
95-
96-
overridefunc visit(_ node:FunctionDeclSyntax)->SyntaxVisitorContinueKind{
97-
validateNode(at: node.positionAfterSkippingLeadingTrivia, with: node.modifiers)
98-
return.visitChildren
86+
classContexts.pop()
9987
}
10088

10189
overridefunc visitPost(_ node:FunctionDeclSyntax){
102-
levels.pop()
103-
}
104-
105-
overridefunc visit(_ node:VariableDeclSyntax)->SyntaxVisitorContinueKind{
10690
validateNode(at: node.positionAfterSkippingLeadingTrivia, with: node.modifiers)
107-
return.visitChildren
10891
}
10992

11093
overridefunc visitPost(_ node:VariableDeclSyntax){
111-
levels.pop()
112-
}
113-
114-
overridefunc visit(_ node:SubscriptDeclSyntax)->SyntaxVisitorContinueKind{
11594
validateNode(at: node.positionAfterSkippingLeadingTrivia, with: node.modifiers)
116-
return.visitChildren
11795
}
11896

11997
overridefunc visitPost(_ node:SubscriptDeclSyntax){
120-
levels.pop()
98+
validateNode(at: node.positionAfterSkippingLeadingTrivia, with: node.modifiers)
12199
}
122100

123101
// MARK: -
@@ -126,11 +104,9 @@ private extension StaticOverFinalClassRule {
126104
modifiers.contains(keyword:.class){
127105
violations.append(position)
128106
}elseif modifiers.contains(keyword:.class),
129-
levels.lastIsFinalClass{
107+
classContexts.peek()==true{
130108
violations.append(position)
131109
}
132-
133-
levels.push(false)
134110
}
135111
}
136112
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp