danger-chikuwatter 0.0.1
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 +5 -0
- data/.rubocop.yml +148 -0
- data/.travis.yml +10 -0
- data/.vscode/settings.json +9 -0
- data/Gemfile +7 -0
- data/Guardfile +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +25 -0
- data/danger-chikuwatter.gemspec +50 -0
- data/lib/chikuwatter/gem_version.rb +5 -0
- data/lib/chikuwatter/plugin.rb +118 -0
- data/lib/danger_chikuwatter.rb +3 -0
- data/lib/danger_plugin.rb +3 -0
- data/spec/chikuwatter_spec.rb +42 -0
- data/spec/fixtures/result.log +5 -0
- data/spec/spec_helper.rb +67 -0
- metadata +203 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 907f5157662a6a69023d661f64e7461a279466ae66adfc9e51d3692ccf061502
|
|
4
|
+
data.tar.gz: 8d4f3e8f7161fba38842d320fb309519024af2f854b962e898597cbaf4b9c5bb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 771c21e1fbb14c3f49029412068543a43c50b25ff2f54ff329ef492bda564e3980c1790e473a63ba04611aec895d7ca845ebd99766cc165dc2a4dc2850b02f58
|
|
7
|
+
data.tar.gz: 206194f8d5f75d279c40c53c5faaf06cdc8d5f9c481c46164aedfcb10bb73b0f2a03f478997d33659fedabbdf36515390effceaf30a2a43ab1e61aa7aea40189
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
|
2
|
+
|
|
3
|
+
# If you don't like these settings, just delete this file :)
|
|
4
|
+
|
|
5
|
+
AllCops:
|
|
6
|
+
TargetRubyVersion: 2.7
|
|
7
|
+
|
|
8
|
+
Style/StringLiterals:
|
|
9
|
+
EnforcedStyle: double_quotes
|
|
10
|
+
Enabled: true
|
|
11
|
+
|
|
12
|
+
# kind_of? is a good way to check a type
|
|
13
|
+
Style/ClassCheck:
|
|
14
|
+
EnforcedStyle: kind_of?
|
|
15
|
+
|
|
16
|
+
# specs sometimes have useless assignments, which is fine
|
|
17
|
+
Lint/UselessAssignment:
|
|
18
|
+
Exclude:
|
|
19
|
+
- '**/spec/**/*'
|
|
20
|
+
|
|
21
|
+
# We could potentially enable the 2 below:
|
|
22
|
+
Layout/FirstHashElementIndentation:
|
|
23
|
+
Enabled: false
|
|
24
|
+
|
|
25
|
+
Layout/HashAlignment:
|
|
26
|
+
Enabled: false
|
|
27
|
+
|
|
28
|
+
# HoundCI doesn't like this rule
|
|
29
|
+
Layout/DotPosition:
|
|
30
|
+
Enabled: false
|
|
31
|
+
|
|
32
|
+
# We allow !! as it's an easy way to convert ot boolean
|
|
33
|
+
Style/DoubleNegation:
|
|
34
|
+
Enabled: false
|
|
35
|
+
|
|
36
|
+
# Cop supports --auto-correct.
|
|
37
|
+
Lint/UnusedBlockArgument:
|
|
38
|
+
Enabled: false
|
|
39
|
+
|
|
40
|
+
# We want to allow class Fastlane::Class
|
|
41
|
+
Style/ClassAndModuleChildren:
|
|
42
|
+
Enabled: false
|
|
43
|
+
|
|
44
|
+
Metrics/AbcSize:
|
|
45
|
+
Max: 60
|
|
46
|
+
|
|
47
|
+
# The %w might be confusing for new users
|
|
48
|
+
Style/WordArray:
|
|
49
|
+
MinSize: 19
|
|
50
|
+
|
|
51
|
+
# raise and fail are both okay
|
|
52
|
+
Style/SignalException:
|
|
53
|
+
Enabled: false
|
|
54
|
+
|
|
55
|
+
# Better too much 'return' than one missing
|
|
56
|
+
Style/RedundantReturn:
|
|
57
|
+
Enabled: false
|
|
58
|
+
|
|
59
|
+
# Having if in the same line might not always be good
|
|
60
|
+
Style/IfUnlessModifier:
|
|
61
|
+
Enabled: false
|
|
62
|
+
|
|
63
|
+
# and and or is okay
|
|
64
|
+
Style/AndOr:
|
|
65
|
+
Enabled: false
|
|
66
|
+
|
|
67
|
+
# Configuration parameters: CountComments.
|
|
68
|
+
Metrics/ClassLength:
|
|
69
|
+
Max: 350
|
|
70
|
+
|
|
71
|
+
Metrics/CyclomaticComplexity:
|
|
72
|
+
Max: 17
|
|
73
|
+
|
|
74
|
+
# Configuration parameters: AllowURI, URISchemes.
|
|
75
|
+
Layout/LineLength:
|
|
76
|
+
Max: 370
|
|
77
|
+
|
|
78
|
+
# Configuration parameters: CountKeywordArgs.
|
|
79
|
+
Metrics/ParameterLists:
|
|
80
|
+
Max: 10
|
|
81
|
+
|
|
82
|
+
Metrics/PerceivedComplexity:
|
|
83
|
+
Max: 18
|
|
84
|
+
|
|
85
|
+
# Sometimes it's easier to read without guards
|
|
86
|
+
Style/GuardClause:
|
|
87
|
+
Enabled: false
|
|
88
|
+
|
|
89
|
+
# something = if something_else
|
|
90
|
+
# that's confusing
|
|
91
|
+
Style/ConditionalAssignment:
|
|
92
|
+
Enabled: false
|
|
93
|
+
|
|
94
|
+
# Better to have too much self than missing a self
|
|
95
|
+
Style/RedundantSelf:
|
|
96
|
+
Enabled: false
|
|
97
|
+
|
|
98
|
+
Metrics/MethodLength:
|
|
99
|
+
Max: 60
|
|
100
|
+
|
|
101
|
+
# We're not there yet
|
|
102
|
+
Style/Documentation:
|
|
103
|
+
Enabled: false
|
|
104
|
+
|
|
105
|
+
# Adds complexity
|
|
106
|
+
Style/IfInsideElse:
|
|
107
|
+
Enabled: false
|
|
108
|
+
|
|
109
|
+
# danger specific
|
|
110
|
+
|
|
111
|
+
Style/BlockComments:
|
|
112
|
+
Enabled: false
|
|
113
|
+
|
|
114
|
+
Layout/MultilineMethodCallIndentation:
|
|
115
|
+
EnforcedStyle: indented
|
|
116
|
+
|
|
117
|
+
# FIXME: 25
|
|
118
|
+
Metrics/BlockLength:
|
|
119
|
+
Max: 345
|
|
120
|
+
Exclude:
|
|
121
|
+
- "**/*_spec.rb"
|
|
122
|
+
|
|
123
|
+
Style/MixinGrouping:
|
|
124
|
+
Enabled: false
|
|
125
|
+
|
|
126
|
+
Naming/FileName:
|
|
127
|
+
Enabled: false
|
|
128
|
+
|
|
129
|
+
Layout/HeredocIndentation:
|
|
130
|
+
Enabled: false
|
|
131
|
+
|
|
132
|
+
Style/SpecialGlobalVars:
|
|
133
|
+
Enabled: false
|
|
134
|
+
|
|
135
|
+
Style/PercentLiteralDelimiters:
|
|
136
|
+
PreferredDelimiters:
|
|
137
|
+
"%": ()
|
|
138
|
+
"%i": ()
|
|
139
|
+
"%q": ()
|
|
140
|
+
"%Q": ()
|
|
141
|
+
"%r": "{}"
|
|
142
|
+
"%s": ()
|
|
143
|
+
"%w": ()
|
|
144
|
+
"%W": ()
|
|
145
|
+
"%x": ()
|
|
146
|
+
|
|
147
|
+
Security/YAMLLoad:
|
|
148
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# A guardfile for making Danger Plugins
|
|
4
|
+
# For more info see https://github.com/guard/guard#readme
|
|
5
|
+
|
|
6
|
+
# To run, use `bundle exec guard`.
|
|
7
|
+
|
|
8
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
|
9
|
+
require "guard/rspec/dsl"
|
|
10
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
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.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2023 watanavex <watanave.tech@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,39 @@
|
|
|
1
|
+
# danger-chikuwatter
|
|
2
|
+
|
|
3
|
+
Danger Plugin for reporting flutter analyze errors, warnings and **info**.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your Gemfile:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
gem danger-chikuwa
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Run flutter analyze and save the result to a file.
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
$ flutter analyze > result.log
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Add the following to your Dangerfile.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
chikuwa.report "result.log"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If `inline_mode` is true, the plugin will report the errors, warnings and **info** as inline comments.
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
chikuwa.inline_mode = true
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Development
|
|
34
|
+
|
|
35
|
+
1. Clone this repo
|
|
36
|
+
2. Run `bundle install` to setup dependencies.
|
|
37
|
+
3. Run `bundle exec rake spec` to run the tests.
|
|
38
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
|
39
|
+
5. Make your changes.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
require "rubocop/rake_task"
|
|
6
|
+
|
|
7
|
+
RSpec::Core::RakeTask.new(:specs)
|
|
8
|
+
|
|
9
|
+
task default: :specs
|
|
10
|
+
|
|
11
|
+
task :spec do
|
|
12
|
+
Rake::Task["specs"].invoke
|
|
13
|
+
Rake::Task["rubocop"].invoke
|
|
14
|
+
Rake::Task["spec_docs"].invoke
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Run RuboCop on the lib/specs directory"
|
|
18
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
|
19
|
+
task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc "Ensure that the plugin passes `danger plugins lint`"
|
|
23
|
+
task :spec_docs do
|
|
24
|
+
sh "bundle exec danger plugins lint"
|
|
25
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require "chikuwatter/gem_version"
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "danger-chikuwatter"
|
|
9
|
+
spec.version = Chikuwatter::VERSION
|
|
10
|
+
spec.authors = ["watanavex"]
|
|
11
|
+
spec.email = ["watanave.tech@gmail.com"]
|
|
12
|
+
spec.description = "A short description of danger-chikuwatter."
|
|
13
|
+
spec.summary = "A longer description of danger-chikuwatter."
|
|
14
|
+
spec.homepage = "https://github.com/watanavex/danger-chikuwatter"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files`.split($/)
|
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
|
|
23
|
+
|
|
24
|
+
# General ruby development
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
27
|
+
|
|
28
|
+
# Testing support
|
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
|
30
|
+
|
|
31
|
+
# Linting code and docs
|
|
32
|
+
spec.add_development_dependency "rubocop"
|
|
33
|
+
spec.add_development_dependency "yard"
|
|
34
|
+
|
|
35
|
+
# Makes testing easy via `bundle exec guard`
|
|
36
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
|
37
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
|
38
|
+
|
|
39
|
+
# If you want to work on older builds of ruby
|
|
40
|
+
spec.add_development_dependency "listen", "3.0.7"
|
|
41
|
+
|
|
42
|
+
# This gives you the chance to run a REPL inside your tests
|
|
43
|
+
# via:
|
|
44
|
+
#
|
|
45
|
+
# require 'pry'
|
|
46
|
+
# binding.pry
|
|
47
|
+
#
|
|
48
|
+
# This will stop test execution and let you inspect the results
|
|
49
|
+
spec.add_development_dependency "pry"
|
|
50
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Danger
|
|
4
|
+
# Lint markdown files inside your projects.
|
|
5
|
+
# This is done using the [proselint](http://proselint.com) python egg.
|
|
6
|
+
# Results are passed out as a table in markdown.
|
|
7
|
+
#
|
|
8
|
+
# @example Output analyze results with inline comments
|
|
9
|
+
#
|
|
10
|
+
# (You must run `flutter analyze` before using this plugin.)
|
|
11
|
+
# ($ flutter analize > result.log)
|
|
12
|
+
#
|
|
13
|
+
# chikuwatter.inline_mode = true
|
|
14
|
+
# chikuwatter.report = result.log
|
|
15
|
+
#
|
|
16
|
+
class DangerChikuwatter < Plugin
|
|
17
|
+
attr_accessor :project_root, :inline_mode
|
|
18
|
+
|
|
19
|
+
# Project root directory
|
|
20
|
+
def _project_root
|
|
21
|
+
root = @project_root || Dir.pwd
|
|
22
|
+
root += "/" unless root.end_with? "/"
|
|
23
|
+
root
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Inline mode
|
|
27
|
+
def _inline_mode
|
|
28
|
+
@inline_mode || false
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Report analyze results
|
|
32
|
+
def report(file_path)
|
|
33
|
+
if File.exist?(file_path)
|
|
34
|
+
results = parse_analyze_log(file_path)
|
|
35
|
+
send_reports(results)
|
|
36
|
+
else
|
|
37
|
+
fail "analyze log file not found"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Output level
|
|
42
|
+
module Type
|
|
43
|
+
INFO = "info"
|
|
44
|
+
WARN = "warning"
|
|
45
|
+
ERROR = "error"
|
|
46
|
+
|
|
47
|
+
def self.from_string(str)
|
|
48
|
+
case str.downcase
|
|
49
|
+
when INFO then INFO
|
|
50
|
+
when WARN then WARN
|
|
51
|
+
when ERROR then ERROR
|
|
52
|
+
else
|
|
53
|
+
raise ArgumentError, "Invalid type: #{str}"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Report data
|
|
59
|
+
class ReportData
|
|
60
|
+
attr_accessor :message, :type, :file, :line
|
|
61
|
+
|
|
62
|
+
def initialize(message, type, file, line)
|
|
63
|
+
self.message = message
|
|
64
|
+
self.type = type
|
|
65
|
+
self.file = file
|
|
66
|
+
self.line = line
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Parse analyze log
|
|
71
|
+
def parse_analyze_log(file_path)
|
|
72
|
+
_project_root = Dir.pwd
|
|
73
|
+
report_data = []
|
|
74
|
+
File.foreach(file_path) do |line|
|
|
75
|
+
logs = line.split("•")
|
|
76
|
+
if logs.length < 4
|
|
77
|
+
next
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
type_str = logs[0].strip!
|
|
81
|
+
type = Type.from_string(type_str)
|
|
82
|
+
file, line_num = logs[2].strip!.split(":")
|
|
83
|
+
|
|
84
|
+
message = "#{type_str} • #{logs[3].strip!}: #{logs[1].strip!}"
|
|
85
|
+
|
|
86
|
+
report_data.push(ReportData.new(message, type, file, line_num))
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
return report_data
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Send analyze results
|
|
93
|
+
def send_reports(results)
|
|
94
|
+
results.each do |data|
|
|
95
|
+
case data.type
|
|
96
|
+
when Type::INFO
|
|
97
|
+
if _inline_mode
|
|
98
|
+
warn(data.message, file: data.file, line: data.line)
|
|
99
|
+
else
|
|
100
|
+
warn(data.message)
|
|
101
|
+
end
|
|
102
|
+
when Type::WARN
|
|
103
|
+
if _inline_mode
|
|
104
|
+
warn(data.message, file: data.file, line: data.line)
|
|
105
|
+
else
|
|
106
|
+
warn(data.message)
|
|
107
|
+
end
|
|
108
|
+
when Type::ERROR
|
|
109
|
+
if _inline_mode
|
|
110
|
+
failure(data.message, file: data.file, line: data.line)
|
|
111
|
+
else
|
|
112
|
+
failure(data.message)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.expand_path("spec_helper", __dir__)
|
|
4
|
+
|
|
5
|
+
module Danger
|
|
6
|
+
describe Danger::DangerChikuwatter do
|
|
7
|
+
it "should be a plugin" do
|
|
8
|
+
expect(Danger::DangerChikuwatter.new(nil)).to be_a Danger::Plugin
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# You should test your custom attributes and methods here
|
|
13
|
+
#
|
|
14
|
+
describe "with Dangerfile" do
|
|
15
|
+
before do
|
|
16
|
+
@dangerfile = testing_dangerfile
|
|
17
|
+
@my_plugin = @dangerfile.chikuwatter
|
|
18
|
+
|
|
19
|
+
# mock the PR data
|
|
20
|
+
# you can then use this, eg. github.pr_author, later in the spec
|
|
21
|
+
# 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`
|
|
22
|
+
# allow(@my_plugin.github).to receive(:pr_json).and_return(json)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Some examples for writing tests
|
|
26
|
+
# You should replace these with your own.
|
|
27
|
+
|
|
28
|
+
it "Errors on file not found" do
|
|
29
|
+
@my_plugin.report "no file"
|
|
30
|
+
expect(@dangerfile.status_report[:errors]).to eq(["analyze log file not found"])
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "Report" do
|
|
34
|
+
file_path = "#{File.dirname(__FILE__)}/fixtures/result.log"
|
|
35
|
+
@my_plugin.inline_mode = true
|
|
36
|
+
@my_plugin.report file_path
|
|
37
|
+
expect(@dangerfile.status_report[:warnings]).to eq(["warning • lint_rule: warning message", "info • lint_rule: info message"])
|
|
38
|
+
expect(@dangerfile.status_report[:errors]).to eq(["error • lint_rule: error message"])
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "pathname"
|
|
4
|
+
ROOT = Pathname.new(File.expand_path("..", __dir__))
|
|
5
|
+
$:.unshift("#{ROOT}lib".to_s)
|
|
6
|
+
$:.unshift("#{ROOT}spec".to_s)
|
|
7
|
+
|
|
8
|
+
require "bundler/setup"
|
|
9
|
+
require "pry"
|
|
10
|
+
|
|
11
|
+
require "rspec"
|
|
12
|
+
require "danger"
|
|
13
|
+
|
|
14
|
+
# if `git remote -v` == ""
|
|
15
|
+
# puts "You cannot run tests without setting a local git remote on this repo"
|
|
16
|
+
# puts "It's a weird side-effect of Danger's internals."
|
|
17
|
+
# exit(0)
|
|
18
|
+
# end
|
|
19
|
+
|
|
20
|
+
# Use coloured output, it's the best.
|
|
21
|
+
RSpec.configure do |config|
|
|
22
|
+
config.filter_gems_from_backtrace "bundler"
|
|
23
|
+
config.color = true
|
|
24
|
+
config.tty = true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
require "danger_plugin"
|
|
28
|
+
|
|
29
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
|
30
|
+
# If you are expanding these files, see if it's already been done ^.
|
|
31
|
+
|
|
32
|
+
# A silent version of the user interface,
|
|
33
|
+
# it comes with an extra function `.string` which will
|
|
34
|
+
# strip all ANSI colours from the string.
|
|
35
|
+
|
|
36
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
|
37
|
+
def testing_ui
|
|
38
|
+
@output = StringIO.new
|
|
39
|
+
def @output.winsize
|
|
40
|
+
[20, 9999]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
cork = Cork::Board.new(out: @output)
|
|
44
|
+
def cork.string
|
|
45
|
+
out.string.gsub(/\e\[([;\d]+)?m/, "")
|
|
46
|
+
end
|
|
47
|
+
cork
|
|
48
|
+
end
|
|
49
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
|
50
|
+
|
|
51
|
+
# Example environment (ENV) that would come from
|
|
52
|
+
# running a PR on TravisCI
|
|
53
|
+
def testing_env
|
|
54
|
+
{
|
|
55
|
+
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
|
|
56
|
+
"TRAVIS_PULL_REQUEST" => "800",
|
|
57
|
+
"TRAVIS_REPO_SLUG" => "artsy/eigen",
|
|
58
|
+
"TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
|
|
59
|
+
"DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
|
|
60
|
+
}
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# A stubbed out Dangerfile for use in tests
|
|
64
|
+
def testing_dangerfile
|
|
65
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
|
66
|
+
Danger::Dangerfile.new(env, testing_ui)
|
|
67
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: danger-chikuwatter
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- watanavex
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-04-11 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: A short description of danger-chikuwatter.
|
|
154
|
+
email:
|
|
155
|
+
- watanave.tech@gmail.com
|
|
156
|
+
executables: []
|
|
157
|
+
extensions: []
|
|
158
|
+
extra_rdoc_files: []
|
|
159
|
+
files:
|
|
160
|
+
- ".gitignore"
|
|
161
|
+
- ".rubocop.yml"
|
|
162
|
+
- ".travis.yml"
|
|
163
|
+
- ".vscode/settings.json"
|
|
164
|
+
- Gemfile
|
|
165
|
+
- Guardfile
|
|
166
|
+
- LICENSE.txt
|
|
167
|
+
- README.md
|
|
168
|
+
- Rakefile
|
|
169
|
+
- danger-chikuwatter.gemspec
|
|
170
|
+
- lib/chikuwatter/gem_version.rb
|
|
171
|
+
- lib/chikuwatter/plugin.rb
|
|
172
|
+
- lib/danger_chikuwatter.rb
|
|
173
|
+
- lib/danger_plugin.rb
|
|
174
|
+
- spec/chikuwatter_spec.rb
|
|
175
|
+
- spec/fixtures/result.log
|
|
176
|
+
- spec/spec_helper.rb
|
|
177
|
+
homepage: https://github.com/watanavex/danger-chikuwatter
|
|
178
|
+
licenses:
|
|
179
|
+
- MIT
|
|
180
|
+
metadata: {}
|
|
181
|
+
post_install_message:
|
|
182
|
+
rdoc_options: []
|
|
183
|
+
require_paths:
|
|
184
|
+
- lib
|
|
185
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
|
+
requirements:
|
|
187
|
+
- - ">="
|
|
188
|
+
- !ruby/object:Gem::Version
|
|
189
|
+
version: '0'
|
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
|
+
requirements:
|
|
192
|
+
- - ">="
|
|
193
|
+
- !ruby/object:Gem::Version
|
|
194
|
+
version: '0'
|
|
195
|
+
requirements: []
|
|
196
|
+
rubygems_version: 3.1.6
|
|
197
|
+
signing_key:
|
|
198
|
+
specification_version: 4
|
|
199
|
+
summary: A longer description of danger-chikuwatter.
|
|
200
|
+
test_files:
|
|
201
|
+
- spec/chikuwatter_spec.rb
|
|
202
|
+
- spec/fixtures/result.log
|
|
203
|
+
- spec/spec_helper.rb
|