I very well could not be understanding swifltint correctly but I'm expecting this to give me a VariableNameRule error and I'm not seeing one. I've tried the latest master and homebrew release
printf -- "func fooBar() { let x = 1 }\n" > example.swift; swiftlint lint --path example.swift
$ Linting Swift files at path example.swift
$ Linting 'example.swift' (1/1)
$ Done linting! Found 0 violations, 0 serious in 1 file.
When If I do this, I see the error:
printf -- "let x = 1 }\n" > example.swift; swiftlint lint --path example.swift
$ Linting Swift files at path example.swift
$ Linting 'example.swift' (1/1)
$ /tmp/example.swift:1:1: warning: Name Format Violation: Variable name should be between 3 and 40 $ $ characters in length: 'x'
$ Done linting! Found 1 violation, 0 serious in 1 file.
Is this expected?
Since SwiftLint uses the AST obtained via SourceKit, it will share the same limitations. In this case, SourceKit doesn't identify "x" in func fooBar() { let x = 1 } as a variable.
Interesting. Shall I leave this issue open since it's weird behavior or close it since it's kind of our of our hands unless we want to write some custom AST or work around it?
Sure, let's leave this open, but the only real way to make progress on this will be to move away from using SourceKit, file a radar with Apple about it, or fix it in SourceKit itself if/when its source is released when Swift goes open-source later this year (which is unlikely).
I've created SR-5057 to track this.
This should be automatically fixed since https://github.com/apple/swift/pull/11431 was merged. I'll keep this open until that PR is included in an official release (probably 4.1?).
This was included in Swift 4.1 馃帀
Most helpful comment
This should be automatically fixed since https://github.com/apple/swift/pull/11431 was merged. I'll keep this open until that PR is included in an official release (probably 4.1?).