danger-inspect 1.0.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 +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +164 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +23 -0
- data/danger-inspect.gemspec +49 -0
- data/lib/danger_inspect.rb +1 -0
- data/lib/danger_plugin.rb +1 -0
- data/lib/inspect/gem_version.rb +3 -0
- data/lib/inspect/plugin.rb +48 -0
- data/lib/inspect/problem.rb +11 -0
- data/spec/inspect_spec.rb +46 -0
- data/spec/spec_helper.rb +65 -0
- metadata +202 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e4435080d5f4d7f710109c4e85af94e5985f20ae8e22f8ad0e4006eb6d91a4d9
|
|
4
|
+
data.tar.gz: 24f5e7f1b89ed5263fc5bb29da77288c0380dc30c3309a8d007fe85103587c4a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0d495f274895afa42b8fd452e72c45e32597156d3e4a191a8e57e8508c54a150140450c9a5918ab84ace2580c87ea87fb8cedfb71f62023410a0b64a9aa1ae2a
|
|
7
|
+
data.tar.gz: ea83571298d234ff3265d74887d48ad492804ad6c452e00995a7136dc1c32ff628079afd1c6b0e9ed543b5aa42a008d259fc0e6e61d78c013d610d5353d09b06
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.7.0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
danger-inspect (1.0.0)
|
|
5
|
+
danger-plugin-api (~> 1.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.8.0)
|
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
12
|
+
ast (2.4.2)
|
|
13
|
+
claide (1.0.3)
|
|
14
|
+
claide-plugins (0.9.2)
|
|
15
|
+
cork
|
|
16
|
+
nap
|
|
17
|
+
open4 (~> 1.3)
|
|
18
|
+
coderay (1.1.3)
|
|
19
|
+
colored2 (3.1.2)
|
|
20
|
+
cork (0.3.0)
|
|
21
|
+
colored2 (~> 3.1)
|
|
22
|
+
danger (8.4.0)
|
|
23
|
+
claide (~> 1.0)
|
|
24
|
+
claide-plugins (>= 0.9.2)
|
|
25
|
+
colored2 (~> 3.1)
|
|
26
|
+
cork (~> 0.1)
|
|
27
|
+
faraday (>= 0.9.0, < 2.0)
|
|
28
|
+
faraday-http-cache (~> 2.0)
|
|
29
|
+
git (~> 1.7)
|
|
30
|
+
kramdown (~> 2.3)
|
|
31
|
+
kramdown-parser-gfm (~> 1.0)
|
|
32
|
+
no_proxy_fix
|
|
33
|
+
octokit (~> 4.7)
|
|
34
|
+
terminal-table (>= 1, < 4)
|
|
35
|
+
danger-plugin-api (1.0.0)
|
|
36
|
+
danger (> 2.0)
|
|
37
|
+
diff-lcs (1.4.4)
|
|
38
|
+
faraday (1.8.0)
|
|
39
|
+
faraday-em_http (~> 1.0)
|
|
40
|
+
faraday-em_synchrony (~> 1.0)
|
|
41
|
+
faraday-excon (~> 1.1)
|
|
42
|
+
faraday-httpclient (~> 1.0.1)
|
|
43
|
+
faraday-net_http (~> 1.0)
|
|
44
|
+
faraday-net_http_persistent (~> 1.1)
|
|
45
|
+
faraday-patron (~> 1.0)
|
|
46
|
+
faraday-rack (~> 1.0)
|
|
47
|
+
multipart-post (>= 1.2, < 3)
|
|
48
|
+
ruby2_keywords (>= 0.0.4)
|
|
49
|
+
faraday-em_http (1.0.0)
|
|
50
|
+
faraday-em_synchrony (1.0.0)
|
|
51
|
+
faraday-excon (1.1.0)
|
|
52
|
+
faraday-http-cache (2.2.0)
|
|
53
|
+
faraday (>= 0.8)
|
|
54
|
+
faraday-httpclient (1.0.1)
|
|
55
|
+
faraday-net_http (1.0.1)
|
|
56
|
+
faraday-net_http_persistent (1.2.0)
|
|
57
|
+
faraday-patron (1.0.0)
|
|
58
|
+
faraday-rack (1.0.0)
|
|
59
|
+
ffi (1.15.4)
|
|
60
|
+
formatador (0.3.0)
|
|
61
|
+
git (1.9.1)
|
|
62
|
+
rchardet (~> 1.8)
|
|
63
|
+
guard (2.18.0)
|
|
64
|
+
formatador (>= 0.2.4)
|
|
65
|
+
listen (>= 2.7, < 4.0)
|
|
66
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
67
|
+
nenv (~> 0.1)
|
|
68
|
+
notiffany (~> 0.0)
|
|
69
|
+
pry (>= 0.13.0)
|
|
70
|
+
shellany (~> 0.0)
|
|
71
|
+
thor (>= 0.18.1)
|
|
72
|
+
guard-compat (1.2.1)
|
|
73
|
+
guard-rspec (4.7.3)
|
|
74
|
+
guard (~> 2.1)
|
|
75
|
+
guard-compat (~> 1.1)
|
|
76
|
+
rspec (>= 2.99.0, < 4.0)
|
|
77
|
+
kramdown (2.3.1)
|
|
78
|
+
rexml
|
|
79
|
+
kramdown-parser-gfm (1.1.0)
|
|
80
|
+
kramdown (~> 2.0)
|
|
81
|
+
listen (3.0.7)
|
|
82
|
+
rb-fsevent (>= 0.9.3)
|
|
83
|
+
rb-inotify (>= 0.9.7)
|
|
84
|
+
lumberjack (1.2.8)
|
|
85
|
+
method_source (1.0.0)
|
|
86
|
+
multipart-post (2.1.1)
|
|
87
|
+
nap (1.1.0)
|
|
88
|
+
nenv (0.3.0)
|
|
89
|
+
no_proxy_fix (0.1.2)
|
|
90
|
+
notiffany (0.1.3)
|
|
91
|
+
nenv (~> 0.1)
|
|
92
|
+
shellany (~> 0.0)
|
|
93
|
+
octokit (4.21.0)
|
|
94
|
+
faraday (>= 0.9)
|
|
95
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
|
96
|
+
open4 (1.3.4)
|
|
97
|
+
parallel (1.21.0)
|
|
98
|
+
parser (3.0.2.0)
|
|
99
|
+
ast (~> 2.4.1)
|
|
100
|
+
pry (0.14.1)
|
|
101
|
+
coderay (~> 1.1)
|
|
102
|
+
method_source (~> 1.0)
|
|
103
|
+
public_suffix (4.0.6)
|
|
104
|
+
rainbow (3.0.0)
|
|
105
|
+
rake (10.5.0)
|
|
106
|
+
rb-fsevent (0.11.0)
|
|
107
|
+
rb-inotify (0.10.1)
|
|
108
|
+
ffi (~> 1.0)
|
|
109
|
+
rchardet (1.8.0)
|
|
110
|
+
regexp_parser (2.1.1)
|
|
111
|
+
rexml (3.2.5)
|
|
112
|
+
rspec (3.10.0)
|
|
113
|
+
rspec-core (~> 3.10.0)
|
|
114
|
+
rspec-expectations (~> 3.10.0)
|
|
115
|
+
rspec-mocks (~> 3.10.0)
|
|
116
|
+
rspec-core (3.10.1)
|
|
117
|
+
rspec-support (~> 3.10.0)
|
|
118
|
+
rspec-expectations (3.10.1)
|
|
119
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
120
|
+
rspec-support (~> 3.10.0)
|
|
121
|
+
rspec-mocks (3.10.2)
|
|
122
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
123
|
+
rspec-support (~> 3.10.0)
|
|
124
|
+
rspec-support (3.10.2)
|
|
125
|
+
rubocop (1.22.0)
|
|
126
|
+
parallel (~> 1.10)
|
|
127
|
+
parser (>= 3.0.0.0)
|
|
128
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
129
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
130
|
+
rexml
|
|
131
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
|
132
|
+
ruby-progressbar (~> 1.7)
|
|
133
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
134
|
+
rubocop-ast (1.12.0)
|
|
135
|
+
parser (>= 3.0.1.1)
|
|
136
|
+
ruby-progressbar (1.11.0)
|
|
137
|
+
ruby2_keywords (0.0.5)
|
|
138
|
+
sawyer (0.8.2)
|
|
139
|
+
addressable (>= 2.3.5)
|
|
140
|
+
faraday (> 0.8, < 2.0)
|
|
141
|
+
shellany (0.0.1)
|
|
142
|
+
terminal-table (3.0.2)
|
|
143
|
+
unicode-display_width (>= 1.1.1, < 3)
|
|
144
|
+
thor (1.1.0)
|
|
145
|
+
unicode-display_width (2.1.0)
|
|
146
|
+
yard (0.9.26)
|
|
147
|
+
|
|
148
|
+
PLATFORMS
|
|
149
|
+
x86_64-darwin-20
|
|
150
|
+
|
|
151
|
+
DEPENDENCIES
|
|
152
|
+
bundler (~> 2.0)
|
|
153
|
+
danger-inspect!
|
|
154
|
+
guard (~> 2.14)
|
|
155
|
+
guard-rspec (~> 4.7)
|
|
156
|
+
listen (= 3.0.7)
|
|
157
|
+
pry
|
|
158
|
+
rake (~> 10.0)
|
|
159
|
+
rspec (~> 3.4)
|
|
160
|
+
rubocop
|
|
161
|
+
yard
|
|
162
|
+
|
|
163
|
+
BUNDLED WITH
|
|
164
|
+
2.2.25
|
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.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2021 shogo4405 <shogo4405@gmail.com>
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# danger-inspect
|
|
2
|
+
|
|
3
|
+
Danger plugin for code inspections.
|
|
4
|
+
|
|
5
|
+
|IntelliJ IDEA|Danger|
|
|
6
|
+
|:-:|:-:|
|
|
7
|
+
|<img width="588" alt="スクリーンショット 2021-10-10 15 12 11" src="https://user-images.githubusercontent.com/810189/136684847-a191193b-a43c-4a61-a53f-68b92259d8d3.png">|<img width="608" alt="スクリーンショット 2021-10-10 15 21 35" src="https://user-images.githubusercontent.com/810189/136685067-1b832a71-730d-4408-83ef-355b089c19b8.png">
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
```sh
|
|
12
|
+
$ gem install danger-inspect
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Inspect
|
|
18
|
+
[Run code inspections from the command line.](https://www.jetbrains.com/help/idea/command-line-code-inspector.html)
|
|
19
|
+
```sh
|
|
20
|
+
$ idea.sh inspect #{workspace} #{workspace}/inspect.xml /path/to/inspect-result_dir
|
|
21
|
+
```
|
|
22
|
+
```sh
|
|
23
|
+
$ /opt/android-studio/bin/inspect.sh #{workspace} #{workspace}/inspect.xml /path/to/inspect-result_dir
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Dangerfile
|
|
27
|
+
*Please inspect before danger step.*
|
|
28
|
+
```rb
|
|
29
|
+
inspect.report 'path/to/inspect-result_dir'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Development
|
|
33
|
+
|
|
34
|
+
1. Clone this repo
|
|
35
|
+
2. Run `bundle install` to setup dependencies.
|
|
36
|
+
3. Run `bundle exec rake spec` to run the tests.
|
|
37
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
|
38
|
+
5. Make your changes.
|
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,49 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'inspect/gem_version.rb'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'danger-inspect'
|
|
8
|
+
spec.version = Inspect::VERSION
|
|
9
|
+
spec.authors = ['shogo4405']
|
|
10
|
+
spec.email = ['shogo4405@gmail.com']
|
|
11
|
+
spec.description = %q{Danger plugin for code inspections.}
|
|
12
|
+
spec.summary = %q{Danger plugin for code inspections. You can see the code inspections as danger messages.}
|
|
13
|
+
spec.homepage = 'https://github.com/shogo4405/danger-inspect'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ['lib']
|
|
20
|
+
|
|
21
|
+
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
|
22
|
+
|
|
23
|
+
# General ruby development
|
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
26
|
+
|
|
27
|
+
# Testing support
|
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
|
29
|
+
|
|
30
|
+
# Linting code and docs
|
|
31
|
+
spec.add_development_dependency "rubocop"
|
|
32
|
+
spec.add_development_dependency "yard"
|
|
33
|
+
|
|
34
|
+
# Makes testing easy via `bundle exec guard`
|
|
35
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
|
36
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
|
37
|
+
|
|
38
|
+
# If you want to work on older builds of ruby
|
|
39
|
+
spec.add_development_dependency 'listen', '3.0.7'
|
|
40
|
+
|
|
41
|
+
# This gives you the chance to run a REPL inside your tests
|
|
42
|
+
# via:
|
|
43
|
+
#
|
|
44
|
+
# require 'pry'
|
|
45
|
+
# binding.pry
|
|
46
|
+
#
|
|
47
|
+
# This will stop test execution and let you inspect the results
|
|
48
|
+
spec.add_development_dependency 'pry'
|
|
49
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "inspect/gem_version"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "inspect/plugin"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require_relative 'problem'
|
|
2
|
+
|
|
3
|
+
module Danger
|
|
4
|
+
# Danger plugin for code inspections.
|
|
5
|
+
#
|
|
6
|
+
# @example Parse the XML files, and report messages.
|
|
7
|
+
#
|
|
8
|
+
# inspect.report 'path/to/inspect-result_dir'
|
|
9
|
+
#
|
|
10
|
+
# @see shogo4405/danger-inspect
|
|
11
|
+
# @tags lint
|
|
12
|
+
#
|
|
13
|
+
class DangerInspect < Plugin
|
|
14
|
+
# Report code inspections messages.
|
|
15
|
+
#
|
|
16
|
+
# @return [void]
|
|
17
|
+
def report(dir)
|
|
18
|
+
problems = []
|
|
19
|
+
Dir.glob("#{dir}/*.xml") do |file|
|
|
20
|
+
problems.push(read_xml(file)) unless file.include?('.descriptions.xml')
|
|
21
|
+
end
|
|
22
|
+
comment(problems.flatten)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def read_xml(file)
|
|
28
|
+
require 'rexml/document'
|
|
29
|
+
problems = []
|
|
30
|
+
xml = REXML::Document.new(File.read(file))
|
|
31
|
+
xml
|
|
32
|
+
.get_elements('problems/problem')
|
|
33
|
+
.each { |element| problems.push(Problem.generate(element)) }
|
|
34
|
+
problems
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def comment(problems)
|
|
38
|
+
problems.each do |problem|
|
|
39
|
+
case problem.severity.downcase
|
|
40
|
+
when 'info'
|
|
41
|
+
message(problem.message, file: problem.file, line: problem.line)
|
|
42
|
+
else
|
|
43
|
+
warn(problem.message, file: problem.file, line: problem.line)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Problem =
|
|
2
|
+
Struct.new(:file, :line, :message, :severity) do
|
|
3
|
+
def self.generate(node)
|
|
4
|
+
Problem.new(
|
|
5
|
+
node.get_elements('file').first.text.gsub('file://$PROJECT_DIR$/', ''),
|
|
6
|
+
node.get_elements('line').first.text.to_i,
|
|
7
|
+
node.get_elements('description').first.text,
|
|
8
|
+
node.get_elements('problem_class').first.attributes['severity']
|
|
9
|
+
)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Danger
|
|
4
|
+
describe Danger::DangerInspect do
|
|
5
|
+
it "should be a plugin" do
|
|
6
|
+
expect(Danger::DangerInspect.new(nil)).to be_a Danger::Plugin
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# You should test your custom attributes and methods here
|
|
11
|
+
#
|
|
12
|
+
describe "with Dangerfile" do
|
|
13
|
+
before do
|
|
14
|
+
@dangerfile = testing_dangerfile
|
|
15
|
+
@my_plugin = @dangerfile.inspect
|
|
16
|
+
|
|
17
|
+
# mock the PR data
|
|
18
|
+
# you can then use this, eg. github.pr_author, later in the spec
|
|
19
|
+
json = File.read(File.dirname(__FILE__) + '/support/fixtures/github_pr.json') # example json: `curl https://api.github.com/repos/danger/danger-plugin-template/pulls/18 > github_pr.json`
|
|
20
|
+
allow(@my_plugin.github).to receive(:pr_json).and_return(json)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Some examples for writing tests
|
|
24
|
+
# You should replace these with your own.
|
|
25
|
+
|
|
26
|
+
it "Warns on a monday" do
|
|
27
|
+
monday_date = Date.parse("2016-07-11")
|
|
28
|
+
allow(Date).to receive(:today).and_return monday_date
|
|
29
|
+
|
|
30
|
+
@my_plugin.warn_on_mondays
|
|
31
|
+
|
|
32
|
+
expect(@dangerfile.status_report[:warnings]).to eq(["Trying to merge code on a Monday"])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "Does nothing on a tuesday" do
|
|
36
|
+
monday_date = Date.parse("2016-07-12")
|
|
37
|
+
allow(Date).to receive(:today).and_return monday_date
|
|
38
|
+
|
|
39
|
+
@my_plugin.warn_on_mondays
|
|
40
|
+
|
|
41
|
+
expect(@dangerfile.status_report[:warnings]).to eq([])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
ROOT = Pathname.new(File.expand_path("../../", __FILE__))
|
|
3
|
+
$:.unshift((ROOT + "lib").to_s)
|
|
4
|
+
$:.unshift((ROOT + "spec").to_s)
|
|
5
|
+
|
|
6
|
+
require "bundler/setup"
|
|
7
|
+
require "pry"
|
|
8
|
+
|
|
9
|
+
require "rspec"
|
|
10
|
+
require "danger"
|
|
11
|
+
|
|
12
|
+
if `git remote -v` == ''
|
|
13
|
+
puts "You cannot run tests without setting a local git remote on this repo"
|
|
14
|
+
puts "It's a weird side-effect of Danger's internals."
|
|
15
|
+
exit(0)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Use coloured output, it's the best.
|
|
19
|
+
RSpec.configure do |config|
|
|
20
|
+
config.filter_gems_from_backtrace "bundler"
|
|
21
|
+
config.color = true
|
|
22
|
+
config.tty = true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
require "danger_plugin"
|
|
26
|
+
|
|
27
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
|
28
|
+
# If you are expanding these files, see if it's already been done ^.
|
|
29
|
+
|
|
30
|
+
# A silent version of the user interface,
|
|
31
|
+
# it comes with an extra function `.string` which will
|
|
32
|
+
# strip all ANSI colours from the string.
|
|
33
|
+
|
|
34
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
|
35
|
+
def testing_ui
|
|
36
|
+
@output = StringIO.new
|
|
37
|
+
def @output.winsize
|
|
38
|
+
[20, 9999]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
cork = Cork::Board.new(out: @output)
|
|
42
|
+
def cork.string
|
|
43
|
+
out.string.gsub(/\e\[([;\d]+)?m/, "")
|
|
44
|
+
end
|
|
45
|
+
cork
|
|
46
|
+
end
|
|
47
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
|
48
|
+
|
|
49
|
+
# Example environment (ENV) that would come from
|
|
50
|
+
# running a PR on TravisCI
|
|
51
|
+
def testing_env
|
|
52
|
+
{
|
|
53
|
+
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
|
|
54
|
+
"TRAVIS_PULL_REQUEST" => "800",
|
|
55
|
+
"TRAVIS_REPO_SLUG" => "artsy/eigen",
|
|
56
|
+
"TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
|
|
57
|
+
"DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# A stubbed out Dangerfile for use in tests
|
|
62
|
+
def testing_dangerfile
|
|
63
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
|
64
|
+
Danger::Dangerfile.new(env, testing_ui)
|
|
65
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: danger-inspect
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- shogo4405
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-10-10 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: '2.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
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'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
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'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
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: pry
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
description: Danger plugin for code inspections.
|
|
154
|
+
email:
|
|
155
|
+
- shogo4405@gmail.com
|
|
156
|
+
executables: []
|
|
157
|
+
extensions: []
|
|
158
|
+
extra_rdoc_files: []
|
|
159
|
+
files:
|
|
160
|
+
- ".gitignore"
|
|
161
|
+
- ".ruby-version"
|
|
162
|
+
- Gemfile
|
|
163
|
+
- Gemfile.lock
|
|
164
|
+
- Guardfile
|
|
165
|
+
- LICENSE.txt
|
|
166
|
+
- README.md
|
|
167
|
+
- Rakefile
|
|
168
|
+
- danger-inspect.gemspec
|
|
169
|
+
- lib/danger_inspect.rb
|
|
170
|
+
- lib/danger_plugin.rb
|
|
171
|
+
- lib/inspect/gem_version.rb
|
|
172
|
+
- lib/inspect/plugin.rb
|
|
173
|
+
- lib/inspect/problem.rb
|
|
174
|
+
- spec/inspect_spec.rb
|
|
175
|
+
- spec/spec_helper.rb
|
|
176
|
+
homepage: https://github.com/shogo4405/danger-inspect
|
|
177
|
+
licenses:
|
|
178
|
+
- MIT
|
|
179
|
+
metadata: {}
|
|
180
|
+
post_install_message:
|
|
181
|
+
rdoc_options: []
|
|
182
|
+
require_paths:
|
|
183
|
+
- lib
|
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
|
+
requirements:
|
|
186
|
+
- - ">="
|
|
187
|
+
- !ruby/object:Gem::Version
|
|
188
|
+
version: '0'
|
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
|
+
requirements:
|
|
191
|
+
- - ">="
|
|
192
|
+
- !ruby/object:Gem::Version
|
|
193
|
+
version: '0'
|
|
194
|
+
requirements: []
|
|
195
|
+
rubygems_version: 3.1.2
|
|
196
|
+
signing_key:
|
|
197
|
+
specification_version: 4
|
|
198
|
+
summary: Danger plugin for code inspections. You can see the code inspections as danger
|
|
199
|
+
messages.
|
|
200
|
+
test_files:
|
|
201
|
+
- spec/inspect_spec.rb
|
|
202
|
+
- spec/spec_helper.rb
|