Skip to content

Commit

Permalink
Move reusable functionality from SwiftLintBuiltInRules to SwiftLintCore
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny committed Mar 4, 2024
1 parent 33bf93c commit 768f00d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SwiftLintCore

struct FunctionBodyLengthRule: SwiftSyntaxRule {
var configuration = SeverityLevelsConfiguration<Self>(warning: 50, error: 100)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SwiftLintCore

private func wrapExample(
prefix: String = "",
_ type: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import SwiftSyntax

final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<SeverityLevelsConfiguration<Parent>> {
public final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<SeverityLevelsConfiguration<Parent>> {
private let kind: Kind

enum Kind {
public enum Kind {
case closure
case function
case type
Expand All @@ -20,12 +20,12 @@ final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<Severit
}
}

init(kind: Kind, file: SwiftLintFile, configuration: SeverityLevelsConfiguration<Parent>) {
public init(kind: Kind, file: SwiftLintFile, configuration: SeverityLevelsConfiguration<Parent>) {
self.kind = kind
super.init(configuration: configuration, file: file)
}

override func visitPost(_ node: EnumDeclSyntax) {
public override func visitPost(_ node: EnumDeclSyntax) {
if kind == .type {
registerViolations(
leftBrace: node.memberBlock.leftBrace,
Expand All @@ -35,7 +35,7 @@ final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<Severit
}
}

override func visitPost(_ node: ClassDeclSyntax) {
public override func visitPost(_ node: ClassDeclSyntax) {
if kind == .type {
registerViolations(
leftBrace: node.memberBlock.leftBrace,
Expand All @@ -45,7 +45,7 @@ final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<Severit
}
}

override func visitPost(_ node: StructDeclSyntax) {
public override func visitPost(_ node: StructDeclSyntax) {
if kind == .type {
registerViolations(
leftBrace: node.memberBlock.leftBrace,
Expand All @@ -55,7 +55,7 @@ final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<Severit
}
}

override func visitPost(_ node: ActorDeclSyntax) {
public override func visitPost(_ node: ActorDeclSyntax) {
if kind == .type {
registerViolations(
leftBrace: node.memberBlock.leftBrace,
Expand All @@ -65,7 +65,7 @@ final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<Severit
}
}

override func visitPost(_ node: ClosureExprSyntax) {
public override func visitPost(_ node: ClosureExprSyntax) {
if kind == .closure {
registerViolations(
leftBrace: node.leftBrace,
Expand All @@ -75,7 +75,7 @@ final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<Severit
}
}

override func visitPost(_ node: FunctionDeclSyntax) {
public override func visitPost(_ node: FunctionDeclSyntax) {
if kind == .function, let body = node.body {
registerViolations(
leftBrace: body.leftBrace,
Expand All @@ -85,7 +85,7 @@ final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<Severit
}
}

override func visitPost(_ node: InitializerDeclSyntax) {
public override func visitPost(_ node: InitializerDeclSyntax) {
if kind == .function, let body = node.body {
registerViolations(
leftBrace: body.leftBrace,
Expand Down

0 comments on commit 768f00d

Please sign in to comment.