Skip to content

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

Closed

Description

@arsonik

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 !

Activity

  1. arsonik commented on Nov 24, 2015

    @arsonik
    Author

    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

  2. bjzhou commented on Nov 26, 2015

    @bjzhou

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

  3. jpsim commented on Nov 26, 2015

    @jpsim
    Collaborator

    @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.
  4. added
    question
    on Nov 26, 2015
  5. bjzhou commented on Nov 27, 2015

    @bjzhou

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

  6. jpsim commented on Nov 27, 2015

    @jpsim
    Collaborator

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

    image

  7. SokichiFujita commented on Nov 30, 2015

    @SokichiFujita

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

    commaviolation

  8. hankbao commented on Dec 2, 2015

    @hankbao

    Same issue here.

  9. arsonik commented on Dec 2, 2015

    @arsonik
    Author

    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.

  10. jpsim commented on Dec 2, 2015

    @jpsim
    Collaborator

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

  11. bjzhou commented on Dec 3, 2015

    @bjzhou
    //
    //  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

  12. jpsim commented on Dec 3, 2015

    @jpsim
    Collaborator

    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.

  13. added a commit that references this issue on Dec 3, 2015
    008f85f
  14. jpsim commented on Dec 3, 2015

    @jpsim
    Collaborator

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions