rubocop_challenger 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66e110ffa25623e67fa5de2245c71339fd464878f3f7d96514373fd807765c7f
4
- data.tar.gz: 310e649280408cac4ce73f68dec4e3b8292c8127e2da6b9cf197baabe5028c8f
3
+ metadata.gz: 0e6ab36ea5a8373773c832d7f40e7867b857fc11682737f2a618e6ceda54ec65
4
+ data.tar.gz: f33fa38af154d266e71c48c4268cb3438e241e5575fc793080cb14f41c51392d
5
5
  SHA512:
6
- metadata.gz: 863e666a4b4e38d4b5750c3ec5ce4f439e1aeb58eee489921ecf979e36c8a7d299c2a40399c9d68fc9fc96cb4d1b69d19dbc77551a601ad4801bae041fee750e
7
- data.tar.gz: 6069887ab002bc116139fa1e5f85bc74d27c5bc515cd199d2c00a2661b4c8547c0b38b95a183befae961ed0d70a3846eb43a4c3405912efb324b5b2e1ad68ebb
6
+ metadata.gz: 8919ffd26ae70dfc7752505abf9a06278fa774a9cb8e31df6698b466c0399fb7ced53560737f8bac7a07bd378e1388ae0a7a9d76a74fcf18282b70253bc67c95
7
+ data.tar.gz: 6cfe197bffdc6064494d1de3267ab64e327ce2a57e7cef1b89a24990ea62f6bd6810cbc2bb4e8286ca8f4f421a2674f9576bea9e34576e339bd48eca57456cee
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-10-22 15:21:40 +0900 using RuboCop version 0.59.2.
3
+ # on 2018-10-26 14:40:31 +0900 using RuboCop version 0.59.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -15,11 +15,11 @@ Layout/SpaceInsideBlockBraces:
15
15
  Exclude:
16
16
  - 'Gemfile'
17
17
 
18
- # Offense count: 5
18
+ # Offense count: 7
19
19
  # Configuration parameters: CountComments, ExcludedMethods.
20
20
  # ExcludedMethods: refine
21
21
  Metrics/BlockLength:
22
- Max: 132
22
+ Max: 112
23
23
 
24
24
  # Offense count: 2
25
25
  # Configuration parameters: Max.
@@ -27,12 +27,11 @@ RSpec/ExampleLength:
27
27
  Exclude:
28
28
  - 'spec/rubocop_challenger/rubocop/todo_reader_spec.rb'
29
29
 
30
- # Offense count: 8
30
+ # Offense count: 9
31
31
  Style/Documentation:
32
32
  Exclude:
33
33
  - 'spec/**/*'
34
34
  - 'test/**/*'
35
- - 'lib/rubocop_challenger.rb'
36
35
  - 'lib/rubocop_challenger/cli.rb'
37
36
  - 'lib/rubocop_challenger/github/pr_template.rb'
38
37
  - 'lib/rubocop_challenger/rubocop/challenge.rb'
@@ -40,6 +39,7 @@ Style/Documentation:
40
39
  - 'lib/rubocop_challenger/rubocop/rule.rb'
41
40
  - 'lib/rubocop_challenger/rubocop/todo_reader.rb'
42
41
  - 'lib/rubocop_challenger/rubocop/todo_writer.rb'
42
+ - 'lib/rubocop_challenger/rubocop/yardoc.rb'
43
43
 
44
44
  # Offense count: 1
45
45
  # Cop supports --auto-correct.
@@ -47,13 +47,7 @@ Style/RedundantSelf:
47
47
  Exclude:
48
48
  - 'lib/rubocop_challenger/rubocop/rule.rb'
49
49
 
50
- # Offense count: 1
51
- # Cop supports --auto-correct.
52
- Style/RescueModifier:
53
- Exclude:
54
- - 'lib/rubocop_challenger/rubocop/rule.rb'
55
-
56
- # Offense count: 6
50
+ # Offense count: 7
57
51
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
58
52
  # URISchemes: http, https
59
53
  Metrics/LineLength:
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop_challenger (0.3.1)
4
+ rubocop_challenger (0.4.0)
5
5
  pr-daikou (~> 0.2.0)
6
6
  rubocop
7
7
  rubocop-rspec
8
8
  thor
9
+ yard
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
@@ -48,6 +49,7 @@ GEM
48
49
  ruby-progressbar (1.10.0)
49
50
  thor (0.20.0)
50
51
  unicode-display_width (1.4.0)
52
+ yard (0.9.16)
51
53
 
52
54
  PLATFORMS
53
55
  ruby
data/README.md CHANGED
@@ -87,7 +87,7 @@ Options:
87
87
  --name=NAME # Pull Request committer name
88
88
  f, [--file-path=FILE_PATH] # Set your ".rubocop_todo.yml" path
89
89
  # Default: .rubocop_todo.yml
90
- t, [--template=TEMPLATE] # Pull Request template `erb` file path.You can use variable that `title`, `rubydoc_url` and `description` into the erb file.
90
+ t, [--template=TEMPLATE] # Pull Request template `erb` file path.You can use variable that `title`, `rubydoc_url`, `description` and `examples` into the erb file.
91
91
  [--mode=MODE] # Mode to select deletion target. You can choice "most_occurrence", "least_occurrence", or "random"
92
92
  # Default: most_occurrence
93
93
  [--base=BASE] # Base branch of Pull Request
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # usage: bin/create_release_pr VERSION
5
+
6
+ require 'bundler/setup'
7
+ require 'rubocop_challenger'
8
+
9
+ def exit_process(error_message)
10
+ puts error_message
11
+ exit!
12
+ end
13
+
14
+ def exist_uncommitted_modify?
15
+ `git add -n .; git diff --name-only` != ''
16
+ end
17
+
18
+ VERSION_FORMAT = /\A\d+\.\d+\.\d+\z/
19
+ version = ARGV[0]
20
+
21
+ # Verifying
22
+ exit_process 'usage: bin/create_release_pr VERSION' if version.nil?
23
+ exit_process 'A version must be like a `1.2.3`' unless version =~ VERSION_FORMAT
24
+ exit_process 'There are uncommitted modify' if exist_uncommitted_modify?
25
+
26
+ # Modify a version file
27
+ File.write('lib/rubocop_challenger/version.rb', <<~VERSION)
28
+ # frozen_string_literal: true
29
+
30
+ module RubocopChallenger
31
+ VERSION = '#{version}'
32
+ end
33
+ VERSION
34
+
35
+ # Bundle Install
36
+ `bundle install`
37
+
38
+ # Create PR
39
+ PRDaikou.exec(
40
+ {
41
+ email: `git config user.email`,
42
+ name: `git config user.name`,
43
+ base: 'master',
44
+ title: "Update v#{version}",
45
+ labels: '',
46
+ topic: "update/v#{version}",
47
+ commit: "Update v#{version}"
48
+ }, nil
49
+ )
data/challenger.gemspec CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_runtime_dependency 'rubocop'
29
29
  spec.add_runtime_dependency 'rubocop-rspec'
30
30
  spec.add_runtime_dependency 'thor'
31
+ spec.add_runtime_dependency 'yard'
31
32
 
32
33
  spec.add_development_dependency 'bundler', '~> 1.16'
33
34
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'erb'
4
+ require 'yard'
4
5
  require 'rubocop'
5
6
  require 'rubocop-rspec'
6
7
  require 'rubocop_challenger/rubocop/rule'
@@ -8,6 +9,7 @@ require 'rubocop_challenger/rubocop/todo_reader'
8
9
  require 'rubocop_challenger/rubocop/todo_writer'
9
10
  require 'rubocop_challenger/rubocop/command'
10
11
  require 'rubocop_challenger/rubocop/challenge'
12
+ require 'rubocop_challenger/rubocop/yardoc'
11
13
  require 'rubocop_challenger/cli'
12
14
  require 'rubocop_challenger/version'
13
15
  require 'rubocop_challenger/github/pr_template.rb'
@@ -22,8 +22,8 @@ module RubocopChallenger
22
22
  type: :string,
23
23
  aliases: :t,
24
24
  desc: 'Pull Request template `erb` file path.' \
25
- 'You can use variable that `title`, `rubydoc_url` and ' \
26
- '`description` into the erb file.'
25
+ 'You can use variable that `title`, `rubydoc_url`, ' \
26
+ '`description` and `examples` into the erb file.'
27
27
  option :mode,
28
28
  type: :string,
29
29
  default: 'most_occurrence',
@@ -7,6 +7,7 @@ module RubocopChallenger
7
7
  template_path ||= File.expand_path('../../templates/default.md.erb', __dir__)
