Linter helps you to setup .swiftlint.yml based on initial warnings and errors by executing swiftlint. It also tells you about how many warnings and errors occurs in each identifier and which identifier are correctable (it means you can use swiftlint autocorrect to fix).


The following are the details:

I tried to introduce SwiftLint for a project, but it was hard to adjust all rules manually.
The problem I faced are…

  • Got a ton of the warnings and errors at first if a project is already big.
  • Had to copy and paste from the warnings and errors in a console to my own .swiftlint.yml.
  • SwiftLint’s autocorrect is really good, but I do want to execute it step by step. If I don’t understand which rules are autocorrected, it can be really messy. I had to check the defined rules by swiftlint rules each time.
  • Wanted to see the count of warnings and errors in each rule to put a high priority on an easy problem.

So, I made a simple tool called Linter to solve the above as possible as I can.

After using Linter, you’ll see the following .swiftlint.yml for instance.

disabled_rules:
  - trailing_semicolon # (48) Correctable (you can use `swiftlint autocorrect` to fix)
  - redundant_optional_initialization # (13) Correctable (you can use `swiftlint autocorrect` to fix)
  - trailing_newline # (5) Correctable (you can use `swiftlint autocorrect` to fix)
  - statement_position # (28) Correctable (you can use `swiftlint autocorrect` to fix)
  - for_where # (6)
  - weak_delegate # (1)
...

So, you can fix the warnings and errors step by step along with your project’s spec. I highly recommend you to customize more after setting up .swiftlint.yml by Linter.

In its usage, what you have to do is just like this,

$ linter --included Sources Tests
$ linter --included AwesomeiOS AwesomeiOSTests --excluded Pods Carthage

The output will be,

disabled_rules:
  - large_tuple # (1)
  - line_length # (3)
  - identifier_name # (25)
  - cyclomatic_complexity # (1)
  - force_try # (6)
  ...

included:
  - Sources
  - Tests
disabled_rules:
  - trailing_semicolon # (48) Correctable (you can use `swiftlint autocorrect` to fix)
  - redundant_optional_initialization # (13) Correctable (you can use `swiftlint autocorrect` to fix)
  - trailing_newline # (5) Correctable (you can use `swiftlint autocorrect` to fix)
  - statement_position # (28) Correctable (you can use `swiftlint autocorrect` to fix)
  - for_where # (6)
  - weak_delegate # (1)
  - todo # (36)
  ...

included:
  - AwesomeiOS
  - AwesomeiOSTests

excluded:
  - Pods
  - Carthage

Also, you can see the help,

$ linter help
Linter
   help: Display general or command-specific help.
   --included: Paths to include during linting and add to `.swiftlint.yml` as `included:`.
   --excluded: Paths to ignore during linting and add to `.swiftlint.yml` as `excluded:`.

This package is built by PackageBuilder. In addition, I applied Linter to itself.

I hope Linter saves your time:)