rubocop-sensei 0.1.5 → 0.1.6

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: 5479d9e29fc19485cd4debdeb0f6441dc444003ed7f2472227abd0e4cd95680d
4
- data.tar.gz: 524580de696dc8e3c808f683c92414f083b108c06e1e5a8ae393e12d5bca6a6a
3
+ metadata.gz: 47bef4bcd3ea0dc376372709a49308840b766ca216fcb05017f4a6900c31dd83
4
+ data.tar.gz: f2b90b2573cf06ac25b91a44f150038d9343e6a020e63a5cc65e7a7b246ba569
5
5
  SHA512:
6
- metadata.gz: ed56878a610c3dcfd5457d1ed94303dc002dfcc95fdd699ed34ec16a732f666b87496f27ad316386550865f362f17dfb9248cf0ac72b8e4e66ce47e303555897
7
- data.tar.gz: 379348550eb3a117028c506a435410d707feeee23c3150827afb98ba240ae78cff9146d36be98a1eebe8d3badc54da5c1ea98f376dfa70214970eee0ff00695f
6
+ metadata.gz: ad93f37ce2557726a5594662eb38fd4d75946cc2d46ba7673c602ee8353dfc1c565e633ab76d4088521b6f1d1dcb6fe64b9ab98111aa9ffdf323be1bb4ddaf05
7
+ data.tar.gz: 4bc4eac17a618626da23e88f7fe31f6d31b02ce766459145acdc23c8418c494ca0abce72e64862b9da861878ef2d66e3015903c8b749df76e207c6d04b4bc930
data/.rubocop.yml CHANGED
@@ -6,3 +6,9 @@ AllCops:
6
6
  Naming/FileName:
7
7
  Exclude:
8
8
  - lib/rubocop-sensei.rb
9
+
10
+ require:
11
+ - rubocop-sensei
12
+
13
+ Lecture:
14
+ Enabled: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,34 @@
1
+ # Change log
2
+
3
+ ## 0.1.6 (2023-07-18)
4
+
5
+ - Lecture/ExplainPatternMatchIn
6
+ - Lecture/ExplainPatternMatchRocket
7
+
8
+ ## 0.1.5 (2023-07-15)
9
+
10
+ - Lecture/ExplainPatternMatchCaseIn
11
+ - Lecture/ExplainNumberedParameters
12
+
13
+ ## 0.1.4 (2023-01-21)
14
+
15
+ - Lecture/PreferMap
16
+ - Lecture/PreferSymbolToProc
17
+ - Lecture/ExplainSymbolToProc
18
+
19
+ ## 0.1.3 (2023-01-05)
20
+
21
+ - Lecture/UnlessElse
22
+
23
+ ## 0.1.2 (2023-01-02)
24
+
25
+ - bug fix
26
+
27
+ ## 0.1.1 (2022-12-31)
28
+
29
+ - bug fix
30
+
31
+ ## 0.1.0 (2022-12-30)
32
+
33
+ - Initial Release
34
+ - Lecture/ReplaceElsif
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sensei (0.1.5)
4
+ rubocop-sensei (0.1.6)
5
5
  rubocop
6
6
  typeprof
7
7
 
data/README.md CHANGED
@@ -5,8 +5,13 @@
5
5
  - rubocopコマンドで良い書き方のアドバイスが表示されます
6
6
  - RuboCop に標準で入っているLSPをつかうとエディタ上で書いたコードのそばに表示できます
7
7
 
8
+ ![demo](demo.png)
8
9
  ![demo](demo.gif)
9
10
 
11
+ # 実装されているアドバイス
12
+
13
+ - [config/default.yml](config/default.yml)
14
+
10
15
  # つかい方
11
16
 
12
17
  ## インストール
data/config/default.yml CHANGED
@@ -1,34 +1,44 @@
1
+ Lecture/ExplainNumberedParameters:
2
+ Description: "ナンバーパラメータの説明"
3
+ Enabled: true
4
+ VersionAdded: "0.1.5"
5
+
1
6
  Lecture/ExplainPatternMatchCaseIn:
2
- Description: 'Explain pattern match case in'
7
+ Description: "パターンマッチ case in の説明"
3
8
  Enabled: true
4
- VersionAdded: '0.1.5'
9
+ VersionAdded: "0.1.5"
5
10
 
6
- Lecture/ExplainNumberedParameters:
7
- Description: 'Explain numbered parameters'
11
+ Lecture/ExplainPatternMatchIn:
12
+ Description: "1行パターンマッチ in の説明"
8
13
  Enabled: true
9
- VersionAdded: '0.1.5'
14
+ VersionAdded: "0.1.6"
10
15
 
11
- Lecture/ExplainSymbolToProc :
12
- Description: 'Explain receiver.method(&:method)'
16
+ Lecture/ExplainPatternMatchRocket:
17
+ Description: "1行パターンマッチ => の説明"
13
18
  Enabled: true
14
- VersionAdded: '0.1.4'
19
+ VersionAdded: "0.1.6"
15
20
 
16
- Lecture/PreferSymbolToProc:
17
- Description: 'might be replaced with method(&:method)'
21
+ Lecture/ExplainSymbolToProc :
22
+ Description: "receiver.method(&:method) の説明"
18
23
  Enabled: true
