BodyLengthVisitor

open class BodyLengthVisitor<LevelConfig> : ViolationsSyntaxVisitor<LevelConfig> where LevelConfig : SeverityLevelsBasedRuleConfiguration

Violation visitor customized to collect violations of code blocks that exceed a specified number of lines.

  • Declaration

    Swift

    @inlinable
    override public init(configuration: LevelConfig, file: SwiftLintFile)
  • Registers a violation if a body exceeds the configured line count.

    Declaration

    Swift

    public func registerViolations(leftBrace: TokenSyntax,
                                   rightBrace: TokenSyntax,
                                   violationNode: some SyntaxProtocol,
                                   objectName: String)

    Parameters

    leftBrace

    The left brace token of the body.

    rightBrace

    The right brace token of the body.

    violationNode

    The syntax node where the violation is to be reported.

    objectName

    The name of the object (e.g., “Function”, “Closure”) used in the violation message.