Skip to content

indentation_width is not working well with multiple line if and guard #4961

Closed

Description

@miku1958

New Issue Checklist

Describe the bug

For example:
image

Complete output when running SwiftLint, including the stack trace and command used

Swift package plugin

Environment

  • SwiftLint version: 0.51.0
  • Installation method used: SPM
  • Paste your configuration file:
opt_in_rules:
  - indentation_width

indentation_width:
   severity: warning 
   indentation_width: 4
   include_comments: false
   include_compiler_directives: false
   trueinclude_multiline_strings: false
  • Are you using nested configurations?
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)?
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
// This triggers a violation:
        guard let startSubvalue = subvalue(at: gesture.startLocation, minutes: minutes),
              let currentSubvalue = subvalue(at: gesture.location, minutes: minutes) else {
            return nil
        }

Activity

  1. added
    bug
    on May 19, 2023
  2. shmilyQin commented on Jul 7, 2023

    @shmilyQin

    Facing the same issue. could you tell me whether you fix it? Thanks.

  3. SimplyDanny commented on Jul 8, 2023

    @SimplyDanny
    Collaborator

    I suppose this is not straightforward to fix. I'm not going to invest energy into this in the near future. But everyone is free to propose a PR. 😉

  4. added 2 commits that reference this issue on Feb 19, 2026
    3de9897
    f158dbd
  5. tanaev commented on Mar 24, 2026

    @tanaev
    Contributor

    I suppose this is not straightforward to fix. I'm not going to invest energy into this in the near future. But everyone is free to propose a PR. 😉

    Please take a look

  6. added 3 commits that reference this issue on Apr 10, 2026
    a09d152
    6899f95
    863fde3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions