Skip to content

Latest commit

 

History

History
51 lines (33 loc) · 1.98 KB

README.md

File metadata and controls

51 lines (33 loc) · 1.98 KB

SwiftLint-DiscoverNewRules

A script to discover and list opt-in rules you have not yet enabled in your SwiftLint config.

How to use

Setup

You need Python 3 installed on your system. The easiest way is probably to install it using homebrew:

brew install python3

but if you want to keep things clean and organised (and if you're using multiple python versions in parallel) I'd recommend looking at pyenv.

Usage

Clone this repository, and run the script by passing your Swift project directory (where the .swiftlint.yml file is) as argument:

./swiftlint_discover.py /path/to/your/swift/project

Only list new SwiftLint rules

If you run this script regularly, you'll notice that it will output the same opt-in rules that you don't want to enable again and again. To prevent that, you can explicitly disable these rules in your .swiftlint.yml, and the script will be smart enough to not propose these rules ever again.

For the script to be able to read your SwiftLint configuration though, you have to install the PyYAML dependency. You can either install it globally or in a virtualenv (recommended):

python3 -m venv $(pwd)/venv
. ./venv/bin/activate
pip install -r requirements.txt # This will install PyYAML

For example, if you don't want to ever enable the opt-in rule explicit_acl, you can add this to your .swiftlint.yml, and it will not be listed as a possible rule to enable by the script:

disabled_rules:
  # The following are opt-in rules that we don't want to enable, but that we're
  # keeping here to be able to know which rules are new to SwiftLint when it
  # is updated:
  - explicit_acl

(I personally like to keep the comment in the example to remember why I have disabled opt-in rules in my config, which does nothing from a SwiftLint point of view).

Contact

Guillaume Algis (@guillaumealgis)