sevencop 0.28.0 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79bb602015c9eea9c89de44bfbd22274ef1197412a420f274280cc3cac7fe8c5
4
- data.tar.gz: 8fe918f1ad6031ec0b4886a778e5333d9574ecf23c5658f133e32423349d2a28
3
+ metadata.gz: df805d1a45b205a9edf69411d7900ee8896d7d36da95bb608e0f1d45750d2441
4
+ data.tar.gz: f8318114a6fc158134f381e39a4b095957343ea35db94f86639b702a35ead7c1
5
5
  SHA512:
6
- metadata.gz: 0bdc4d1d137ea5c3a3b2048e8c1aa37bfff81672aef0b10d75cc361f4ff10938d9327ec1193f7936b6180b8fc2e2f6e51909723a9b036279c2852d76e810990b
7
- data.tar.gz: 4235669bbd83b5f460663877b3e47272bffa0aadec21e1f413a7e957c6f0bdafe851443d0bbff5985553978b495e4b8c0d418b7736b9ebc9f2ee941859885f85
6
+ metadata.gz: 2aa56f5b6fc473ce25c3758e754dd98bd5ca635c3984fd8b6af1347821bdd7fc5b3bfd213a57db0866b96b4a5a3464cd5097b253782dc30c05471ca09afed09c
7
+ data.tar.gz: d16d7cf8fe6cff81a82277a140ef6738a9089072afea4163d96d839bf3ec6f62848a5c061b7226b927cfd5da1d01c9318d216fc262271c1371886c657190c2fb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sevencop (0.28.0)
4
+ sevencop (0.29.1)
5
5
  activesupport
6
6
  rubocop
7
7
 
@@ -25,39 +25,39 @@ GEM
25
25
  ast (~> 2.4.1)
26
26
  rainbow (3.1.1)
27
27
  rake (13.0.6)
28
- regexp_parser (2.5.0)
28
+ regexp_parser (2.6.0)
29
29
  rexml (3.2.5)
30
- rspec (3.11.0)
31
- rspec-core (~> 3.11.0)
32
- rspec-expectations (~> 3.11.0)
33
- rspec-mocks (~> 3.11.0)
34
- rspec-core (3.11.0)
35
- rspec-support (~> 3.11.0)
36
- rspec-expectations (3.11.1)
30
+ rspec (3.12.0)
31
+ rspec-core (~> 3.12.0)
32
+ rspec-expectations (~> 3.12.0)
33
+ rspec-mocks (~> 3.12.0)
34
+ rspec-core (3.12.0)
35
+ rspec-support (~> 3.12.0)
36
+ rspec-expectations (3.12.0)
37
37
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.11.0)
39
- rspec-mocks (3.11.1)
38
+ rspec-support (~> 3.12.0)
39
+ rspec-mocks (3.12.0)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.11.0)
42
- rspec-support (3.11.1)
43
- rubocop (1.36.0)
41
+ rspec-support (~> 3.12.0)
42
+ rspec-support (3.12.0)
43
+ rubocop (1.38.0)
44
44
  json (~> 2.3)
45
45
  parallel (~> 1.10)
46
46
  parser (>= 3.1.2.1)
47
47
  rainbow (>= 2.2.2, < 4.0)
48
48
  regexp_parser (>= 1.8, < 3.0)
49
49
  rexml (>= 3.2.5, < 4.0)
50
- rubocop-ast (>= 1.20.1, < 2.0)
50
+ rubocop-ast (>= 1.23.0, < 2.0)
51
51
  ruby-progressbar (~> 1.7)
52
52
  unicode-display_width (>= 1.4.0, < 3.0)
53
- rubocop-ast (1.21.0)
53
+ rubocop-ast (1.23.0)
54
54
  parser (>= 3.1.1.0)
55
55
  rubocop-performance (1.15.0)
56
56
  rubocop (>= 1.7.0, < 2.0)
57
57
  rubocop-ast (>= 0.4.0)
