Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule direct_return comments the whole line. #5081

Closed
2 tasks done
amaurydavid opened this issue Jun 26, 2023 · 1 comment · Fixed by #5083
Closed
2 tasks done

Rule direct_return comments the whole line. #5081

amaurydavid opened this issue Jun 26, 2023 · 1 comment · Fixed by #5083

Comments

@amaurydavid
Copy link

New Issue Checklist

Describe the bug

When using swiftlint --fix with the direct_returnrule enabled, the following code lines are mishandled:

let view = nib.instantiate(withOwner: self, options: nil).first as! UIView // swiftlint:disable:this force_cast
return view

The rule currently updates the code to

 // swiftlint:disable:this force_cast        return nib.instantiate(withOwner: self, options: nil).first as! UIView // swiftlint:disable:this force_cast

adding the comment both before and after the statement.
An expected update would be

return nib.instantiate(withOwner: self, options: nil).first as! UIView // swiftlint:disable:this force_cast

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.52.3
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? brew
  • Paste your configuration file:
only_rules:
  - direct_return
  • Are you using nested configurations? no
  • Which Xcode version are you using (check xcodebuild -version)? Version 14.3.1 (14E300c)
@mildm8nnered
Copy link
Collaborator

I have a possible fix for this ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants