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
1 answer

How to fix Cyclonemtic Complexity? - RxDataSource RxSwift - SwiftLint

I met warning like this "Cyclomatic Complexity Violation: Function should have complexity 10 or less: currently complexity equals 14 (cyclomatic_complexity)" when I used RxDataSource. My code structure like this: struct ItemDetailDataSource { …
hhg
  • 79
  • 1
  • 6
0
votes
1 answer

how to run SwiftLint on uncommitted files for m1

I found this shell script # Run SwiftLint START_DATE=$(date +"%s") SWIFT_LINT=/usr/local/bin/swiftlint # Run SwiftLint for given filename run_swiftlint() { local filename="${1}" if [[ "${filename##*.}" == "swift" ]]; then …
user1898829
  • 3,437
  • 6
  • 34
  • 62
0
votes
1 answer

Using a closure vs a method within a view that takes in a closure

I've been using SwiftLint and ran into multiple multiple_closures_with_trailing_closure errors defined here. The biggest issue I had was my Button where I would toggle some boolean value, e.g. Button(action: {self.startTimer.toggle()}) { …
Paul
  • 1,101
  • 1
  • 11
  • 20
0
votes
1 answer

I Can use a custom Swiftlint Instalation path on xcode?

I need to install swiftlint with mint on my mac, on the path user/.mint/bin, but xcode dont recognize the installation i can use a custom path xcode swiftlint configuration ? I added a default image from the conf below.
Podrosa
  • 27
  • 8
0
votes
1 answer

SwiftLint Custom Spacing Rule After slass/struct/enum/extension

I've got the following regex that is working via https://regex101.com/r/7D6fAL/1 but is not working when added as a swiftlint custom rule. I would like for the rule to trigger under the following conditions (working as expected in regex101): //…
Jax
  • 210
  • 1
  • 7
0
votes
1 answer

How to enforce a person to use the type of data type while declaration using swiftlint

I'm trying to enforce my team to use data type when declairing a var/let Instead of var name = "john" I want var name: String = "john" Can anyone name the rule of swiftLint to implement this change?
0
votes
2 answers

SwiftLint: how to configure rule severity for a rule with warning and error configurations

I would like to configure the Swiftlint cyclomatic_complexity rule to always have the severity level of warning. Here are the approaches I have tried in the .swiftlint.yml. cyclomatic_complexity: warning cyclomatic_complexity: severity:…
Ilias Karim
  • 4,798
  • 3
  • 38
  • 60
0
votes
1 answer

How to make my Github action fail if there is an error

I am having the following workflow file in my project which is used to check if there is any swiftlint error. If there is any swiftlint error, I am expecting the workflow to fail, instead, I see the Workflow success. When I check the workflow log, I…
Perseus
  • 1,546
  • 4
  • 30
  • 55
0
votes
2 answers

How to place swiftlint config file in Swift Package?

In our app we are using cocoapods to keep our config file in a private repo and access the file in build phase like this CONFIG_FILE="${PODS_ROOT}/My-Repo-Name/swiftlint.yml" "${PODS_ROOT}/SwiftLint/swiftlint" --config $CONFIG_FILE Now we are…
Alejandro Vargas
  • 1,327
  • 12
  • 26
0
votes
1 answer

Extra command for swiftlint necessary after autocorrecting?

Is it necessary to call both of these lines? swiftlint --autocorrect --format swiftlint I've seen this in some example code but for me it looks like the first line does does listing and shows the warnings/errors and afterwards corrects and formats…
brainray
  • 12,512
  • 11
  • 67
  • 116
0
votes
1 answer

Mandatory empty line after function definition SwiftLint

I am integrating swiftlint in my xcode project and setting it's configuration. But I am not able to get the rule which enforces an empty line after function definition func test1() { } func test2() { } If I add multiple spaces between two functions…
Geetanshu Gulati
  • 692
  • 8
  • 13
0
votes
1 answer

Shell script won't fully execute when running from Xcode

Hello:) I'm trying to implement a new xcode behavior which runs swiftlint's autocorrect on currently open Xcode file. If I run the script from terminal, it works just perfectly, however, if I execute the script through xcodes behaviors, all of the…
sponkau
  • 23
  • 4
0
votes
1 answer

SwiftLint config in dependency source conflicts with SwiftLint in main project

I have a project that uses SwiftLint and Swift Package Manager. One of the packages I'm pulling in (Apollo) is in turn pulling in another framework (Stencil). That framework (Stencil) has a swiftlint.yml file in its source with a specific…
SeanR
  • 7,899
  • 6
  • 27
  • 38
0
votes
0 answers

SwiftLint cannot exclude Pods folder

I configure .swiftlint.yml file on the root path of project. .swiftlint.yml: disabled_rules: - colon - comma - control_statement - trailing_whitespace opt_in_rules: - empty_count - missing_docs included: - Searcher excluded: -…
betterhee
  • 13
  • 3
0
votes
1 answer

SwiftLint: Is it possible to disable rules for a specific parameter?

I have a logging method that will inevitably be called with a parameter that violates the hardcoded_string rule of SwiftLint: Logger.log("This will be a hardcoded string usually") I am aware that I can use swiftlint:disable:next each time, but is…
Aron
  • 3,419
  • 3
  • 30
  • 42