Skip to content

statement_position rule triggers for missing space before else in if stmt, but not in guard #6153

@lukaskollmer

Description

@lukaskollmer

New Issue Checklist

Bug Description

A clear and concise description of what the bug is. Ideally, provide a small (but compilable) example code snippet that
can be used to reproduce the issue.

guard foo()else { return } // This should trigger a violation, but doesn't

if foo() {
}else { // This triggers a violation (statement_position)
}

Mention the command or other SwiftLint integration method that caused the issue. Include stack traces or command output.

$ swiftlint test.swift
Linting Swift files at paths test.swift
Linting 'test.swift' (1/1)
/Users/lukas/temp/test.swift:4:1: warning: Statement Position Violation: Else and catch should be on the same line, one space after the previous declaration (statement_position)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version: 0.59.1
  • Xcode version Xcode 16.4 Build version 16F6
  • Installation method used Homebrew
  • Configuration file: none (using implicit default config)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected and reproducible misbehavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions