• Stars
    star
    203
  • Rank 192,890 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Danger plugin for SwiftLint.

Danger SwiftLint Build Status

A Danger Ruby plugin for SwiftLint that runs on macOS.

Installation

Add this line to your Gemfile:

gem 'danger-swiftlint'

SwiftLint also needs to be installed before you run Danger, which you can do via Homebrew or a Brewfile. On CI, this is done for you when the gem is installed.

Usage

The easiest way to use is just add this to your Dangerfile:

swiftlint.lint_files

By default danger-swiftlint will lint added and modified files.

swiftlint.config_file = '.swiftlint.yml'
swiftlint.binary_path = '/path/to/swiftlint'
swiftlint.max_num_violations = 20
swiftlint.lint_files

If you want the lint result shows in diff instead of comment, you can use inline_mode option. Violations that out of the diff will show in danger's fail or warn section.

swiftlint.lint_files inline_mode: true

If you want different configurations on different directories, you can specify the directory. Note: Run swiftlint.lint_files per specified directory then.

swiftlint.directory = "Directory A"

If you want lint errors to fail Danger, you can use fail_on_error option.

swiftlint.lint_files fail_on_error: true

If you need to specify options for swiftlint that can only be specified by command line arguments, use the additional_swiftlint_args option.

swiftlint.lint_files additional_swiftlint_args: '--lenient'

By default, only files that were added or modified are linted.

It's not possible to use nested configurations in that case, because Danger SwiftLint lints each file on it's own, and by doing that the nested configuration is disabled. If you want to learn more details about this, read the whole issue here.

However, you can use the lint_all_files option to lint all the files. In that case, Danger SwiftLint doesn't lint files individually, which makes nested configuration to work. It'd be the same as you were running swiftlint on the root folder:

swiftlint.lint_all_files = true
swiftlint.lint_files

It's also possible to pass a block to filter out any violations after swiftlint has been run. Here's an example filtering out all violations that didn't occur in the current github PR, using the third party gem git_diff_parser:

require 'git_diff_parser'

diff = GitDiffParser::Patches.parse(github.pr_diff)
dir = "#{Dir.pwd}/"
swiftlint.lint_files(inline_mode: true) { |violation|
  diff_filename = violation['file'].gsub(dir, '')
  file_patch = diff.find_patch_by_file(diff_filename)
  file_patch != nil && file_patch.changed_lines.any? { |line| line.number == violation['line']}
}

Or, by passing the no_comment parameter, you can completely manage the commenting of issues, warnings and errors yourself. An example usage might be using GitHub reviews, or custom filtering logic. Note: When this parameter is set to true, all other parameters except files and additional_swiftlint_args are ignored.

swiftlint.lint_files(no_comment: true)

# Now, you can handle the combined warnings + errors, or each separately commenting
swiftlint.issues    # contains combined warnings + errors
swiftlint.warnings  # just warnings
swiftlint.errors    # just errors

You can use the SWIFTLINT_VERSION environment variable to override the default version installed via the rake install task.

Or, if you are behind a proxy or using a package manager which does not allow you to go to github.com directly, you can manually download the SwiftLint package and skip the installation by setting the DANGER_SKIP_SWIFTLINT_INSTALL environment variable equal to YES.

next if ENV['DANGER_SKIP_SWIFTLINT_INSTALL'] == 'YES'

Finally, if something's not working correctly, you can debug this plugin by using setting swiftlint.verbose = true.

Attribution

Original structure, sequence, and organization of repo taken from danger-prose by David Grandinetti.

License

MIT

More Repositories

1

C-41

C-41 is an application to help people develop film at home by providing a series of "recipes" for photographers to use.
Objective-C
2,059
star
2

xcode-hardware-performance

Results from running Xcode on a non-trivial open source project using various Macs
1,134
star
3

FunctionalReactivePixels

A demonstration of how to use FRP with ReactiveCocoa in an iOS context using the 500px API.
Objective-C
702
star
4

AFTabledCollectionView

How to display a UICollectionView within a UITableViewCell
Objective-C
549
star
5

UICollectionView-NSFetchedResultsController

How to use UICollectionView with NSFetchedResultsController
439
star
6

Collection-View-in-a-Table-View-Cell

Sample code for my tutorial
Swift
393
star
7

Nimble-Snapshots

Nimble matchers for FBSnapshotTestCase.
Swift
317
star
8

UICollectionViewFlowLayoutExample

UICollectionViewFlowLayout Example
Objective-C
198
star
9

ARCollectionViewMasonryLayout

Objective-C
184
star
10

danger-swiftlint

Automated Swift linting on pull requests
Swift
149
star
11

ASHSpringyCollectionView

Objective-C
140
star
12

second_curtain

Upload failing iOS snapshot tests cases to S3
Objective-C
130
star
13

blog

This is my website, a static site generated with Gatsby.
MDX
112
star
14

UICollectionViewExample

Objective-C
100
star
15

LongPlay

Long Play
Objective-C
93
star
16

AFImageDownloader

Downloads JPEG images asynchronously and decompresses them on a background thread.
Objective-C
88
star
17

Forgeries

Helper methods for testing iOS code
Objective-C
83
star
18

yourfirstswiftapp

Swift
66
star
19

FunctionalReactiveAwesome

Sample Code for AltConf 2015 talk on FRP 🎉
Swift
57
star
20

NSFetchedResultsController-MVVM

NSFetchedResultsController using MVVM
Objective-C
55
star
21

Swift-RAC-Macros

(Temporary) Replacements for the RAC and RACObserve macros in Swift
Swift
54
star
22

UIView-BooleanAnimations

Perform changes to UI with or without animations, depending on a variable.
Objective-C
47
star
23

danger-rubocop

Danger plugin for Rubocop
Ruby
43
star
24

peerlab.community

Worldwide directory of peer labs, instructions on starting your own.
HTML
43
star
25

DOOM-CPU-Monitor

CPU monitor that displays how much load your CPU is under via the dying face from the video game DOOM.
Objective-C
42
star
26

Newtonian-UICollectionView

Objective-C
40
star
27

pragma-2015-rx-workshop

Materials for my Pragma 2015 workshop on reactive programming
Swift
37
star
28

Your-First-iOS-App

Sample code for "Your First iOS App", the book
Objective-C
35
star
29

Angular

Making an Othello/Reversi clone
Objective-C
34
star
30

NSSpain2014

Annotated playground for my presentation at NSSpain 2014
Swift
32
star
31

MBLTDev

Sample code for MBLTDev
Swift
31
star
32

Bleach

iOS 9 app extension to block ads
27
star
33

Swift-Course

A small demo of Swift for newcomers
Swift
26
star
34

AFActivityIndicatorView

A ground-up, home-made implementation of UIActivityIndicatorView
Objective-C
24
star
35

PXSaver

Super hacky screen saver for OS X I wrote in a few hours while drinking
Objective-C
23
star
36

FunctionalReactiveDemo

A small demonstration of how to use ReactiveCocoa in iOS applications
Objective-C
23
star
37

ReactiveMoya

Swift
22
star
38

UIAlertController-Example

A demonstration of how to use Apple's hot new UIAlertController class
Swift
20
star
39

500px-API-Test

500px recently opened their API to the public. I want to try it out.
19
star
40

Haste

NSTimer Extension for Swift
Swift
18
star
41

twelease

🗣 A small Express server for automatically tweeting about new git tags
TypeScript
18
star
42

cocoapods-superdeintegrate

💣
Ruby
16
star
43

WhiskeyList

Objective-C
15
star
44

cocoapods-chillax-swift

CocoaPods plugin for disabling compiler optimizations for specific pods
Ruby
13
star
45

RACAlertAction

UIAlertAction subclass with support for ReactiveCocoa
Objective-C
13
star
46

hasValue

Reimplementing hasValue in Swift.
Ruby
11
star
47

UIView-ShinkTo

Shrinks any UIView instance to a point in a view similar to the iOS Mail app
Objective-C
11
star
48

FoundationOperators

Operators overloading for the Foundation (so we can finally just nsnumber + nsnumber)
Swift
10
star
49

canadian-measurements

Since moving to Europe, I get asked a lot about Canada's adoption of the metric system. Here it is.
9
star
50

production-swift-code

Sample code for my upcoming book
8
star
51

stylesheet

My custom user stylesheet for making the web less shitty.
CSS
7
star
52

EuroTrip-2015

We'll be in Europe for most of May. This repo is used to organize our travel plans.
7
star
53

cornell-rx-materials

Swift
6
star
54

category-theory-exercises

Swift
6
star
55

buggy

A Slackbot that makes it easy to organize bug bashes
Ruby
6
star
56

UIApplication-Keychain-Access

This is a library to abstract access to the keychain on iOS devices.
5
star
57

graphql-depth-limit

Limit the complexity of your GraphQL queries based on depth.
JavaScript
5
star
58

trumpsoundboard

HTML
4
star
59

Simple-OAuth

Simple Objective-C OAuth
Objective-C
4
star
60

FunctionalDemo

A short demo of functional programming on iOS using RXCollections
Objective-C
4
star
61

tsnyc-tslint-rules

Materials for my October 30th talk at TypeScript NYC
TypeScript
3
star
62

task-list-checker

JavaScript
3
star
63

pride.watch

I'm going to make a gallery of Apple Watch watch faces that are pride flags ¯\_(ツ)_/¯
HTML
3
star
64

peril-settings

Settings for my personal Peril server
TypeScript
2
star
65

static-keys-test

Objective-C
2
star
66

screensaver

JavaScript
2
star
67

FITC-SCREENS

Demo repo for FITC SCREENS
2
star
68

test-repo

test repo for twelease
2
star
69

500px-Behind-The-Scenes

Source Materials for the 500px Behind The Scenes FITC Screens Presentation
2
star
70

ashfurrow

This is the readme repo for my GitHub profile.
2
star
71

ScienceDog

A simple Haskell web app written using the Happstack-lite web framework
1
star
72

mastodon-technology

Ruby
1
star
73

hfm-exercises

My solutions to the Haskell-for-Mac Exercises
Haskell
1
star
74

TumblrSharing

Simple sharing to Tumblr's v2 OAuth API
Objective-C
1
star
75

colourschemes

Some Xcode 4+ colour schemes I like
1
star
76

minsk

Code from Mobile Developer & Business Day
Swift
1
star
77

tslint-playground

A playground repo for me to experiment with writing custom TSLint rules
TypeScript
1
star
78

AnyoneCanLearn

Core beliefs, resources, and planning for the organization.
1
star
79

empty-podspec

Repo for an empty, modifiable podspec. Pay this repo no attention.
Ruby
1
star
80

ios-13-uiimage-crash

Objective-C
1
star