SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

swiflint adding incorrect spaces

Open pablorodriguezcolbaes opened this issue 1 year ago • 7 comments
trafficstars

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

pablorodriguezcolbaes avatar Jul 10 '24 17:07 pablorodriguezcolbaes

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

SimplyDanny avatar Jul 10 '24 18:07 SimplyDanny

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")
        }
}

pablorodriguezcolbaes avatar Jul 11 '24 07:07 pablorodriguezcolbaes

I am also having the same issue

gavinmcroy avatar Jul 12 '24 18:07 gavinmcroy

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.

SimplyDanny avatar Jul 13 '24 11:07 SimplyDanny

Give me a moment when I’m back in office and I’ll send over what causes it. I ran it on my entire source folder I’m not sure if that’s how it works by design but it added a weird white space to about 23 ish files mainly SwiftUI based code

On Sat, Jul 13, 2024 at 7:55 AM Danny Mösch @.***> wrote:

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.

— Reply to this email directly, view it on GitHub https://github.com/realm/SwiftLint/issues/5663#issuecomment-2226874997, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ3O33LXX67LM3RZGSC4POLZMEISXAVCNFSM6AAAAABKVMSZWOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRWHA3TIOJZG4 . You are receiving this because you commented.Message ID: @.***>

gavinmcroy avatar Jul 13 '24 13:07 gavinmcroy

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

pablorodriguezcolbaes avatar Jul 13 '24 19:07 pablorodriguezcolbaes

@gavinmcroy @pablorodriguezcolbaes - any update on this?

mildm8nnered avatar Sep 21 '24 18:09 mildm8nnered

This issue has been marked as stale because it has not seen any activity in the last 4 months. It is going to be closed soon if it stays inactive.

SimplyDanny avatar Feb 15 '25 13:02 SimplyDanny

This issue is being closed due to inactivity. Please feel free to reopen if you have more information.

github-actions[bot] avatar Apr 15 '25 08:04 github-actions[bot]