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

Comma Spacing Violation: Should not be checked in String #234

Closed
arsonik opened this issue Nov 24, 2015 · 12 comments
Closed

Comma Spacing Violation: Should not be checked in String #234

arsonik opened this issue Nov 24, 2015 · 12 comments
Labels
question Question or doubts that needs discussion and clarification. Can become a bug or proposal.

Comments

@arsonik
Copy link

arsonik commented Nov 24, 2015

Why would the program check if there is a space after a comma in a string ?
Example :

let reg = try! NSRegularExpression(pattern: "[a-z]{2,5}", options: NSRegularExpressionOptions.CaseInsensitive)

will fail if we add a space {2, 5}

cheers & good job by the way !

@arsonik
Copy link
Author

arsonik commented Nov 24, 2015

Also for : Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)

screen shot 2015-11-24 at 14 59 34

@bjzhou
Copy link

bjzhou commented Nov 26, 2015

I have a problem like this, let url: String = "https://www.google.com" will fail, but let url = "https://www.google.com" will success

@jpsim
Copy link
Collaborator

jpsim commented Nov 26, 2015

@arsonik I can't reproduce your issue:

$ echo "let reg = try! NSRegularExpression(pattern: \"[a-z]{2,5}\", options: NSRegularExpressionOptions.CaseInsensitive)" | swiftlint lint --use-stdin
<nopath>:1:11: error: Force Try Violation: Force tries should be avoided. (force_try)
<nopath>:1: warning: Line Length Violation: Line should be 100 characters or less: currently 110 characters (line_length)
Done linting! Found 2 violations, 1 serious in 1 file.
$ echo "let reg = try! NSRegularExpression(pattern: \"[a-z]{2, 5}\", options: NSRegularExpressionOptions.CaseInsensitive)" | swiftlint lint --use-stdin
<nopath>:1:11: error: Force Try Violation: Force tries should be avoided. (force_try)
<nopath>:1: warning: Line Length Violation: Line should be 100 characters or less: currently 111 characters (line_length)
Done linting! Found 2 violations, 1 serious in 1 file.

@bjzhou I also can't reproduce your issue:

$ echo "let url: String = \"https://www.google.com\"" | swiftlint lint --use-stdin
Done linting! Found 0 violations, 0 serious in 1 file.
$ echo "let url = \"https://www.google.com\"" | swiftlint lint --use-stdin 
Done linting! Found 0 violations, 0 serious in 1 file.

@jpsim jpsim added the question Question or doubts that needs discussion and clarification. Can become a bug or proposal. label Nov 26, 2015
@bjzhou
Copy link

bjzhou commented Nov 27, 2015

@jpsim Don't try in command line, this issue only occurred in Xcode.

@jpsim
Copy link
Collaborator

jpsim commented Nov 27, 2015

SwiftLint doesn't behave differently on the command line versus Xcode.

image

@SokichiFujita
Copy link

@jpsim I could reproduce it. The string is for the scope string of OAuth 2.0.

commaviolation

@hankbao
Copy link

hankbao commented Dec 2, 2015

Same issue here.

@arsonik
Copy link
Author

arsonik commented Dec 2, 2015

Looks like its happening only when checked in a large file&or project.

Sent from my iPhone

On 02 Dec 2015, at 1:20 PM, Hank BAO [email protected] wrote:

Same issue here.


Reply to this email directly or view it on GitHub.

@jpsim
Copy link
Collaborator

jpsim commented Dec 2, 2015

I'm still waiting for steps to reproduce this issue, as the details shared so far are insufficient to trigger it.

@bjzhou
Copy link

bjzhou commented Dec 3, 2015

//
//  Created by 周斌佳 on 15/8/1.
//  Copyright © 2015年 周斌佳. All rights reserved.
//

struct Test {
    let url = "https://www.google.com"
    let url: String = "https://www.google.com"
}

@jpsim I reproduced my issue again, maybe the key is the comment. Please check it

@jpsim
Copy link
Collaborator

jpsim commented Dec 3, 2015

Thanks for sharing that @bjzhou, I can now reproduce the issue. I've reduced it even further:

// 周斌佳年周斌佳
let abc: String = "abc:"

Now I can investigate this.

@jpsim
Copy link
Collaborator

jpsim commented Dec 3, 2015

Should be fixed now. Thanks for reporting all! Next time, sharing a repro case really helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or doubts that needs discussion and clarification. Can become a bug or proposal.
Projects
None yet
Development

No branches or pull requests

5 participants