danger-swiftlint 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +50 -0
- data/.ruby-version +1 -0
- data/Changelog.md +9 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +113 -0
- data/Guardfile +21 -0
- data/LICENSE +21 -0
- data/README.md +47 -0
- data/Rakefile +13 -0
- data/danger-swiftlint.gemspec +42 -0
- data/lib/danger_plugin.rb +99 -0
- data/lib/version.rb +3 -0
- data/spec/danger_plugin_spec.rb +73 -0
- data/spec/fixtures/SwiftFile.swift +1 -0
- data/spec/spec_helper.rb +43 -0
- metadata +178 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 9925f1de7a1bd52e14b57072f1f36dd02cf6a160
|
|
4
|
+
data.tar.gz: 12b7f1206f6270366a12ae32ef56036888dc3b47
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cd4b2964885038e94697afda64209f3c06262c7e04a41b2bbe973d3868c33744a8133ef59651ad0ad1c8fb84b2c60f3ac2a5a66a4e7ab652c32be159da8bcb6f
|
|
7
|
+
data.tar.gz: 8dccbeb0c866068476404a50160663bdade0447db54a3384e05ef8559997fac0795f8615faffd51e6f4820d1eb6e866564a0aea9e42c3b80852f84d30a11ed8c
|
data/.gitignore
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
/.config
|
|
4
|
+
/coverage/
|
|
5
|
+
/InstalledFiles
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/spec/examples.txt
|
|
9
|
+
/test/tmp/
|
|
10
|
+
/test/version_tmp/
|
|
11
|
+
/tmp/
|
|
12
|
+
|
|
13
|
+
# Used by dotenv library to load environment variables.
|
|
14
|
+
# .env
|
|
15
|
+
|
|
16
|
+
## Specific to RubyMotion:
|
|
17
|
+
.dat*
|
|
18
|
+
.repl_history
|
|
19
|
+
build/
|
|
20
|
+
*.bridgesupport
|
|
21
|
+
build-iPhoneOS/
|
|
22
|
+
build-iPhoneSimulator/
|
|
23
|
+
|
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
25
|
+
#
|
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
|
29
|
+
#
|
|
30
|
+
# vendor/Pods/
|
|
31
|
+
|
|
32
|
+
## Documentation cache and generated files:
|
|
33
|
+
/.yardoc/
|
|
34
|
+
/_yardoc/
|
|
35
|
+
/doc/
|
|
36
|
+
/rdoc/
|
|
37
|
+
|
|
38
|
+
## Environment normalization:
|
|
39
|
+
/.bundle/
|
|
40
|
+
/vendor/bundle
|
|
41
|
+
/lib/bundler/man/
|
|
42
|
+
|
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
45
|
+
# Gemfile.lock
|
|
46
|
+
# .ruby-version
|
|
47
|
+
# .ruby-gemset
|
|
48
|
+
|
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
50
|
+
.rvmrc
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.0.0-p247
|
data/Changelog.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
danger-swiftlint (0.0.1)
|
|
5
|
+
danger
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.4.0)
|
|
11
|
+
bacon (1.2.0)
|
|
12
|
+
claide (1.0.0)
|
|
13
|
+
coderay (1.1.1)
|
|
14
|
+
colored (1.2)
|
|
15
|
+
cork (0.1.0)
|
|
16
|
+
colored (~> 1.2)
|
|
17
|
+
danger (0.8.3)
|
|
18
|
+
claide (~> 1.0)
|
|
19
|
+
colored (~> 1.2)
|
|
20
|
+
cork (~> 0.1)
|
|
21
|
+
faraday (~> 0)
|
|
22
|
+
git (~> 1)
|
|
23
|
+
octokit (~> 4.2)
|
|
24
|
+
redcarpet (~> 3.3)
|
|
25
|
+
terminal-table (~> 1)
|
|
26
|
+
diff-lcs (1.2.5)
|
|
27
|
+
faraday (0.9.2)
|
|
28
|
+
multipart-post (>= 1.2, < 3)
|
|
29
|
+
ffi (1.9.10)
|
|
30
|
+
formatador (0.2.5)
|
|
31
|
+
git (1.3.0)
|
|
32
|
+
guard (2.14.0)
|
|
33
|
+
formatador (>= 0.2.4)
|
|
34
|
+
listen (>= 2.7, < 4.0)
|
|
35
|
+
lumberjack (~> 1.0)
|
|
36
|
+
nenv (~> 0.1)
|
|
37
|
+
notiffany (~> 0.0)
|
|
38
|
+
pry (>= 0.9.12)
|
|
39
|
+
shellany (~> 0.0)
|
|
40
|
+
thor (>= 0.18.1)
|
|
41
|
+
guard-compat (1.2.1)
|
|
42
|
+
guard-rspec (4.7.2)
|
|
43
|
+
guard (~> 2.1)
|
|
44
|
+
guard-compat (~> 1.1)
|
|
45
|
+
rspec (>= 2.99.0, < 4.0)
|
|
46
|
+
listen (3.0.7)
|
|
47
|
+
rb-fsevent (>= 0.9.3)
|
|
48
|
+
rb-inotify (>= 0.9.7)
|
|
49
|
+
lumberjack (1.0.10)
|
|
50
|
+
metaclass (0.0.4)
|
|
51
|
+
method_source (0.8.2)
|
|
52
|
+
mocha (1.1.0)
|
|
53
|
+
metaclass (~> 0.0.1)
|
|
54
|
+
mocha-on-bacon (0.2.2)
|
|
55
|
+
mocha (>= 0.13.0)
|
|
56
|
+
multipart-post (2.0.0)
|
|
57
|
+
nenv (0.3.0)
|
|
58
|
+
notiffany (0.1.0)
|
|
59
|
+
nenv (~> 0.1)
|
|
60
|
+
shellany (~> 0.0)
|
|
61
|
+
octokit (4.3.0)
|
|
62
|
+
sawyer (~> 0.7.0, >= 0.5.3)
|
|
63
|
+
prettybacon (0.0.2)
|
|
64
|
+
bacon (~> 1.2)
|
|
65
|
+
pry (0.10.3)
|
|
66
|
+
coderay (~> 1.1.0)
|
|
67
|
+
method_source (~> 0.8.1)
|
|
68
|
+
slop (~> 3.4)
|
|
69
|
+
rake (10.5.0)
|
|
70
|
+
rb-fsevent (0.9.7)
|
|
71
|
+
rb-inotify (0.9.7)
|
|
72
|
+
ffi (>= 0.5.0)
|
|
73
|
+
redcarpet (3.3.4)
|
|
74
|
+
rspec (3.4.0)
|
|
75
|
+
rspec-core (~> 3.4.0)
|
|
76
|
+
rspec-expectations (~> 3.4.0)
|
|
77
|
+
rspec-mocks (~> 3.4.0)
|
|
78
|
+
rspec-core (3.4.4)
|
|
79
|
+
rspec-support (~> 3.4.0)
|
|
80
|
+
rspec-expectations (3.4.0)
|
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
82
|
+
rspec-support (~> 3.4.0)
|
|
83
|
+
rspec-mocks (3.4.1)
|
|
84
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
85
|
+
rspec-support (~> 3.4.0)
|
|
86
|
+
rspec-support (3.4.1)
|
|
87
|
+
sawyer (0.7.0)
|
|
88
|
+
addressable (>= 2.3.5, < 2.5)
|
|
89
|
+
faraday (~> 0.8, < 0.10)
|
|
90
|
+
shellany (0.0.1)
|
|
91
|
+
slop (3.6.0)
|
|
92
|
+
terminal-table (1.6.0)
|
|
93
|
+
thor (0.19.1)
|
|
94
|
+
|
|
95
|
+
PLATFORMS
|
|
96
|
+
ruby
|
|
97
|
+
|
|
98
|
+
DEPENDENCIES
|
|
99
|
+
bacon
|
|
100
|
+
bundler (~> 1.3)
|
|
101
|
+
danger-swiftlint!
|
|
102
|
+
guard (~> 2.14)
|
|
103
|
+
guard-rspec (~> 4.7)
|
|
104
|
+
listen (= 3.0.7)
|
|
105
|
+
mocha
|
|
106
|
+
mocha-on-bacon
|
|
107
|
+
prettybacon
|
|
108
|
+
pry
|
|
109
|
+
rake (~> 10.0)
|
|
110
|
+
rspec (~> 3.4)
|
|
111
|
+
|
|
112
|
+
BUNDLED WITH
|
|
113
|
+
1.12.5
|
data/Guardfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# A guardfile for making Danger Plugins
|
|
2
|
+
# For more info see https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
# To run, use `bundle exec guard`.
|
|
5
|
+
|
|
6
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
|
7
|
+
require "guard/rspec/dsl"
|
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
9
|
+
|
|
10
|
+
# Feel free to open issues for suggestions and improvements
|
|
11
|
+
|
|
12
|
+
# RSpec files
|
|
13
|
+
rspec = dsl.rspec
|
|
14
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
15
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
16
|
+
watch(rspec.spec_files)
|
|
17
|
+
|
|
18
|
+
# Ruby files
|
|
19
|
+
ruby = dsl.ruby
|
|
20
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
21
|
+
end
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Ash Furrow
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[](https://circleci.com/gh/ashfurrow/danger-swiftlint)
|
|
2
|
+
|
|
3
|
+
# Danger SwiftLint
|
|
4
|
+
|
|
5
|
+
A [Danger](https://github.com/danger/danger) plugin for [SwiftLint](https://github.com/realm/SwiftLint).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your Gemfile:
|
|
10
|
+
|
|
11
|
+
```rb
|
|
12
|
+
gem 'danger-swiftlint'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
The easiest way to use is just add this to your Dangerfile:
|
|
18
|
+
|
|
19
|
+
```rb
|
|
20
|
+
swiftlint.lint_files
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
That will lint any changed or added Swift files in the PR. You can also set up a config file first.
|
|
24
|
+
|
|
25
|
+
```rb
|
|
26
|
+
swiftlint.config_file = '.swiftlint.yml'
|
|
27
|
+
swiftlint.lint_files
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
And finally, you can provide a list of files manually:
|
|
31
|
+
|
|
32
|
+
``` ruby
|
|
33
|
+
# Look through all changed Markdown files
|
|
34
|
+
swift_files = (modified_files + added_files).select do |file|
|
|
35
|
+
file.end_with?(".swift")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
swiftlint.lint_files swift_files
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Attribution
|
|
42
|
+
|
|
43
|
+
Original structure, sequence, and organization of repo taken from [danger-prose](https://github.com/dbgrandi/danger-prose) by [David Grandinetti](https://github.com/dbgrandi/).
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
data/Rakefile
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'danger-swiftlint'
|
|
8
|
+
spec.version = DangerSwiftlint::VERSION
|
|
9
|
+
spec.authors = ['Ash Furrow', 'David Grandinetti', 'Orta Therox']
|
|
10
|
+
spec.email = ['ash@ashfurrow.com', 'dbgrandi@gmail.com', 'orta.therox@gmail.com']
|
|
11
|
+
spec.description = %q{A Danger plugin for linting Swift with SwiftLint.}
|
|
12
|
+
spec.summary = %q{A Danger plugin for linting Swift with SwiftLint.}
|
|
13
|
+
spec.homepage = 'https://github.com/ashfurrow/danger-swiftlint'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
spec.require_paths = ['lib']
|
|
19
|
+
|
|
20
|
+
spec.add_dependency 'danger'
|
|
21
|
+
|
|
22
|
+
# General ruby development
|
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
25
|
+
|
|
26
|
+
# Testing support
|
|
27
|
+
spec.add_development_dependency "rspec", '~> 3.4'
|
|
28
|
+
|
|
29
|
+
# Makes testing easy via `bundle exec guard`
|
|
30
|
+
spec.add_development_dependency "guard", '~> 2.14'
|
|
31
|
+
spec.add_development_dependency "guard-rspec", '~> 4.7'
|
|
32
|
+
|
|
33
|
+
# If you want to work on older builds of ruby
|
|
34
|
+
spec.add_development_dependency "listen", '3.0.7'
|
|
35
|
+
|
|
36
|
+
# This gives you the chance to run a REPL inside your test
|
|
37
|
+
# via
|
|
38
|
+
# binding.pry
|
|
39
|
+
# This will stop test execution and let you inspect the results
|
|
40
|
+
spec.add_development_dependency "pry"
|
|
41
|
+
|
|
42
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
module Danger
|
|
2
|
+
|
|
3
|
+
# Lint Swift files inside your projects.
|
|
4
|
+
# This is done using the [SwiftLint](https://github.com/realm/SwiftLint) tool.
|
|
5
|
+
# Results are passed out as a table in markdown.
|
|
6
|
+
#
|
|
7
|
+
# @example Specifying custom config file.
|
|
8
|
+
#
|
|
9
|
+
# # Runs a linter with comma style disabled
|
|
10
|
+
# swiftlint.config_file = '.swiftlint.yml'
|
|
11
|
+
# swiftlint.lint_files
|
|
12
|
+
#
|
|
13
|
+
# @see artsy/eigen
|
|
14
|
+
# @tags swift
|
|
15
|
+
#
|
|
16
|
+
class DangerSwiftlint < Plugin
|
|
17
|
+
|
|
18
|
+
# Allows you to specify a config file location for swiftlint.
|
|
19
|
+
attr_accessor :config_file
|
|
20
|
+
|
|
21
|
+
# Lints Swift files. Will fail if `swiftlint` cannot be installed correctly.
|
|
22
|
+
# Generates a `markdown` list of warnings for the prose in a corpus of .markdown and .md files.
|
|
23
|
+
#
|
|
24
|
+
# @param [String] files
|
|
25
|
+
# A globbed string which should return the files that you want to lint, defaults to nil.
|
|
26
|
+
# if nil, modified and added files from the diff will be used.
|
|
27
|
+
# @return [void]
|
|
28
|
+
#
|
|
29
|
+
def lint_files(files=nil)
|
|
30
|
+
# Installs SwiftLint if needed
|
|
31
|
+
system "brew install swiftlint" unless swiftlint_installed?
|
|
32
|
+
|
|
33
|
+
# Check that this is in the user's PATH after installing
|
|
34
|
+
unless swiftlint_installed?
|
|
35
|
+
fail "swiftlint is not in the user's PATH, or it failed to install"
|
|
36
|
+
return
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Either use files provided, or use the modified + added
|
|
40
|
+
swift_files = files ? Dir.glob(files) : (modified_files + added_files)
|
|
41
|
+
swift_files.select! do |line| line.end_with?(".swift") end
|
|
42
|
+
|
|
43
|
+
swiftlint_command = "swiftlint lint --quiet --reporter json"
|
|
44
|
+
swiftlint_command += " --config #{config_file}" if config_file
|
|
45
|
+
|
|
46
|
+
require 'json'
|
|
47
|
+
result_json = swift_files.uniq.collect { |f| JSON.parse(`#{swiftlint_command} --path #{f}`.strip).flatten }.flatten
|
|
48
|
+
|
|
49
|
+
# Convert to swiftlint results
|
|
50
|
+
warnings = result_json.flatten.select do |results|
|
|
51
|
+
results['severity'] == 'Warning'
|
|
52
|
+
end
|
|
53
|
+
errors = result_json.select do |results|
|
|
54
|
+
results['severity'] == 'Error'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
message = ''
|
|
58
|
+
|
|
59
|
+
# We got some error reports back from swiftlint
|
|
60
|
+
if warnings.count > 0 || errors.count > 0
|
|
61
|
+
message = '### SwiftLint found issues\n\n'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
message << parse_results(warnings, 'Warnings') unless warnings.empty?
|
|
65
|
+
message << parse_results(errors, 'Errors') unless errors.empty?
|
|
66
|
+
|
|
67
|
+
markdown message
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Parses swiftlint invocation results into a string
|
|
71
|
+
# which is formatted as a markdown table.
|
|
72
|
+
#
|
|
73
|
+
# @return [String]
|
|
74
|
+
#
|
|
75
|
+
def parse_results (results, heading)
|
|
76
|
+
message = "#### #{heading}\n\n"
|
|
77
|
+
|
|
78
|
+
message << 'File | Line | Reason |\n'
|
|
79
|
+
message << '| --- | ----- | ----- |\n'
|
|
80
|
+
|
|
81
|
+
results.each do |r|
|
|
82
|
+
filename = r['file'].split('/').last
|
|
83
|
+
line = r['line']
|
|
84
|
+
reason = r['reason']
|
|
85
|
+
|
|
86
|
+
message << "#{filename} | #{line} | #{reason} \n"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
message
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Determine if swiftlint is currently installed in the system paths.
|
|
93
|
+
# @return [Bool]
|
|
94
|
+
#
|
|
95
|
+
def swiftlint_installed?
|
|
96
|
+
`which swiftlint`.strip.empty? == false
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
data/lib/version.rb
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
module Danger
|
|
4
|
+
describe DangerSwiftlint do
|
|
5
|
+
it 'is a plugin' do
|
|
6
|
+
expect(Danger::DangerSwiftlint < Danger::Plugin).to be_truthy
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe 'with Dangerfile' do
|
|
10
|
+
before do
|
|
11
|
+
@dangerfile = testing_dangerfile
|
|
12
|
+
@swiftlint = testing_dangerfile.swiftlint
|
|
13
|
+
|
|
14
|
+
@swiftlint.config_file = nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "handles swiftlint not being installed" do
|
|
18
|
+
allow(@swiftlint).to receive(:`).with("which swiftlint").and_return("")
|
|
19
|
+
expect(@swiftlint.swiftlint_installed?).to be_falsy
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "handles swiftlint being installed" do
|
|
23
|
+
allow(@swiftlint).to receive(:`).with("which swiftlint").and_return("/bin/wherever/swiftlint")
|
|
24
|
+
expect(@swiftlint.swiftlint_installed?).to be_truthy
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe :lint_files do
|
|
28
|
+
before do
|
|
29
|
+
# So it doesn't try to install on your computer
|
|
30
|
+
allow(@swiftlint).to receive(:`).with("which swiftlint").and_return("/bin/wheverever/swiftlint")
|
|
31
|
+
|
|
32
|
+
# Set up our stubbed JSON response
|
|
33
|
+
@swiftlint_response = '[{"reason": "Force casts should be avoided.", "file": "/User/me/this_repo/spec/fixtures/SwiftFile.swift", "line": 13, "severity": "Error" }]'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'handles a known SwiftLint report' do
|
|
37
|
+
allow(@swiftlint).to receive(:`).with('swiftlint lint --quiet --reporter json --path spec/fixtures/SwiftFile.swift').and_return(@swiftlint_response)
|
|
38
|
+
|
|
39
|
+
# Do it
|
|
40
|
+
@swiftlint.lint_files("spec/fixtures/*.swift")
|
|
41
|
+
|
|
42
|
+
output = @swiftlint.status_report[:markdowns].first
|
|
43
|
+
|
|
44
|
+
expect(output).to_not be_empty
|
|
45
|
+
|
|
46
|
+
# A title
|
|
47
|
+
expect(output).to include("SwiftLint found issues")
|
|
48
|
+
# A warning
|
|
49
|
+
expect(output).to include("SwiftFile.swift | 13 | Force casts should be avoided.")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'handles no files' do
|
|
53
|
+
allow(@swiftlint).to receive(:modified_files).and_return('spec/fixtures/SwiftFile.swift')
|
|
54
|
+
allow(@swiftlint).to receive(:`).with('swiftlint lint --quiet --reporter json --path spec/fixtures/SwiftFile.swift').and_return(@swiftlint_response)
|
|
55
|
+
|
|
56
|
+
@swiftlint.lint_files("spec/fixtures/*.swift")
|
|
57
|
+
|
|
58
|
+
expect(@swiftlint.status_report[:markdowns].first).to_not be_empty
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'uses a config file' do
|
|
62
|
+
@swiftlint.config_file = 'some_config.yml'
|
|
63
|
+
allow(@swiftlint).to receive(:`).with('swiftlint lint --quiet --reporter json --config some_config.yml --path spec/fixtures/SwiftFile.swift').and_return(@swiftlint_response)
|
|
64
|
+
|
|
65
|
+
@swiftlint.lint_files("spec/fixtures/*.swift")
|
|
66
|
+
|
|
67
|
+
expect(@swiftlint.status_report[:markdowns].first).to_not be_empty
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// This file intentional left blank-ish.
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
3
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
|
4
|
+
$:.unshift((ROOT + 'lib').to_s)
|
|
5
|
+
$:.unshift((ROOT + 'spec').to_s)
|
|
6
|
+
|
|
7
|
+
RSpec.configure do |config|
|
|
8
|
+
# Use color in STDOUT
|
|
9
|
+
config.color = true
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require 'bundler/setup'
|
|
13
|
+
require 'pry'
|
|
14
|
+
|
|
15
|
+
require 'danger'
|
|
16
|
+
require 'cork'
|
|
17
|
+
require 'danger_plugin'
|
|
18
|
+
|
|
19
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
|
20
|
+
# If you are expanding these files, see if it's already been done ^.
|
|
21
|
+
|
|
22
|
+
# A silent version of the user interface
|
|
23
|
+
def testing_ui
|
|
24
|
+
Cork::Board.new(silent: true)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Example environment (ENV) that would come from
|
|
28
|
+
# running a PR on TravisCI
|
|
29
|
+
def testing_env
|
|
30
|
+
{
|
|
31
|
+
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
|
|
32
|
+
"TRAVIS_PULL_REQUEST" => "800",
|
|
33
|
+
"TRAVIS_REPO_SLUG" => "artsy/eigen",
|
|
34
|
+
"TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
|
|
35
|
+
"DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# A stubbed out Dangerfile for use in tests
|
|
40
|
+
def testing_dangerfile
|
|
41
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
|
42
|
+
Danger::Dangerfile.new(env, testing_ui)
|
|
43
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: danger-swiftlint
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ash Furrow
|
|
8
|
+
- David Grandinetti
|
|
9
|
+
- Orta Therox
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: bin
|
|
12
|
+
cert_chain: []
|
|
13
|
+
date: 2016-07-05 00:00:00.000000000 Z
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: danger
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
|
+
requirements:
|
|
19
|
+
- - '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - '>='
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '0'
|
|
29
|
+
- !ruby/object:Gem::Dependency
|
|
30
|
+
name: bundler
|
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ~>
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '1.3'
|
|
36
|
+
type: :development
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ~>
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '1.3'
|
|
43
|
+
- !ruby/object:Gem::Dependency
|
|
44
|
+
name: rake
|
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ~>
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '10.0'
|
|
50
|
+
type: :development
|
|
51
|
+
prerelease: false
|
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ~>
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '10.0'
|
|
57
|
+
- !ruby/object:Gem::Dependency
|
|
58
|
+
name: rspec
|
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ~>
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '3.4'
|
|
64
|
+
type: :development
|
|
65
|
+
prerelease: false
|
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ~>
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: '3.4'
|
|
71
|
+
- !ruby/object:Gem::Dependency
|
|
72
|
+
name: guard
|
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
|
74
|
+
requirements:
|
|
75
|
+
- - ~>
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '2.14'
|
|
78
|
+
type: :development
|
|
79
|
+
prerelease: false
|
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
81
|
+
requirements:
|
|
82
|
+
- - ~>
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: '2.14'
|
|
85
|
+
- !ruby/object:Gem::Dependency
|
|
86
|
+
name: guard-rspec
|
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ~>
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '4.7'
|
|
92
|
+
type: :development
|
|
93
|
+
prerelease: false
|
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ~>
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '4.7'
|
|
99
|
+
- !ruby/object:Gem::Dependency
|
|
100
|
+
name: listen
|
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
|
102
|
+
requirements:
|
|
103
|
+
- - '='
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: 3.0.7
|
|
106
|
+
type: :development
|
|
107
|
+
prerelease: false
|
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
109
|
+
requirements:
|
|
110
|
+
- - '='
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: 3.0.7
|
|
113
|
+
- !ruby/object:Gem::Dependency
|
|
114
|
+
name: pry
|
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - '>='
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '0'
|
|
120
|
+
type: :development
|
|
121
|
+
prerelease: false
|
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
123
|
+
requirements:
|
|
124
|
+
- - '>='
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: '0'
|
|
127
|
+
description: A Danger plugin for linting Swift with SwiftLint.
|
|
128
|
+
email:
|
|
129
|
+
- ash@ashfurrow.com
|
|
130
|
+
- dbgrandi@gmail.com
|
|
131
|
+
- orta.therox@gmail.com
|
|
132
|
+
executables: []
|
|
133
|
+
extensions: []
|
|
134
|
+
extra_rdoc_files: []
|
|
135
|
+
files:
|
|
136
|
+
- .gitignore
|
|
137
|
+
- .ruby-version
|
|
138
|
+
- Changelog.md
|
|
139
|
+
- Gemfile
|
|
140
|
+
- Gemfile.lock
|
|
141
|
+
- Guardfile
|
|
142
|
+
- LICENSE
|
|
143
|
+
- README.md
|
|
144
|
+
- Rakefile
|
|
145
|
+
- danger-swiftlint.gemspec
|
|
146
|
+
- lib/danger_plugin.rb
|
|
147
|
+
- lib/version.rb
|
|
148
|
+
- spec/danger_plugin_spec.rb
|
|
149
|
+
- spec/fixtures/SwiftFile.swift
|
|
150
|
+
- spec/spec_helper.rb
|
|
151
|
+
homepage: https://github.com/ashfurrow/danger-swiftlint
|
|
152
|
+
licenses:
|
|
153
|
+
- MIT
|
|
154
|
+
metadata: {}
|
|
155
|
+
post_install_message:
|
|
156
|
+
rdoc_options: []
|
|
157
|
+
require_paths:
|
|
158
|
+
- lib
|
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
|
+
requirements:
|
|
161
|
+
- - '>='
|
|
162
|
+
- !ruby/object:Gem::Version
|
|
163
|
+
version: '0'
|
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
|
+
requirements:
|
|
166
|
+
- - '>='
|
|
167
|
+
- !ruby/object:Gem::Version
|
|
168
|
+
version: '0'
|
|
169
|
+
requirements: []
|
|
170
|
+
rubyforge_project:
|
|
171
|
+
rubygems_version: 2.0.14.1
|
|
172
|
+
signing_key:
|
|
173
|
+
specification_version: 4
|
|
174
|
+
summary: A Danger plugin for linting Swift with SwiftLint.
|
|
175
|
+
test_files:
|
|
176
|
+
- spec/danger_plugin_spec.rb
|
|
177
|
+
- spec/fixtures/SwiftFile.swift
|
|
178
|
+
- spec/spec_helper.rb
|