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
0
votes
3 answers

Convert all the existing code files in the project from 2 space indentation to 4 space indentation with a Shell Script in XCode

Amazing people!! I have a project which needs a TechDebt to be executed where, all the existing code files having 2 space indentation. Now I want to convert all the 2 space indentation to 4 space indentation, is there any way I can automate this…
Kuldeep
  • 2,589
  • 1
  • 18
  • 28
0
votes
3 answers

SwiftLint - allow one line guards

SwiftLint - How to allow one line guard conditionals like this: guard let x = true else { return false } and keep conditional_returns_on_newline functionality for other cases? Edit: As far as I know SwiftLint defines rules of violations so I have…
Kaktusiarz
  • 415
  • 7
  • 22
0
votes
0 answers

SwiftLint doesn't recognize changes to .swiftlint.yml (Xcode11.3)

Trying to install swiftlint using mintfile and carthage. Xcode version 11.3.1. Using swiftlint latest version realm/SwiftLint@0.39.1. Abort trap: 6 mint run swiftlint swiftlint --path ${TARGET_PATH} --config ${SRCROOT}/.swiftlint.yml
Pratik Sodha
  • 3,679
  • 2
  • 19
  • 38
0
votes
1 answer

Eliminating forced downcasts

I am using swiftlint as a way to code better, and for the most part I have been able to muddle my way through up to the following code which includes a forced downcast: let questionToAdd = MultipleChoiceQuestion(question: dictionary["Question"] as!…
Douglas W. Palme
  • 390
  • 1
  • 4
  • 10
0
votes
0 answers

SwiftLint force new line after function opening bracket

I'm trying to write some regex in order to force a new line after function opening bracket.Currenly my regex is \{[^\n\{\}]*\n\n but it returns the opposite thing and ideas?
sger
  • 719
  • 2
  • 12
  • 26
0
votes
2 answers

Return Empty Cell to Avoid Force Casting TableView?

I'm using "as!" for a custom tableView cell and my understanding is that it's generally OK, however I'm using SwiftLint and would like to see if I can provide an alternative. Using a guard statement, is there an alternative I can provide that won't…
moosgrn
  • 379
  • 3
  • 13
0
votes
2 answers

Adding a custom rule to a certain type of function for Swiftlint

I am creating some custom rules for SwiftLint, I only want my rule to be applied to strings in certain functions, for example only the strings in a logEvent analytics.logEvent('goal_completion', { name: 'lever_puzzle'}); The SwiftLint Github…
久美子
  • 101
  • 1
  • 13
0
votes
1 answer

How to error rather than warning on specific rule

I want the build to error out on trailing_whitespace. I have added trailing_whitespace: error to my .swiftlint.yml but it's still just showing up as a warning. I've seen How to force error on SwiftLint instead of warnings? but that's about treating…
retorquere
  • 1,496
  • 1
  • 14
  • 27
0
votes
3 answers

SwiftLint causing build failed

I am using swiftlint in Build phase - Run script. Build is failed because of swiftlint error. How can I proceed successful build but still want to produce swiftlint comments (i.e. errors, warnings) in my project?
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
0
votes
2 answers

How to exclude Pod Warnings with SwiftLint

Xcode shows Warnings for some of my Pod Files, especially warnings about deprecated variables. I already have a .swiftlint.yml file and it is in the same folder as my Pods folder. This is what my file looks like: excluded: - Pods -…
nico_dkd
  • 99
  • 1
  • 9
0
votes
1 answer

Alamofire.upload SwiftLint violation

The code for uploading image with Alamofire triggers a SwiftLint violation. How can it be fixed? Alamofire.upload(multipartFormData: { (multipartFormData) in multipartFormData.append(imageData, withName: "profileImage", fileName:…
Luda
  • 7,282
  • 12
  • 79
  • 139
0
votes
2 answers

pod not excluded while lint with swift lint

I have added swiftLint to my Project and also added .swiftlint.yml file with all rules but some of rule of file not working in my project like excluded and line length. i want to exclude pod from Linting so i have added following code in…
Hardik Baldha
  • 159
  • 1
  • 14
0
votes
2 answers

Suppressing variable name length from protocols in frameworks

We are using Ad frameworks in our iOS application and integrated SwiftLint as part of the code. We noticed that some protocols from the Ad framework have variable length 2. Example is: func ad(_ ad: Any!, requestFailedWithError error: Error!) As…
Satyam
  • 15,493
  • 31
  • 131
  • 244
0
votes
3 answers

What is the easiest way to systematically replace ".doOnComplete {}" with ".do(onComplete: {})" in a large Swift codebase?

What is the best way to replace: .doOnComplete { // Implementation } with .do( onComplete: { // Implementation } ) throughout a large Swift codebase? Given that there are a large number of these manually replacing is not an…
0
votes
1 answer

Fetch the latest pkg from github

I use this script to install swiftlint on travis: set -e SWIFTLINT_PKG_PATH="/tmp/SwiftLint.pkg" SWIFTLINT_PKG_URL="https://github.com/realm/SwiftLint/releases/download/0.25.1/SwiftLint.pkg" wget --output-document=$SWIFTLINT_PKG_PATH…
Vladyslav Zavalykhatko
  • 15,202
  • 8
  • 65
  • 100