Skip to content

Compiler Directives makes opening brace rule violation missed in subsequent function #3712

@StevenGurrSky

Description

@StevenGurrSky

New Issue Checklist

Describe the bug

If I have a function containing a compiler directive and a function below that should trigger the opening brace rule, it gets missed.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Linting Swift files in current working directory
Linting 'TestFile.swift' (1/1)
Done linting! Found 0 violations, 0 serious in 1 file.

Environment

  • SwiftLint version: 0.44.0

  • Installation method used: Downloaded from the portable_swiftlint.zip from the 0.44.0 release tag

  • Paste your configuration file: None/default/anything with opening_brace enabled

  • Are you using nested configurations? No

  • Which Xcode version are you using? 12.5.1 (although not relevant)

  • Do you have a sample that shows the issue?

class TestFile {
    func problemFunction() {
        #if DEBUG
        #endif
    }

    func openingBraceViolation()
    {
        print("Brackets")
    }
}

The openingBraceViolation function does not trigger the opening_brace rule as expected.

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