8
8
  @template = File.read(template_path)
9
9
  @rule = rule
10
+ @yardoc = Rubocop::Yardoc.new(title)
10
11
  end
11
12
 
12
13
  def generate_pullrequest_markdown
@@ -18,7 +19,7 @@ module RubocopChallenger
18
19
 
19
20
  private
20
21
 
21
- attr_reader :template, :rule
22
+ attr_reader :template, :rule, :yardoc
22
23
 
23
24
  def title
24
25
  rule.title
@@ -29,7 +30,11 @@ module RubocopChallenger
29
30
  end
30
31
 
31
32
  def description
32
- rule.description
33
+ yardoc.description
34
+ end
35
+
36
+ def examples
37
+ yardoc.examples
33
38
  end
34
39
  end
35
40
  end
@@ -29,11 +29,6 @@ module RubocopChallenger
29
29
  end
30
30
  end
31
31
 
32
- def description
33
- message_const = "RuboCop::Cop::#{title.sub('/', '::')}::MSG"
34
- Object.const_get(message_const) rescue '**NO DESCRIPTION**'
35
- end
36
-
37
32
  private
38
33
 
39
34
  def extract_title
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubocopChallenger
4
+ module Rubocop
5
+ class Yardoc
6
+ def initialize(title)
7
+ @cop_class = Object.const_get("RuboCop::Cop::#{title.sub('/', '::')}")
8
+ YARD.parse(source_file_path)
9
+ @yardoc = YARD::Registry.all(:class).first
10
+ YARD::Registry.clear
11
+ end
12
+
13
+ def description
14
+ yardoc.docstring
15
+ end
16
+
17
+ def examples
18
+ yardoc.tags('example').map(&:text)
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :cop_class, :yardoc
24
+
25
+ def instance_methods
26
+ [
27
+ cop_class.instance_methods(false),
28
+ cop_class.private_instance_methods(false)
29
+ ].flatten!
30
+ end
31
+
32
+ def source_file_path
33
+ instance_methods
34
+ .map { |m| cop_class.instance_method(m).source_location }
35
+ .reject(&:nil?)
36
+ .map(&:first)
37
+ .first
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubocopChallenger
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -4,8 +4,20 @@
4
4
 
5
5
  ## Description
6
6
 
7
+ > ### Overview
8
+ >
7
9
  <% description.each_line do |line| -%>
8
- > <%= line.chomp %>
10
+ <%= "> #{line}".chomp.strip %>
11
+ <% end -%>
12
+ >
13
+ > ### Examples
14
+ <% examples.each do |example| -%>
15
+ >
16
+ > ```rb
17
+ <% example.each_line do |line| -%>
18
+ <%= "> #{line}".chomp.strip %>
19
+ <% end -%>
20
+ > ```
9
21
  <% end -%>
10
22
 
11
23
  ## Checklist
@@ -4,6 +4,18 @@
4
4
 
5
5
  ## Description
6
6
 
7
+ > ### Overview
8
+ >
7
9
  <% description.each_line do |line| -%>
8
- > <%= line.chomp %>
10
+ <%= "> #{line}".chomp.strip %>
11
+ <% end -%>
12
+ >
13
+ > ### Examples
14
+ <% examples.each do |example| -%>
15
+ >
16
+ > ```rb
17
+ <% example.each_line do |line| -%>
18
+ <%= "> #{line}".chomp.strip %>
19
+ <% end -%>
20
+ > ```
9
21
  <% end -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop_challenger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryosuke_sato
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2018-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pr-daikou
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +158,7 @@ files:
144
158
  - README.md
145
159
  - Rakefile
146
160
  - bin/console
161
+ - bin/create_release_pr
147
162
  - bin/setup
148
163
  - challenger.gemspec
149
164
  - exe/rubocop_challenger
@@ -157,6 +172,7 @@ files:
157
172
  - lib/rubocop_challenger/rubocop/rule.rb
158
173
  - lib/rubocop_challenger/rubocop/todo_reader.rb
159
174
  - lib/rubocop_challenger/rubocop/todo_writer.rb
175
+ - lib/rubocop_challenger/rubocop/yardoc.rb
160
176
  - lib/rubocop_challenger/version.rb
161
177
  - lib/templates/checklist.md.erb
162
178
  - lib/templates/default.md.erb