Questions tagged [swiftlint]

A tool to enforce Swift style and conventions, loosely based on GitHub's Swift Style Guide. SwiftLint hooks into Clang and SourceKit to use the AST representation of your source files for more accurate results.

A tool to enforce Swift style and conventions, loosely based on GitHub's Swift Style Guide. SwiftLint hooks into Clang and SourceKit to use the AST representation of your source files for more accurate results.

The tool verifies that your Swift code conforms to a set of rules syntactic rules defined by you and your teammates.

More details at SwiftLint Github.

185 questions
16
votes
2 answers

Swift 4 Using KVO to listen to volume changes

I just updated to Swift 4 and Xcode 9 and got a (swiftlint) warning for the following code telling me that I should use KVO now: Warning: (Block Based KVO Violation: Prefer the new block based KVO API with keypaths when using Swift 3.2 or later.…
Eternal Black
  • 259
  • 2
  • 15
16
votes
3 answers

How to force error on SwiftLint instead of warnings?

my question is very simple, how do I make all warnings become errors on SwiftLint? (without manually configuring each rule separately)
Rodrigo Ruiz
  • 4,248
  • 6
  • 43
  • 75
16
votes
1 answer

Legacy Constructor Violation: Swift constructors are preferred over legacy convenience functions. (legacy_constructor)

I'm getting a SwiftLint warning on this line: return UIEdgeInsetsMake(topInset, leftInset, bottomInset, rightInset) This is the warning : Legacy Constructor Violation: Swift constructors are preferred over legacy convenience functions.…
etayluz
  • 15,920
  • 23
  • 106
  • 151
15
votes
1 answer

What's the difference between swiftlint:disable:next and swiftlint:disable:this?

I'm a little confused about the differences of: swiftlint:disable:next swiftlint:disable:this
mfaani
  • 33,269
  • 19
  • 164
  • 293
15
votes
1 answer

What exactly does 'Type Body Length' mean in Swiftlint?

We just added Swiftlint to our project and we want to follow all the rules but I'm not sure what's meant by 'type_body_length' warning. I'm not a native english speaker so I find it a bit confusing. There is a rule for file length aswell so how do…
andromedainiative
  • 4,414
  • 6
  • 22
  • 34
15
votes
1 answer

Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)

I am currently using SwiftLint for the perfect coding standards in my projects. After installing it I am getting so many warnings and the common ones are: "Colon Violation: Colons should be next to the identifier when specifying a type and next to…
Michelle Root
  • 185
  • 1
  • 3
  • 9
14
votes
2 answers

How to Exclude Files/Folders for SwiftLint Using CocoaPods?

The Problem When building my xcode Swift project, I am getting violations from SwiftLint (i.e. Empty Count Violations) of files/folders that I exclude in my .swiftlint.yml file, but when specifying those files/folders in the excluded section, the…
gpsugy
  • 1,199
  • 1
  • 11
  • 25
14
votes
0 answers

Better Explanation of SwiftLint Opt-In Rules match_kinds setting

Does anyone have a better explanation of the match_kinds types for the Opt-In rules of SwiftLint. The documentation gives the enumerated types, but no explanation other than names. The match_kinds types include: argument, attribute.builtin,…
Steve Sheets
  • 447
  • 2
  • 10
13
votes
10 answers

No lintable files found at paths SwiftLint

I tried to install SwiftLint using CocoaPods and I add in Build phases the following script : "${PODS_ROOT}/SwiftLint/swiftlint" SwiftLint is installed correctly and I get many errors and warnings in the project. Then, I create the swiftLint.yml…
Rwaydha
  • 171
  • 1
  • 2
  • 8
12
votes
4 answers

Excluding Pods from SwiftLint configuration

I'm integrating SwiftLint, via Cocoapods, into an existing project. My project directory is as such: AppNameRepo |-- AppName | |--.swiftlint.yml |--AppName.xcworkspace |--Pods And my .swiftlint.yml, as I've tried to exclude pods: included: #…
agreendev
  • 309
  • 1
  • 3
  • 9
12
votes
1 answer

What is extension_access_modifier swiftlint?

I added Swiftlint to a project and I'm having trouble understanding what the warning is for extension_access_modifier. I see it mainly on a class that is declared as public, but there are extensions littered throughout the codebase that adds…
Crystal
  • 28,460
  • 62
  • 219
  • 393
12
votes
3 answers

Nesting violation. Types should be nested at most 1 level deep

struct Email { struct Constraints { static let top = 20.asConstraint() } static let placeholder = "login_email" } How to fix that issue?
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
11
votes
1 answer

Nested types in Swift - what is the good practice?

I have a swiftlint warning that bothers me. warning: Nesting Violation: Types should be nested at most 1 level deep (nesting) However, the nesting of structs is an established programming technique, and quite a few people advocate it. Edit: Indeed…
Kheldar
  • 5,361
  • 3
  • 34
  • 63
11
votes
3 answers

How do I use swiftlint to lint a single file?

I'd like to use swiftlint to lint a single file. How do I accomplish this? Checking the docs on https://github.com/realm/SwiftLint was not helpful.
ablarg
  • 2,400
  • 1
  • 24
  • 32
10
votes
1 answer

SwiftLint get "implicit_getter" warning in overriding getter in Swift

extension CGRect { var x: CGFloat { set { self.origin.x = newValue } get { return self.origin.x } > got warning this line } } warning: Implicit Getter Violation: Computed read-only properties should avoid using the get…
user13538171
  • 101
  • 1
  • 3
1
2
3
12 13