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

swiflint adding incorrect spaces #5663

Open
pablorodriguezcolbaes opened this issue Jul 10, 2024 · 7 comments
Open

swiflint adding incorrect spaces #5663

pablorodriguezcolbaes opened this issue Jul 10, 2024 · 7 comments
Labels
help Questions or user problems that require more explanation rather than code changes. repro-needed Issues that cannot be reproduced or miss proper descriptive examples.

Comments

@pablorodriguezcolbaes
Copy link

swiflint adding incorrect spaces, i dont know if is a configuration issue or a bug in swiftlint, thanks for helping me

for example

func getIcon() -> UIImage ?{
func getIcon() -> UIImage? {

if hasToSav e{
if hasToSave {

HStac k{
HStack {

Environment

  • SwiftLint version: 0.55.1
  • Installation method: Homebrew
  • Paste your configuration file:
excluded: # exclude these files and directories
  - node_modules
  - APISchema
@SimplyDanny
Copy link
Collaborator

Please provide a small code snippet you run SwiftLint on together with the changed code. Also mention the command you are running.

@SimplyDanny SimplyDanny added the help Questions or user problems that require more explanation rather than code changes. label Jul 10, 2024
@pablorodriguezcolbaes
Copy link
Author

I'm executing this command

swiftlint --autocorrect

original code:

HStack{
        Spacer()
        Button(action: {
            dismiss()
        }, label: {
            SwiftUI.Image(.deleteClose)
        })
}.padding(.horizontal, -20)

changed code:

HStac k{
        Spacer()
        Button(action: {
            dismiss()
        }, label: {
            SwiftUI.Image(.deleteClose)
        })
}.padding(.horizontal, -20)

original code:

func getIcon() -> UIImage?{
        switch self {
        case .komootPlanned:
	        return UIImage(named: "komoot_empty")
        case .komootRecorded:
	        return UIImage(named: "komoot_empty")
        case .notifications:
	        return UIImage(named: "notifications_empty")
        case .subscriptions:
	        return UIImage(named: "subscriptions_empty")
        }
}

changed code:

func getIcon() -> UIImage ?{
        switch self {
        case .komootPlanned:
	        return UIImage(named: "komoot_empty")
        case .komootRecorded:
	        return UIImage(named: "komoot_empty")
        case .notifications:
	        return UIImage(named: "notifications_empty")
        case .subscriptions:
	        return UIImage(named: "subscriptions_empty")
        }
}

@gavinmcroy
Copy link

I am also having the same issue

@SimplyDanny
Copy link
Collaborator

I'm unable to reproduce this. My involved files and commands are as follows:

.swiftlint.yml

only_rules:
  - opening_brace

main.swift

func getIcon() -> UIImage?{
    nil
}
$ swiftlint --version
0.55.1
$ swiftlint lint --fix main.swift
Correcting Swift files at paths main.swift
Correcting 'main.swift' (1/1)
/Users/danny/Projects/SwiftLint/main/main.swift:1:27 Corrected Opening Brace Spacing
Done correcting 1 file!

main.swift

func getIcon() -> UIImage? {
    nil
}

Please provide an example as small as possible which causes broken output with these steps.

@gavinmcroy
Copy link

gavinmcroy commented Jul 13, 2024 via email

@pablorodriguezcolbaes
Copy link
Author

pablorodriguezcolbaes commented Jul 13, 2024

Thanks, I'm doing the same, all source folder, I can send more info tomorrow, thanks for providing more info

@mildm8nnered
Copy link
Collaborator

@gavinmcroy @pablorodriguezcolbaes - any update on this?

@SimplyDanny SimplyDanny added the repro-needed Issues that cannot be reproduced or miss proper descriptive examples. label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help Questions or user problems that require more explanation rather than code changes. repro-needed Issues that cannot be reproduced or miss proper descriptive examples.
Projects
None yet
Development

No branches or pull requests

4 participants