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 +4 -4
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +34 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/config/default.yml +25 -15
- data/demo.png +0 -0
- data/lib/rubocop/cop/lecture/explain_pattern_match_in.rb +41 -0
- data/lib/rubocop/cop/lecture/explain_pattern_match_rocket.rb +41 -0
- data/lib/rubocop/cop/sensei_cops.rb +2 -0
- data/lib/rubocop/sensei/version.rb +1 -1
- metadata +6 -3
- data/LICENSE +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47bef4bcd3ea0dc376372709a49308840b766ca216fcb05017f4a6900c31dd83
|
4
|
+
data.tar.gz: f2b90b2573cf06ac25b91a44f150038d9343e6a020e63a5cc65e7a7b246ba569
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad93f37ce2557726a5594662eb38fd4d75946cc2d46ba7673c602ee8353dfc1c565e633ab76d4088521b6f1d1dcb6fe64b9ab98111aa9ffdf323be1bb4ddaf05
|
7
|
+
data.tar.gz: 4bc4eac17a618626da23e88f7fe31f6d31b02ce766459145acdc23c8418c494ca0abce72e64862b9da861878ef2d66e3015903c8b749df76e207c6d04b4bc930
|
data/.rubocop.yml
CHANGED
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
data/README.md
CHANGED
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:
|
7
|
+
Description: "パターンマッチ case in の説明"
|
3
8
|
Enabled: true
|
4
|
-
VersionAdded:
|
9
|
+
VersionAdded: "0.1.5"
|
5
10
|
|
6
|
-
Lecture/
|
7
|
-
Description:
|
11
|
+
Lecture/ExplainPatternMatchIn:
|
12
|
+
Description: "1行パターンマッチ in の説明"
|
8
13
|
Enabled: true
|
9
|
-
VersionAdded:
|
14
|
+
VersionAdded: "0.1.6"
|
10
15
|
|
11
|
-
Lecture/
|
12
|
-
Description:
|
16
|
+
Lecture/ExplainPatternMatchRocket:
|
17
|
+
Description: "1行パターンマッチ => の説明"
|
13
18
|
Enabled: true
|
14
|
-
VersionAdded:
|
19
|
+
VersionAdded: "0.1.6"
|
15
20
|
|
16
|
-
Lecture/
|
17
|
-
Description:
|
21
|
+
Lecture/ExplainSymbolToProc :
|
22
|
+
Description: "receiver.method(&:method) の説明"
|
18
23
|
Enabled: true
|
19
|
-
VersionAdded:
|
24
|
+
VersionAdded: "0.1.4"
|
20
25
|
|
21
26
|
Lecture/PreferMap:
|
22
|
-
Description:
|
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:
|
34
|
+
VersionAdded: "0.1.4"
|
25
35
|
|
26
36
|
Lecture/ReplaceElsif:
|
27
|
-
Description: "
|
37
|
+
Description: "elsif は case で書き換えよう"
|
28
38
|
Enabled: true
|
29
39
|
VersionAdded: "0.1.0"
|
30
40
|
|
31
41
|
Lecture/UnlessElse:
|
32
|
-
Description: "
|
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'
|
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.
|
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-
|
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.
|