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

Require multiline parameters and arguments to start on a new line after the opening parenthesis

I'm configuring SwiftLint for a project, and one of our standards that I would like to enforce is this: when a function is declared or called, and its parameters or arguments are broken over multiple lines, then the first parameter should always be…
Phlippie Bosman
  • 5,378
  • 3
  • 26
  • 29
3
votes
1 answer

Run SwiftLint on pull request GitHub actions

I m running jobs on Mac-os-11. I have integrated the SwiftLint locally as well and that is working fine. But When someone raise the pr I need to run the SwiftLint on GitHub actions. How can I do that. Below is the current yml file for actions. name:…
3
votes
0 answers

Force new line between two functions using swiftlint

I have added custom_rule for forcing single line space between two functions. Below is my custom rule. But it is not showing warning. Anyone having idea of this? custom_rules: comma_space_rule: include: "*.swift" …
Dharani
  • 63
  • 8
3
votes
1 answer

What should be the path of SwiftLint when installed with Swift Package Dependency

I have installed SwiftLint with Swift Package Dependancy. I have added the following Run script in Build Phases as described in the manual: if which swiftlint >/dev/null; then swiftlint else echo "warning: SwiftLint not installed, download from…
Luda
  • 7,282
  • 12
  • 79
  • 139
3
votes
1 answer

iOS SwiftLint Identifier Name doesn't work

https://realm.github.io/SwiftLint/identifier_name.html Hello. I recently encountered swiftlint and learned this. But there's a problem. I modified the Identifier Name of swiftlint to maintain the CalmelCase grammar, but it didn't work. this is my…
monglong
  • 455
  • 3
  • 11
3
votes
1 answer

Display SwiftLint analyze results in Xcode

I'm testing SwiftLint's (experimental) analyze feature and am able to generate reports. Now I would like to get them back into Xcode and display these as warnings and errors. Using the xcode formatter/reporter a file of this structure was…
Carsten
  • 1,029
  • 14
  • 29
3
votes
2 answers

Switch case formatting issue with SwiftLint

My switch case is auto formatted when i do Cntrl + i , like below switch someBool { ↓case true: print("success") ↓case false: print("failed") } but its throws a lint warning Switch and Case Statement Alignment Violation:…
Pavan kumar C
  • 393
  • 1
  • 4
  • 15
3
votes
1 answer

SwiftLint install step fails on GitHub Actions

Recently something changed on GitHub Actions and we're not sure what happened or how to resolve it. We are testing and building iOS apps and have SwiftLint in place for our automatic PR checks. For months our job configuration worked like a charm…
JanMensch
  • 1,720
  • 1
  • 18
  • 27
3
votes
2 answers

Control Statement Violation inside for-loop

I am using SwiftLint in my app. I am getting Control Statement Violation: if, for, guard, switch, while, and catch statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses. (control_statement). What is wrong with that…
Ahil
  • 57
  • 2
  • 11
3
votes
1 answer

SwiftLint Rule for Braces on next line but with some exceptions

I want to modify .swiftlint.yml to add some custom rules for enforcing braces on next line. This works for me ... opening_braces: name: "Opening Braces not on Next Line" message: "Opening braces should be placed on the next line." …
BadmintonCat
  • 9,416
  • 14
  • 78
  • 129
3
votes
0 answers

How to use swiftlint command and Xcode Script when .swiftlint.yml file not in the same folder with project.xcodeproj?

I use SwiftLint to control the code style of my project, it is working fine almost all the time. But I met a little trouble: when the .swiftlint.yml file not in the same folder with the project file '.xcodeproj', if I use command swiftlint…
Raymond Liao
  • 1,799
  • 3
  • 20
  • 32
3
votes
2 answers

Unused Optional Binding Violation: Prefer `!= nil` over `let _ =` (unused_optional_binding) while using swiftlint

I have defined a class for slide menu controller. So I have got the following code like this: open override func closeLeft() { guard let _ = leftViewController else { // If leftViewController is nil, then return return } …
Chelsea Shawra
  • 1,593
  • 4
  • 22
  • 43
3
votes
2 answers

Regex for swiftlint custom rule

I am creating custom rules in swiftlint program. This is my reference: https://github.com/realm/SwiftLint I wanted to add a custom rule where I have to detect 2 or more spaces after ','. So I added this rule. comma_space_rule: regex: ",[ ]{2,}" …
mythicalcoder
  • 3,143
  • 1
  • 32
  • 42
3
votes
1 answer

Regex - sets subtraction

I have to find all strings starting with //MARK that do not contain sting ABCDS. I had some trials but all failed. Biggest question here is to mark set A-B. (\/\/[ ]*MARK[ \t]*[:]*[ \t]*[^\n(?P=ABCD)]*) It should work with: //MARK:…
Piotr_iOS
  • 129
  • 1
  • 7
2
votes
1 answer

Regex where substring isn't found in pattern in specific location

I am trying to build a (multiline) pattern for a linter, to catch cases where: There is a Text( declaration That is not followed by .appFont( declaration... ...before the next occurrence of } (end of function) or Text( (another Text…
Aviel Gross
  • 9,770
  • 3
  • 52
  • 62