58
58
  rubocop-rake (0.6.0)
59
59
  rubocop (~> 1.0)
60
- rubocop-rspec (2.13.1)
60
+ rubocop-rspec (2.15.0)
61
61
  rubocop (~> 1.33)
62
62
  ruby-progressbar (1.11.0)
63
63
  tzinfo (2.0.5)
data/README.md CHANGED
@@ -36,11 +36,11 @@ Note that all cops are `Enabled: false` by default.
36
36
  - [Sevencop/MethodDefinitionInIncluded](lib/rubocop/cop/sevencop/method_definition_in_included.rb)
37
37
  - [Sevencop/MethodDefinitionKeywordArgumentOrdered](lib/rubocop/cop/sevencop/method_definition_keyword_argument_ordered.rb)
38
38
  - [Sevencop/MethodDefinitionOrdered](lib/rubocop/cop/sevencop/method_definition_ordered.rb)
39
- - [Sevencop/RailsActionName](lib/rubocop/cop/sevencop/rails_action_name.rb)
40
39
  - [Sevencop/RailsBelongsToOptional](lib/rubocop/cop/sevencop/rails_belongs_to_optional.rb)
41
40
  - [Sevencop/RailsDateAndTimeCalculation](lib/rubocop/cop/sevencop/rails_date_and_time_calculation.rb)
42
41
  - [Sevencop/RailsInferredSpecType](lib/rubocop/cop/sevencop/rails_inferred_spec_type.rb)
43
42
  - [Sevencop/RailsOrderField](lib/rubocop/cop/sevencop/rails_order_field.rb)
43
+ - [Sevencop/RailsSpecificActionName](lib/rubocop/cop/sevencop/rails_specific_action_name.rb)
44
44
  - [Sevencop/RailsUniquenessValidatorExplicitCaseSensitivity](lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb)
45
45
  - [Sevencop/RailsWhereNot](lib/rubocop/cop/sevencop/rails_where_not.rb)
46
46
  - [Sevencop/RequireOrdered](lib/rubocop/cop/sevencop/require_ordered.rb)
data/config/default.yml CHANGED
@@ -68,22 +68,6 @@ Sevencop/MethodDefinitionKeywordArgumentOrdered:
68
68
  Safe: false
69
69
  VersionAdded: '0.13'
70
70
 
71
- Sevencop/RailsActionName:
72
- Description: |
73
- Use only specific action names.
74
- Enabled: false
75
- VersionAdded: '0.24'
76
- ActionNames:
77
- - create
78
- - destroy
79
- - edit
80
- - index
81
- - new
82
- - show
83
- - update
84
- Include:
85
- - app/controllers/**/*.rb
86
-
87
71
  Sevencop/RailsBelongsToOptional:
88
72
  Description: |
89
73
  Force `belongs_to` with `optional: true` option.
@@ -112,6 +96,23 @@ Sevencop/RailsOrderField:
112
96
  Safe: false
113
97
  VersionAdded: '0.4'
114
98
 
99
+ Sevencop/RailsSpecificActionName:
100
+ Description: |
101
+ Use only specific action names.
102
+ Enabled: false
103
+ VersionAdded: '0.24'
104
+ VersionChanged: '0.29'
105
+ ActionNames:
106
+ - create
107
+ - destroy
108
+ - edit
109
+ - index
110
+ - new
111
+ - show
112
+ - update
113
+ Include:
114
+ - app/controllers/**/*.rb
115
+
115
116
  Sevencop/RailsUniquenessValidatorExplicitCaseSensitivity:
116
117
  Description: |
117
118
  Specify :case_sensitivity option on use of UniquenessValidator.
@@ -148,6 +148,7 @@ module RuboCop
148
148
  block = node.parent
149
149
  return [] unless block
150
150
  return [] unless block.block_type?
151
+ return [] unless block.body
151
152
 
152
153
  if block.body.begin_type?
153
154
  block.body.children