19
- VersionAdded: '0.1.4'
24
+ VersionAdded: "0.1.4"
20
25
 
21
26
  Lecture/PreferMap:
22
- Description: '`each` can be replaced with `map`'
27
+ Description: "この each メソッドは map メソッドで書き換えられるかもしれません"
28
+ Enabled: true
29
+ VersionAdded: "0.1.4"
30
+
31
+ Lecture/PreferSymbolToProc:
32
+ Description: "method(&:method) で書き換えられるかもしれません"
23
33
  Enabled: true
24
- VersionAdded: '0.1.3'
34
+ VersionAdded: "0.1.4"
25
35
 
26
36
  Lecture/ReplaceElsif:
27
- Description: "`elsif` can be replaced with `case`"
37
+ Description: "elsif case で書き換えよう"
28
38
  Enabled: true
29
39
  VersionAdded: "0.1.0"
30
40
 
31
41
  Lecture/UnlessElse:
32
- Description: "Do not use `unless` with `else`. Rewrite these with the positive case first."
42
+ Description: "unless else はやめてif に書き換えよう"
33
43
  Enabled: true
34
44
  VersionAdded: "0.1.3"
data/demo.png ADDED
Binary file
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Lecture
6
+ # 1行パターンマッチです。
7
+ # [1,2,3] in [x,y,3]
8
+ # p x #=> 1
9
+ # p y #=> 2
10
+ # inの右側には変数入りのパターンを書くことができ、左側と対応させ、それぞれの変数に代入します。
11
+ #
12
+ # @example
13
+ # # good
14
+ # 5 => x
15
+ # p x #=> 5
16
+ #
17
+ # # good
18
+ # [1,2,3] in [x,y,3]
19
+ # p x #=> 1
20
+ # p y #=> 2
21
+ #
22
+ class ExplainPatternMatchIn < Base
23
+ MSG = <<~STRING
24
+ 1行パターンマッチです。
25
+ inの右側には変数入りのパターンを書くことができ、左側と対応させ、それぞれの変数に代入します。
26
+
27
+ [1,2,3] in [x,y,3]
28
+ p x #=> 1
29
+ p y #=> 2
30
+
31
+ 5 in x
32
+ p x #=> 5
33
+ STRING
34
+
35
+ def on_match_pattern_p(node)
36
+ add_offense(node)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Lecture
6
+ # 1行パターンマッチです。
7
+ # [1,2,3] => [x,y,3]
8
+ # p x #=> 1
9
+ # p y #=> 2
10
+ # =>の右側には変数入りのパターンを書くことができ、左側と対応させ、それぞれの変数に代入します。
11
+ #
12
+ # @example
13
+ # # good
14
+ # 5 => x
15
+ # p x #=> 5
16
+ #
17
+ # # good
18
+ # [1,2,3] => [x,y,3]
19
+ # p x #=> 1
20
+ # p y #=> 2
21
+ #
22
+ class ExplainPatternMatchRocket < Base
23
+ MSG = <<~STRING
24
+ 1行パターンマッチです。
25
+ =>の右側には変数入りのパターンを書くことができ、左側と対応させ、それぞれの変数に代入します。
26
+
27
+ [1,2,3] => [x,y,3]
28
+ p x #=> 1
29
+ p y #=> 2
30
+
31
+ 5 => x
32
+ p x #=> 5
33
+ STRING
34
+
35
+ def on_match_pattern(node)
36
+ add_offense(node)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require_relative 'lecture/explain_numbered_parameters'
4
4
  require_relative 'lecture/explain_pattern_match_case_in'
5
+ require_relative 'lecture/explain_pattern_match_in'
6
+ require_relative 'lecture/explain_pattern_match_rocket'
5
7
  require_relative 'lecture/prefer_symbol_to_proc'
6
8
  require_relative 'lecture/explain_symbol_to_proc'
7
9
  require_relative 'lecture/prefer_map'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Sensei
5
- VERSION = "0.1.5"
5
+ VERSION = "0.1.6"
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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuniaki Igarashi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-15 00:00:00.000000000 Z
11
+ date: 2023-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -47,17 +47,20 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - ".rspec"
49
49
  - ".rubocop.yml"
50
+ - CHANGELOG.md
50
51
  - Gemfile
51
52
  - Gemfile.lock
52
- - 'LICENSE '
53
53
  - LICENSE.txt
54
54
  - README.md
55
55
  - Rakefile
56
56
  - config/default.yml
57
57
  - demo.gif
58
+ - demo.png
58
59
  - lib/rubocop-sensei.rb
59
60
  - lib/rubocop/cop/lecture/explain_numbered_parameters.rb
60
61
  - lib/rubocop/cop/lecture/explain_pattern_match_case_in.rb
62
+ - lib/rubocop/cop/lecture/explain_pattern_match_in.rb
63
+ - lib/rubocop/cop/lecture/explain_pattern_match_rocket.rb
61
64
  - lib/rubocop/cop/lecture/explain_symbol_to_proc.rb
62
65
  - lib/rubocop/cop/lecture/prefer_map.rb
63
66
  - lib/rubocop/cop/lecture/prefer_symbol_to_proc.rb
data/LICENSE DELETED
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright 2022 Kuniaki Igarashi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.