Swiftpack.co - Package - ashfurrow/danger-swiftlint

CircleCI

Danger SwiftLint

Danger Swift plugin for SwiftLint. So you can get SwiftLint warnings on your pull requests!

(Note: If you're looking for the Ruby version of this Danger plugin, it has been moved here.)

Usage

Install and run Danger Swift as normal and install SwiftLint in your CI's config file. Something like:

dependencies:
  override:
  - npm install -g danger # This installs Danger
  - brew install danger/tap/danger-swift # This installs Danger-Swift
  - brew install swiftlint # This is for the Danger SwiftLint plugin.

Then use the following Dangerfile.swift.

// Dangerfile.swift

import Danger
import DangerSwiftLint // package: https://github.com/danger/DangerSwiftLint.git

SwiftLint.lint()

That will lint the created and modified files

Contributing

If you find a bug, please open an issue! Or a pull request :wink:

No, seriously.

This is the first command line Swift I've ever written, and it's the first Danger Swift plugin anyone has ever written, so if something doesn't work, I could really use your help figuring out the problem.

A good place to start is writing a failing unit test. Then you can try to fix the bug. First, you'll need to fork the repo and clone your fork locally. Build it and run the unit tests.

git clone https://github.com/YOUR_USERNAME/danger-swiftlint.git
cd danger-swiftlint
swift build
swift test

Alright, verify that everything so far works before going further. To write your tests and modify the plugin files, run swift package generate-xcodeproj. Open the generated Xcode project and enjoy the modernities of code autocomplete and inline documentation. You can even run the unit tests from Xcode (sometimes results are inconsistent with running swift test).

One place that unit tests have a hard time covering is the integration with the swiftlint command line tool. If you're changing code there, open a pull request (like this one) to test everything works.

Customizing

There are tonnes of ways this plugin can be customized for individual use cases. After building the Ruby version of this plugin, I realized that it's really difficult to scale up a tool that works for everyone. So instead, I'm treating this project as a template, that you to do fork and customize however you like!

  1. Fork this project.
  2. Change the import DangerSwiftLint package URL to point to your fork.
  3. After making your changes to the plugin, push them to your fork and push a new tag.

Because you need to tag a new version, testing your plugin can be tricky. I've built some basic unit tests, so you should be able to use test-driven development for most of your changes.

If you think you've got a real general-purpose feature that most users of this plugin would benefit from, I would be grateful for a pull request.

License

#MIT4Lyfe

A Fun GIF

Your feeling when you lint your swift code

Github

link
Stars: 36
Help us keep the lights on

Dependencies

Used By

Total: 1