@@ -37,8 +37,8 @@ module RuboCop
37
37
  (send
38
38
  _ _
39
39
  {
40
- (str /field\(.+\)/i) |
41
- (dstr <(str /field\(.+\)/i) ...>)
40
+ (str /field(.+)/i) |
41
+ (dstr <(str /field(.+)/i) ...>)
42
42
  }
43
43
  ...
44
44
  )
@@ -5,6 +5,9 @@ module RuboCop
5
5
  module Sevencop
6
6
  # Use only specific action names.
7
7
  #
8
+ # It is good practice to separate controller classes rather than adding more actions as needed.
9
+ # By default, the 7 CRUD action names are specified that are generated by the Rails scaffold.
10
+ #
8
11
  # @example
9
12
  # # bad
10
13
  # class UsersController < ApplicationController
@@ -17,7 +20,7 @@ module RuboCop
17
20
  # def index
18
21
  # end
19
22
  # end
20
- class RailsActionName < Base
23
+ class RailsSpecificActionName < Base
21
24
  include VisibilityHelp
22
25
 
23
26
  MSG = 'Use only specific action names.'
@@ -27,7 +30,13 @@ module RuboCop
27
30
  def on_def(node)
28
31
  return unless bad?(node)
29
32
 
30
- add_offense(node.location.name)
33
+ add_offense(
34
+ node.location.name,
35
+ message: format(
36
+ 'Use only specific action names (%<action_names>s).',
37
+ action_names: configured_action_names.join(', ')
38
+ )
39
+ )
31
40
  end
32
41
 
33
42
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sevencop
4
- VERSION = '0.28.0'
4
+ VERSION = '0.29.1'
5
5
  end
data/lib/sevencop.rb CHANGED
@@ -12,11 +12,11 @@ require_relative 'rubocop/cop/sevencop/method_definition_arguments_multiline'
12
12
  require_relative 'rubocop/cop/sevencop/method_definition_in_included'
13
13
  require_relative 'rubocop/cop/sevencop/method_definition_keyword_argument_ordered'
14
14
  require_relative 'rubocop/cop/sevencop/method_definition_ordered'
15
- require_relative 'rubocop/cop/sevencop/rails_action_name'
16
15
  require_relative 'rubocop/cop/sevencop/rails_belongs_to_optional'
17
16
  require_relative 'rubocop/cop/sevencop/rails_date_and_time_calculation'
18
17
  require_relative 'rubocop/cop/sevencop/rails_inferred_spec_type'
19
18
  require_relative 'rubocop/cop/sevencop/rails_order_field'
19
+ require_relative 'rubocop/cop/sevencop/rails_specific_action_name'
20
20
  require_relative 'rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity'
21
21
  require_relative 'rubocop/cop/sevencop/rails_where_not'
22
22
  require_relative 'rubocop/cop/sevencop/require_ordered'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sevencop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 0.29.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-05 00:00:00.000000000 Z
11
+ date: 2022-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -64,11 +64,11 @@ files:
64
64
  - lib/rubocop/cop/sevencop/method_definition_in_included.rb
65
65
  - lib/rubocop/cop/sevencop/method_definition_keyword_argument_ordered.rb
66
66
  - lib/rubocop/cop/sevencop/method_definition_ordered.rb
67
- - lib/rubocop/cop/sevencop/rails_action_name.rb
68
67
  - lib/rubocop/cop/sevencop/rails_belongs_to_optional.rb
69
68
  - lib/rubocop/cop/sevencop/rails_date_and_time_calculation.rb
70
69
  - lib/rubocop/cop/sevencop/rails_inferred_spec_type.rb
71
70
  - lib/rubocop/cop/sevencop/rails_order_field.rb
71
+ - lib/rubocop/cop/sevencop/rails_specific_action_name.rb
72
72
  - lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb
73
73
  - lib/rubocop/cop/sevencop/rails_where_not.rb
74
74
  - lib/rubocop/cop/sevencop/require_ordered.rb