danger-tailor 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +50 -0
- data/.rubocop.yml +88 -0
- data/.travis.yml +20 -0
- data/Gemfile +4 -0
- data/Guardfile +19 -0
- data/LICENSE +21 -0
- data/README.md +44 -0
- data/Rakefile +23 -0
- data/danger-tailor.gemspec +54 -0
- data/lib/danger_plugin.rb +1 -0
- data/lib/danger_tailor.rb +1 -0
- data/lib/tailor/gem_version.rb +3 -0
- data/lib/tailor/plugin.rb +109 -0
- data/spec/errors.json +72 -0
- data/spec/spec_helper.rb +62 -0
- data/spec/tailor_spec.rb +51 -0
- data/spec/warnings.json +72 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9c0e6bfe3b9a7eb0aafc22072522a0bb94e4af1d
|
4
|
+
data.tar.gz: ab8cfa9ad133c6b8e290e70c3a8cf7b0cce866e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22ee21b73c90d6241eb73f7b77f13ec0c8f310a6cd9c52cd087140320557d19697c266faa066661d42a3e8389ac7da31d614dd909bfcd0e672e3127d656b93cc
|
7
|
+
data.tar.gz: 7ff16795162a60d6d16406ffb5fcc82f9d6ff673d080d871d1039d518c37c0bff873fad8d129734b767a23340dcee9caa0f14cadc47ba831dfd627424e562084
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
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/.rubocop.yml
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# kind_of? is a good way to check a type
|
2
|
+
Style/ClassCheck:
|
3
|
+
EnforcedStyle: kind_of?
|
4
|
+
|
5
|
+
# It's better to be more explicit about the type
|
6
|
+
Style/BracesAroundHashParameters:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
# specs sometimes have useless assignments, which is fine
|
10
|
+
Lint/UselessAssignment:
|
11
|
+
Exclude:
|
12
|
+
- '**/spec/**/*'
|
13
|
+
|
14
|
+
# HoundCI doesn't like this rule
|
15
|
+
Style/DotPosition:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
Lint/UnusedBlockArgument:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
# We want to allow class Fastlane::Class
|
23
|
+
Style/ClassAndModuleChildren:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Metrics/AbcSize:
|
27
|
+
Max: 60
|
28
|
+
|
29
|
+
# The %w might be confusing for new users
|
30
|
+
Style/WordArray:
|
31
|
+
MinSize: 19
|
32
|
+
|
33
|
+
# raise and fail are both okay
|
34
|
+
Style/SignalException:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
# Better too much 'return' than one missing
|
38
|
+
Style/RedundantReturn:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
# Having if in the same line might not always be good
|
42
|
+
Style/IfUnlessModifier:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
# Configuration parameters: CountComments.
|
46
|
+
Metrics/ClassLength:
|
47
|
+
Max: 320
|
48
|
+
|
49
|
+
Metrics/CyclomaticComplexity:
|
50
|
+
Max: 17
|
51
|
+
|
52
|
+
# Configuration parameters: AllowURI, URISchemes.
|
53
|
+
Metrics/LineLength:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# Configuration parameters: CountKeywordArgs.
|
57
|
+
Metrics/ParameterLists:
|
58
|
+
Max: 10
|
59
|
+
|
60
|
+
Metrics/PerceivedComplexity:
|
61
|
+
Max: 18
|
62
|
+
|
63
|
+
# Sometimes it's easier to read without guards
|
64
|
+
Style/GuardClause:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
# something = if something_else
|
68
|
+
# that's confusing
|
69
|
+
Style/ConditionalAssignment:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
# Better to have too much self than missing a self
|
73
|
+
Style/RedundantSelf:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Metrics/MethodLength:
|
77
|
+
Max: 60
|
78
|
+
|
79
|
+
Metrics/BlockLength:
|
80
|
+
Max: 50
|
81
|
+
|
82
|
+
# We're not there yet
|
83
|
+
Style/Documentation:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
# Adds complexity
|
87
|
+
Style/IfInsideElse:
|
88
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache:
|
3
|
+
directories:
|
4
|
+
- bundle
|
5
|
+
|
6
|
+
before_install:
|
7
|
+
- gem update --system
|
8
|
+
- gem install bundler
|
9
|
+
|
10
|
+
sudo: false
|
11
|
+
|
12
|
+
rvm:
|
13
|
+
- 2.0.0
|
14
|
+
- 2.1.10
|
15
|
+
- 2.2.6
|
16
|
+
- 2.3.3
|
17
|
+
- 2.4.0
|
18
|
+
|
19
|
+
script:
|
20
|
+
- bundle exec rake spec
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,19 @@
|
|
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
|
+
# RSpec files
|
11
|
+
rspec = dsl.rspec
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_files)
|
15
|
+
|
16
|
+
# Ruby files
|
17
|
+
ruby = dsl.ruby
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
19
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Intrepid Pursuits LLC
|
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,44 @@
|
|
1
|
+
# danger-tailor
|
2
|
+
|
3
|
+
![Travis](https://travis-ci.org/IntrepidPursuits/danger-tailor.svg)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/github/IntrepidPursuits/danger-tailor/badge.svg?branch=master)](https://coveralls.io/github/IntrepidPursuits/danger-tailor?branch=master)
|
5
|
+
![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)
|
6
|
+
|
7
|
+
A [Danger](http://danger.systems/) plugin that shows the static analysis output generated by [Tailor](tailor.sh).
|
8
|
+
|
9
|
+
To use this plugin, you need to generate a JSON file using [Tailor](tailor.sh) for this plugin to read.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
$ gem install danger-tailor
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Somewhere in your build process, call tailor using the JSON output flag.
|
18
|
+
|
19
|
+
tailor -f json MyProject/ > tailor.json
|
20
|
+
|
21
|
+
At a minimum, add this line to your `Dangerfile`:
|
22
|
+
|
23
|
+
danger-tailor.report 'tailor.json'
|
24
|
+
|
25
|
+
|
26
|
+
You may also use optional specifiers to ignore files, or set the project root.
|
27
|
+
|
28
|
+
# Ignore Pod warnings
|
29
|
+
danger-tailor.ignored_files = '**/Pods/**'
|
30
|
+
|
31
|
+
# Set a different project root
|
32
|
+
danger-tailor.project_root = 'MyProject/NewRoot/'
|
33
|
+
|
34
|
+
## License
|
35
|
+
danger-tailor is released under the MIT license. See [LICENSE](https://github.com/IntrepidPursuits/danger-tailor/blob/master/LICENSE) for details.
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork this repo
|
40
|
+
2. Run `bundle install` to setup dependencies.
|
41
|
+
3. Run `bundle exec rake spec` to run the tests.
|
42
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
43
|
+
5. Make your changes.
|
44
|
+
6. Create a Pull Request for us to review
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:specs)
|
6
|
+
|
7
|
+
task default: :specs
|
8
|
+
|
9
|
+
task :spec do
|
10
|
+
Rake::Task['specs'].invoke
|
11
|
+
Rake::Task['rubocop'].invoke
|
12
|
+
Rake::Task['spec_docs'].invoke
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run RuboCop on the lib/specs directory'
|
16
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
17
|
+
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Ensure that the plugin passes `danger plugins lint`'
|
21
|
+
task :spec_docs do
|
22
|
+
sh 'bundle exec danger plugins lint'
|
23
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tailor/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'danger-tailor'
|
8
|
+
spec.version = Tailor::VERSION
|
9
|
+
spec.authors = ['Patrick Butkiewicz']
|
10
|
+
spec.email = ['patrick@intrepid.io']
|
11
|
+
spec.description = 'Show formatted static analysis reports in your PRs'
|
12
|
+
spec.summary = 'A [Danger](https://danger.systems) plugin that shows ' \
|
13
|
+
'warnings and errors generated from the Tailor ' \
|
14
|
+
'static analysis tool for the Swift language.'
|
15
|
+
spec.homepage = 'https://github.com/IntrepidPursuits/danger-tailor'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
24
|
+
|
25
|
+
# General ruby development
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
|
29
|
+
# Testing support
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
31
|
+
|
32
|
+
# Linting code and docs
|
33
|
+
spec.add_development_dependency 'rubocop', '~> 0.41'
|
34
|
+
spec.add_development_dependency 'yard', '~> 0.8'
|
35
|
+
|
36
|
+
# Makes testing easy via `bundle exec guard`
|
37
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
38
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
39
|
+
|
40
|
+
# If you want to work on older builds of ruby
|
41
|
+
spec.add_development_dependency 'listen', '3.0.7'
|
42
|
+
|
43
|
+
# Use coveralls
|
44
|
+
spec.add_development_dependency 'coveralls', '0.8.19'
|
45
|
+
|
46
|
+
# This gives you the chance to run a REPL inside your tests
|
47
|
+
# via:
|
48
|
+
#
|
49
|
+
# require 'pry'
|
50
|
+
# binding.pry
|
51
|
+
#
|
52
|
+
# This will stop test execution and let you inspect the results
|
53
|
+
spec.add_development_dependency 'pry'
|
54
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'tailor/plugin'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'tailor/gem_version'
|
@@ -0,0 +1,109 @@
|
|
1
|
+
module Danger
|
2
|
+
# Shows the build errors, warnings and violations generated from Tailor.
|
3
|
+
# You need [Tailor](https://tailor.sh) installed and generating a json file
|
4
|
+
# to use this plugin
|
5
|
+
#
|
6
|
+
# @example Showing summary
|
7
|
+
#
|
8
|
+
# tailor -f json MyProject/ > tailor.json
|
9
|
+
# danger-tailor.report 'tailor.json'
|
10
|
+
#
|
11
|
+
# @example Filter out the pods before analyzing
|
12
|
+
#
|
13
|
+
# danger-tailor.ignored_files = '**/Pods/**'
|
14
|
+
# danger-tailor.report 'tailor.json'
|
15
|
+
#
|
16
|
+
# @see IntrepidPursuits/danger-tailor
|
17
|
+
# @tags xcode, swift, tailor, lint, format, xcodebuild
|
18
|
+
#
|
19
|
+
class DangerTailor < Plugin
|
20
|
+
# The project root, which will be used to make the paths relative.
|
21
|
+
# Defaults to `pwd`.
|
22
|
+
# @return [String] project_root value
|
23
|
+
attr_accessor :project_root
|
24
|
+
|
25
|
+
# A globbed string or array of strings which should match the files
|
26
|
+
# that you want to ignore warnings on. Defaults to nil.
|
27
|
+
# An example would be `'**/Pods/**'` to ignore warnings in Pods that your
|
28
|
+
# project uses.
|
29
|
+
#
|
30
|
+
# @return [[String]] ignored-files
|
31
|
+
attr_accessor :ignored_files
|
32
|
+
|
33
|
+
# Defines if the test summary will be sticky or not.
|
34
|
+
# Defaults to `false`.
|
35
|
+
# @return [Boolean] sticky
|
36
|
+
attr_accessor :sticky_summary
|
37
|
+
|
38
|
+
def project_root
|
39
|
+
root = @project_root || Dir.pwd
|
40
|
+
root += '/' unless root.end_with? '/'
|
41
|
+
root
|
42
|
+
end
|
43
|
+
|
44
|
+
def ignored_files
|
45
|
+
[@ignored_files].flatten.compact
|
46
|
+
end
|
47
|
+
|
48
|
+
def sticky_summary
|
49
|
+
@sticky_summary || false
|
50
|
+
end
|
51
|
+
|
52
|
+
# Reads a file with JSON Xcode summary and reports it.
|
53
|
+
#
|
54
|
+
# @param [String] file_path Path for Tailor summary in JSON format.
|
55
|
+
# @return [void]
|
56
|
+
def report(file_path)
|
57
|
+
raise 'Summary file not found' unless File.file?(file_path)
|
58
|
+
tailor_summary = JSON.parse(File.read(file_path), symbolize_names: true)
|
59
|
+
run_summary(tailor_summary)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def run_summary(tailor_summary)
|
65
|
+
# Output the tailor summary
|
66
|
+
message(summary_message(tailor_summary), sticky: sticky_summary)
|
67
|
+
|
68
|
+
# Parse the file violations
|
69
|
+
parse_files(tailor_summary)
|
70
|
+
end
|
71
|
+
|
72
|
+
def summary_message(tailor_summary)
|
73
|
+
summary = tailor_summary[:summary]
|
74
|
+
m = "Tailor Summary: Analyzed #{summary[:analyzed]} files. Found #{summary[:violations]} violations. #{summary[:warnings]} Warnings and #{summary[:errors]} Errors."
|
75
|
+
m << " Skipped #{summary[:skipped]} files." unless summary[:skipped].zero?
|
76
|
+
m
|
77
|
+
end
|
78
|
+
|
79
|
+
# A method that takes the tailor summary, and for each file, parses out
|
80
|
+
# any violations found.
|
81
|
+
def parse_files(tailor_summary)
|
82
|
+
tailor_summary[:files].each do |f|
|
83
|
+
parse_violations(f[:path], f[:violations])
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# A method that takes a file path, and an array of tailor violation objects,
|
88
|
+
# parses the violation, and calls the appropriate Danger method
|
89
|
+
def parse_violations(file_path, violations)
|
90
|
+
violations.each do |v|
|
91
|
+
severity = v[:severity]
|
92
|
+
message = format_violation(file_path, v)
|
93
|
+
|
94
|
+
if severity == 'warning'
|
95
|
+
warn(message, sticky: false)
|
96
|
+
elsif severity == 'error'
|
97
|
+
fail(message, sticky: false)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# A method that returns a formatted string for a violation
|
103
|
+
# @return String
|
104
|
+
#
|
105
|
+
def format_violation(file_path, violation)
|
106
|
+
"#{file_path}:#L#{violation[:location][:line]} -> #{violation[:rule]} - #{violation[:message]}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/spec/errors.json
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
{
|
2
|
+
"files": [
|
3
|
+
{
|
4
|
+
"path": "/Users/Patrick/Developer/CITest-ios/CITest/AppDelegate.swift",
|
5
|
+
"violations": [
|
6
|
+
{
|
7
|
+
"severity": "error",
|
8
|
+
"rule": "terminating-newline",
|
9
|
+
"location": {
|
10
|
+
"line": 21
|
11
|
+
},
|
12
|
+
"message": "File should terminate with exactly one newline character ('\\n')"
|
13
|
+
}
|
14
|
+
],
|
15
|
+
"parsed": true
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"path": "/Users/Patrick/Developer/CITest-ios/CITest/ViewController.swift",
|
19
|
+
"violations": [
|
20
|
+
{
|
21
|
+
"severity": "error",
|
22
|
+
"rule": "terminating-newline",
|
23
|
+
"location": {
|
24
|
+
"line": 14
|
25
|
+
},
|
26
|
+
"message": "File should terminate with exactly one newline character ('\\n')"
|
27
|
+
}
|
28
|
+
],
|
29
|
+
"parsed": true
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"path": "/Users/Patrick/Developer/CITest-ios/CITest/ViewModel.swift",
|
33
|
+
"violations": [
|
34
|
+
{
|
35
|
+
"severity": "error",
|
36
|
+
"rule": "trailing-whitespace",
|
37
|
+
"location": {
|
38
|
+
"line": 14,
|
39
|
+
"column": 4
|
40
|
+
},
|
41
|
+
"message": "Line should not have any trailing whitespace"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"severity": "error",
|
45
|
+
"rule": "trailing-whitespace",
|
46
|
+
"location": {
|
47
|
+
"line": 18,
|
48
|
+
"column": 4
|
49
|
+
},
|
50
|
+
"message": "Line should not have any trailing whitespace"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"severity": "error",
|
54
|
+
"rule": "function-whitespace",
|
55
|
+
"location": {
|
56
|
+
"line": 21,
|
57
|
+
"column": 6
|
58
|
+
},
|
59
|
+
"message": "Function should have at least one blank line after it"
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"parsed": true
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"summary": {
|
66
|
+
"violations": 5,
|
67
|
+
"warnings": 0,
|
68
|
+
"analyzed": 3,
|
69
|
+
"errors": 5,
|
70
|
+
"skipped": 0
|
71
|
+
}
|
72
|
+
}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
6
|
+
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
|
7
|
+
$LOAD_PATH.unshift((ROOT + 'spec').to_s)
|
8
|
+
|
9
|
+
require 'bundler/setup'
|
10
|
+
require 'pry'
|
11
|
+
|
12
|
+
require 'rspec'
|
13
|
+
require 'danger'
|
14
|
+
|
15
|
+
# Use coloured output, it's the best.
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.filter_gems_from_backtrace 'bundler'
|
18
|
+
config.color = true
|
19
|
+
config.tty = true
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'danger_plugin'
|
23
|
+
|
24
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
25
|
+
# If you are expanding these files, see if it's already been done ^.
|
26
|
+
|
27
|
+
# A silent version of the user interface,
|
28
|
+
# it comes with an extra function `.string` which will
|
29
|
+
# strip all ANSI colours from the string.
|
30
|
+
|
31
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
32
|
+
def testing_ui
|
33
|
+
@output = StringIO.new
|
34
|
+
def @output.winsize
|
35
|
+
[20, 9999]
|
36
|
+
end
|
37
|
+
|
38
|
+
cork = Cork::Board.new(out: @output)
|
39
|
+
def cork.string
|
40
|
+
out.string.gsub(/\e\[([;\d]+)?m/, '')
|
41
|
+
end
|
42
|
+
cork
|
43
|
+
end
|
44
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
45
|
+
|
46
|
+
# Example environment (ENV) that would come from
|
47
|
+
# running a PR on TravisCI
|
48
|
+
def testing_env
|
49
|
+
{
|
50
|
+
'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
|
51
|
+
'TRAVIS_PULL_REQUEST' => '800',
|
52
|
+
'TRAVIS_REPO_SLUG' => 'artsy/eigen',
|
53
|
+
'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
|
54
|
+
'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# A stubbed out Dangerfile for use in tests
|
59
|
+
def testing_dangerfile
|
60
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
61
|
+
Danger::Dangerfile.new(env, testing_ui)
|
62
|
+
end
|
data/spec/tailor_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
describe Danger::DangerTailor do
|
5
|
+
it 'should be a plugin' do
|
6
|
+
expect(Danger::DangerTailor.new(nil)).to be_a Danger::Plugin
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'with Dangerfile' do
|
10
|
+
before do
|
11
|
+
@dangerfile = testing_dangerfile
|
12
|
+
@my_plugin = @dangerfile.tailor
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'Parses JSON with warnings and no errors' do
|
16
|
+
warning_path = File.expand_path('../warnings.json', __FILE__)
|
17
|
+
@my_plugin.report(warning_path)
|
18
|
+
expect(@dangerfile.status_report[:errors]).to eq([])
|
19
|
+
expect(@dangerfile.status_report[:warnings].length).to be == 5
|
20
|
+
expect(@dangerfile.status_report[:markdowns]).to eq([])
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'Displays a summary message for warnings' do
|
24
|
+
warning_path = File.expand_path('../warnings.json', __FILE__)
|
25
|
+
@my_plugin.report(warning_path)
|
26
|
+
# puts @dangerfile.status_report
|
27
|
+
expect(@dangerfile.status_report[:messages]).to eq(['Tailor Summary: Analyzed 3 files. Found 5 violations. 5 Warnings and 0 Errors.'])
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'Displays a properly formatted warning message' do
|
31
|
+
warning_path = File.expand_path('../warnings.json', __FILE__)
|
32
|
+
@my_plugin.report(warning_path)
|
33
|
+
expect(@dangerfile.status_report[:warnings][0]).to eq('/Users/Patrick/Developer/CITest-ios/CITest/AppDelegate.swift:#L21 -> terminating-newline - File should terminate with exactly one newline character (\'\\n\')')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'Parses JSON with errors and no warnings' do
|
37
|
+
error_path = File.expand_path('../errors.json', __FILE__)
|
38
|
+
@my_plugin.report(error_path)
|
39
|
+
expect(@dangerfile.status_report[:errors].length).to be == 5
|
40
|
+
expect(@dangerfile.status_report[:warnings]).to eq([])
|
41
|
+
expect(@dangerfile.status_report[:markdowns]).to eq([])
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'Displays a properly formatted error message' do
|
45
|
+
error_path = File.expand_path('../errors.json', __FILE__)
|
46
|
+
@my_plugin.report(error_path)
|
47
|
+
expect(@dangerfile.status_report[:errors][0]).to eq('/Users/Patrick/Developer/CITest-ios/CITest/AppDelegate.swift:#L21 -> terminating-newline - File should terminate with exactly one newline character (\'\\n\')')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/warnings.json
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
{
|
2
|
+
"files": [
|
3
|
+
{
|
4
|
+
"path": "/Users/Patrick/Developer/CITest-ios/CITest/AppDelegate.swift",
|
5
|
+
"violations": [
|
6
|
+
{
|
7
|
+
"severity": "warning",
|
8
|
+
"rule": "terminating-newline",
|
9
|
+
"location": {
|
10
|
+
"line": 21
|
11
|
+
},
|
12
|
+
"message": "File should terminate with exactly one newline character ('\\n')"
|
13
|
+
}
|
14
|
+
],
|
15
|
+
"parsed": true
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"path": "/Users/Patrick/Developer/CITest-ios/CITest/ViewController.swift",
|
19
|
+
"violations": [
|
20
|
+
{
|
21
|
+
"severity": "warning",
|
22
|
+
"rule": "terminating-newline",
|
23
|
+
"location": {
|
24
|
+
"line": 14
|
25
|
+
},
|
26
|
+
"message": "File should terminate with exactly one newline character ('\\n')"
|
27
|
+
}
|
28
|
+
],
|
29
|
+
"parsed": true
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"path": "/Users/Patrick/Developer/CITest-ios/CITest/ViewModel.swift",
|
33
|
+
"violations": [
|
34
|
+
{
|
35
|
+
"severity": "warning",
|
36
|
+
"rule": "trailing-whitespace",
|
37
|
+
"location": {
|
38
|
+
"line": 14,
|
39
|
+
"column": 4
|
40
|
+
},
|
41
|
+
"message": "Line should not have any trailing whitespace"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"severity": "warning",
|
45
|
+
"rule": "trailing-whitespace",
|
46
|
+
"location": {
|
47
|
+
"line": 18,
|
48
|
+
"column": 4
|
49
|
+
},
|
50
|
+
"message": "Line should not have any trailing whitespace"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"severity": "warning",
|
54
|
+
"rule": "function-whitespace",
|
55
|
+
"location": {
|
56
|
+
"line": 21,
|
57
|
+
"column": 6
|
58
|
+
},
|
59
|
+
"message": "Function should have at least one blank line after it"
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"parsed": true
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"summary": {
|
66
|
+
"violations": 5,
|
67
|
+
"warnings": 5,
|
68
|
+
"analyzed": 3,
|
69
|
+
"errors": 0,
|
70
|
+
"skipped": 0
|
71
|
+
}
|
72
|
+
}
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-tailor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patrick Butkiewicz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: danger-plugin-api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.41'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.41'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.8'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.14'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.14'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.7'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: listen
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.0.7
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.0.7
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: coveralls
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.8.19
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.8.19
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: Show formatted static analysis reports in your PRs
|
168
|
+
email:
|
169
|
+
- patrick@intrepid.io
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- ".coveralls.yml"
|
175
|
+
- ".gitignore"
|
176
|
+
- ".rubocop.yml"
|
177
|
+
- ".travis.yml"
|
178
|
+
- Gemfile
|
179
|
+
- Guardfile
|
180
|
+
- LICENSE
|
181
|
+
- README.md
|
182
|
+
- Rakefile
|
183
|
+
- danger-tailor.gemspec
|
184
|
+
- lib/danger_plugin.rb
|
185
|
+
- lib/danger_tailor.rb
|
186
|
+
- lib/tailor/gem_version.rb
|
187
|
+
- lib/tailor/plugin.rb
|
188
|
+
- spec/errors.json
|
189
|
+
- spec/spec_helper.rb
|
190
|
+
- spec/tailor_spec.rb
|
191
|
+
- spec/warnings.json
|
192
|
+
homepage: https://github.com/IntrepidPursuits/danger-tailor
|
193
|
+
licenses:
|
194
|
+
- MIT
|
195
|
+
metadata: {}
|
196
|
+
post_install_message:
|
197
|
+
rdoc_options: []
|
198
|
+
require_paths:
|
199
|
+
- lib
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
requirements: []
|
211
|
+
rubyforge_project:
|
212
|
+
rubygems_version: 2.6.4
|
213
|
+
signing_key:
|
214
|
+
specification_version: 4
|
215
|
+
summary: A [Danger](https://danger.systems) plugin that shows warnings and errors
|
216
|
+
generated from the Tailor static analysis tool for the Swift language.
|
217
|
+
test_files:
|
218
|
+
- spec/errors.json
|
219
|
+
- spec/spec_helper.rb
|
220
|
+
- spec/tailor_spec.rb
|
221
|
+
- spec/warnings.json
|