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

Passing a list of filenames to SwiftLint using awk and xargs

Goal I'm trying to introduce SwiftLint to an existing project, in a gradual way, enforcing a "you touched it, you fix it" rule. All changes to the project are done via branches and PRs and the intention is that all files created or modified by a PR…
Chris
  • 3,445
  • 3
  • 22
  • 28
0
votes
0 answers

How to prevent swiftlint -fix --format to change format style of closure?

I have a Swift project in which is used swiftlint and my local version is 0.50.03. My problem is with styling on closure after running swiftlint lint --fix --format command. Here is the scenario: I have a closure that will be formatted like this…
poPaTheGuru
  • 1,009
  • 1
  • 13
  • 35
0
votes
0 answers

SwiftLint regex match multiple cases in file

Here is my rule: custom_rules: protocol_single_responsibility_violation: name: "Protocol with more than one function and or variable" regex:…
ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
0
votes
1 answer

How to match multi Line regex in SwiftLint?

I am trying to flag protocols that are created with one or more function or property. To start I created some regex that matches more than one function in a protocol in regex testers. However, when I build the app with the rule, it doesn't match…
ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
0
votes
0 answers

iOS - How to remove implicit imports?

In my team, we develop several frameworks and in one of the apps integrating said frameworks, they want to enforce the imports of FooBar framework to a specific folder and throw a compile time warning if someone tries to import FooBar outside that…
0
votes
1 answer

Swiftlint unable to open configuration file

I installed swiftlint through brew brew install swiftlint verified successfull installation through swiftlint --version 0.50.1 Added script to project export PATH="$PATH:/opt/homebrew/bin" if which swiftlint >/dev/null; then echo "SwiftLint…
patrikbelis
  • 1,350
  • 2
  • 16
  • 35
0
votes
1 answer

Why are some custom swiftlint rules marked as having an "invalid configuration"?

When I run swiftlint I get a printout saying that some rules have an invalid configuration. Invalid configuration for custom rule 'commented_out_code'. Invalid configuration for custom rule 'avoid_multiline_comment_markers'. Invalid configuration…
matthias_code
  • 833
  • 8
  • 21
0
votes
1 answer

How could I downgrade the swiftlint on my m1 pro mac

I want to downgrade the swiftlint version on my MBP M1 Pro. I installed it using brew install swiftlint In homebrew/Cellar/swiftlint the folder is 0.49.1 which I guess is the version installed on my machine. I googled and tried a few methods. But…
sachuverma
  • 559
  • 6
  • 27
0
votes
1 answer

SwiftLint exclude, disabled rule not working?

We are following the instruction from https://github.com/realm/SwiftLint. In terminal CD->PROJECT DIRECTORY touch .swiftlint.yml open .swiftlint.yml and added following rules # By default, SwiftLint uses a set of sensible default rules you can…
karthikeyan
  • 3,821
  • 3
  • 22
  • 45
0
votes
1 answer

Swiftlint unused_import rule does not work

I am using swiftlint for my project with SPM I want to use unused_imports rule like this: ... analyzer_rules: - unused_import ... But it does not find any violations, even thought they are in the project I have also tried turn it on in the…
Daniel Pustotin
  • 237
  • 1
  • 9
0
votes
1 answer

Swift swiftlint disable regular expression

I got this swiftlint error from sonarCube: Rename this constant to match the regular expression ^[a-z][a-zA-Z0-9]*$.". How can I disable the swiftlint warning from sonarCube? // Rename this constant to match the regular expression…
wong john
  • 55
  • 4
0
votes
0 answers

SwiftLint failing while file path have space

some of the file in my project are grouped with folder name with space. I added SwiftLint in my project and while any changes in file with space in file path SwiftLint gives exception. please help me. SwiftLint version : 0.46.2 error: error opening…
Moinuddin Girach
  • 213
  • 1
  • 10
0
votes
1 answer

Trying to run swiftlint through Java subprocess fails (works normally through command line)

I have a java program to run different kinds of linters, calling the linters as a process using ProcessBuilder. So far, other linters have worked for the most part but with swiftlint, i'm facing a strange issue When I run it normally from the…
Kushal Chordiya
  • 121
  • 1
  • 6
0
votes
1 answer

Make Custom SwiftLint action regex ignore comments

I have a custom SwiftLint action to flag up print() statements: custom_rules: disable_print: included: ".*\\.swift" name: "print usage" regex: "((\\bprint)|(Swift\\.print))\\s*\\(" message: "Don't use print" …
Tometoyou
  • 7,792
  • 12
  • 62
  • 108
0
votes
1 answer

Which files are failing in SwiftLint?

I'm fairly inexperienced with SwiftLint, but my branch is failing to build in CircleCI due to a linting error as indicated in the text below. We use Carthage as well as Swift Package Manager. From what I can see from the Build Phases -> Swiftlint…
JFortYork
  • 137
  • 10