rubocop-sensei 0.1.1 → 0.1.2

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: eadef9a8f8be1d6ef6ac1eb8ca500edb3d66e5b7f916ed94dc9207527d5ebb20
4
- data.tar.gz: 254999ef760ebe16339196c7fb130290b1059f49f4e4856b84a85bd83277f944
3
+ metadata.gz: 7f8ecd680160660a5b4445cd504edfd3307f3411cf128a39c7d0585cfb60e1eb
4
+ data.tar.gz: 743d055afd20f09ee158d3dfc98fa54fd8df74734ff172bf6a60454d5f1ed34e
5
5
  SHA512:
6
- metadata.gz: 24b4a56e67cb97e6e5653ad1c270be034f1d97bf9da33e81a8b57b18d0ba434fa14b75d6c1e04ebc5d6941998ea4d2b44784ebba62eff2ff79d1672d08d7c5b4
7
- data.tar.gz: 8a81bca988686cd1f245a15c4cdf256d07170c7733d49a44b2bca3a130c63c2b8a9598f27fdf59c45e9b7ecd69bc956226f1b82f4f80d6696b4a63f49dfa07d6
6
+ metadata.gz: ac08f2b720e36c363e911a2a07230d65455cc3275456d61344f952e90af05b95ad366d8a2760a4c126d324555c2641ae2d783dc1fc2425f307eaf4457bb92ebc
7
+ data.tar.gz: 2a8bf2ad71da661994ab758a9b331ae18939c38a12e4e715b7617fc0245d18a36c211e2f382faff4013b5cacdd71cb972d4ab3ee2a5892cac173f19abe9fadd8
data/Gemfile.lock CHANGED
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sensei (0.1.1)
4
+ rubocop-sensei (0.1.2)
5
5
  rubocop
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- debug (1.7.0)
11
+ debug (1.7.1)
12
12
  irb (>= 1.5.0)
13
13
  reline (>= 0.3.1)
14
14
  diff-lcs (1.5.0)
15
- io-console (0.5.11)
16
- irb (1.6.0)
15
+ io-console (0.6.0)
16
+ irb (1.6.2)
17
17
  reline (>= 0.3.0)
18
18
  json (2.6.3)
19
- minitest (5.15.0)
19
+ minitest (5.17.0)
20
20
  parallel (1.22.1)
21
21
  parser (3.1.3.0)
22
22
  ast (~> 2.4.1)
23
23
  rainbow (3.1.1)
24
24
  rake (13.0.6)
25
25
  regexp_parser (2.6.1)
26
- reline (0.3.1)
26
+ reline (0.3.2)
27
27
  io-console (~> 0.5)
28
28
  rexml (3.2.5)
29
29
  rspec (3.12.0)
@@ -32,21 +32,21 @@ GEM
32
32
  rspec-mocks (~> 3.12.0)
33
33
  rspec-core (3.12.0)
34
34
  rspec-support (~> 3.12.0)
35
- rspec-expectations (3.12.0)
35
+ rspec-expectations (3.12.1)
36
36
  diff-lcs (>= 1.2.0, < 2.0)
37
37
  rspec-support (~> 3.12.0)
38
- rspec-mocks (3.12.0)
38
+ rspec-mocks (3.12.1)
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
40
  rspec-support (~> 3.12.0)
41
41
  rspec-support (3.12.0)
42
- rubocop (1.41.1)
42
+ rubocop (1.42.0)
43
43
  json (~> 2.3)
44
44
  parallel (~> 1.10)
45
45
  parser (>= 3.1.2.1)
46
46
  rainbow (>= 2.2.2, < 4.0)
47
47
  regexp_parser (>= 1.8, < 3.0)
48
48
  rexml (>= 3.2.5, < 4.0)
49
- rubocop-ast (>= 1.23.0, < 2.0)
49
+ rubocop-ast (>= 1.24.1, < 2.0)
50
50
  ruby-progressbar (~> 1.7)
51
51
  unicode-display_width (>= 1.4.0, < 3.0)
52
52
  rubocop-ast (1.24.1)
data/config/default.yml CHANGED
@@ -1,4 +1,4 @@
1
- Style/ReplaceElsif:
1
+ Lecture/ReplaceElsif:
2
2
  Description: '`elsif` can be replaced with `case`'
3
3
  Enabled: true
4
4
  VersionAdded: '0.1.0'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Lecture
6
6
  # `elsif`は`case`で書き換え可能です。
7
7
  # N個の分岐から1つ選ぶ「N者択一」のときはcaseをつかうと読みやすくなります。
8
8
  #
@@ -65,7 +65,10 @@ module RuboCop
65
65
  return unless node.elsif?
66
66
 
67
67
  add_offense(node) do |corrector|
68
- corrector.replace(node.parent.loc.keyword, "case\nwhen") # if => case when
68
+ # if => case when
69
+ replacing_string = "case" + "\n" +
70
+ " " * node.parent.source_range.column + "when"
71
+ corrector.replace(node.parent.loc.keyword, replacing_string)
69
72
  corrector.replace(node.loc.keyword, "when") # elsif => when
70
73
  end
71
74
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'style/replace_elsif'
3
+ require_relative 'lecture/replace_elsif'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Sensei
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-sensei
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuniaki Igarashi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-31 00:00:00.000000000 Z
11
+ date: 2023-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -40,8 +40,8 @@ files:
40
40
  - Rakefile
41
41
  - config/default.yml
42
42
  - lib/rubocop-sensei.rb
43
+ - lib/rubocop/cop/lecture/replace_elsif.rb
43
44
  - lib/rubocop/cop/sensei_cops.rb
44
- - lib/rubocop/cop/style/replace_elsif.rb
45
45
  - lib/rubocop/sensei.rb
46
46
  - lib/rubocop/sensei/inject.rb
47
47
  - lib/rubocop/sensei/version.rb