rubocop-sensei 0.1.0 → 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: 3d5985f2ba4b1583ff53baadfc49b88342901c7b17aa0e353da4d8bca55ae8d1
4
- data.tar.gz: 785df89fde862a0fab0f4756307876f54c133896c2ff9360a4b28f3ffdf88aa5
3
+ metadata.gz: 7f8ecd680160660a5b4445cd504edfd3307f3411cf128a39c7d0585cfb60e1eb
4
+ data.tar.gz: 743d055afd20f09ee158d3dfc98fa54fd8df74734ff172bf6a60454d5f1ed34e
5
5
  SHA512:
6
- metadata.gz: c95241d23a5acb41f201da2310f41d28cceda048721e730d3250fc5921e69c4736c49f39d3e4597c0c7e8ccb51e2c46ab408e219cb86048f08b67479c27680ac
7
- data.tar.gz: dff62e0eb119d25d819616b25994ff482860a7ba61a1f1a35c8ae96651176c035c71dc73702cfedf77a571bad966e43d837862b1ac56cd8d45d8462c7eb0acb8
6
+ metadata.gz: ac08f2b720e36c363e911a2a07230d65455cc3275456d61344f952e90af05b95ad366d8a2760a4c126d324555c2641ae2d783dc1fc2425f307eaf4457bb92ebc
7
+ data.tar.gz: 2a8bf2ad71da661994ab758a9b331ae18939c38a12e4e715b7617fc0245d18a36c211e2f382faff4013b5cacdd71cb972d4ab3ee2a5892cac173f19abe9fadd8
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
3
  SuggestExtensions: false
4
+ TargetRubyVersion: 2.7
4
5
 
5
6
  Naming/FileName:
6
7
  Exclude:
data/Gemfile.lock CHANGED
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sensei (0.1.0)
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
- json (2.6.1)
19
- minitest (5.15.0)
18
+ json (2.6.3)
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,30 +32,32 @@ 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.40.0)
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
- rubocop-ast (1.24.0)
52
+ rubocop-ast (1.24.1)
53
53
  parser (>= 3.1.1.0)
54
54
  ruby-progressbar (1.11.0)
55
55
  unicode-display_width (2.3.0)
56
56
 
57
57
  PLATFORMS
58
58
  arm64-darwin-21
59
+ arm64-darwin-22
60
+ ruby
59
61
 
60
62
  DEPENDENCIES
61
63
  debug
data/config/default.yml CHANGED
@@ -1,6 +1,4 @@
1
- # Write it!
2
-
3
- Lint/ReplaceElsif:
4
- Description: 'elsifはCaseで置換できる'
5
- Enabled: pending
6
- VersionAdded: '<<next>>'
1
+ Lecture/ReplaceElsif:
2
+ Description: '`elsif` can be replaced with `case`'
3
+ Enabled: true
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,2 +1,3 @@
1
1
  # frozen_string_literal: true
2
- require_relative 'style/replace_elsif'
2
+
3
+ require_relative 'lecture/replace_elsif'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Sensei
5
- VERSION = "0.1.0"
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.0
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-30 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