sevencop 0.32.2 → 0.33.0

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: f4a4965c23bf272ebe52214f0c8a37c6bd989638560cbf7e079b3af2e9782622
4
- data.tar.gz: 134934de2b553fabf8b07b63c5e10364178fd007866bb45cea8ff8e357985c77
3
+ metadata.gz: 2aa8a2d8e7e48840c1bfdfd2c512e4117d52c5d525663ba0d25dbfe815ca1f70
4
+ data.tar.gz: 9d3a6b87ee268c2dddc82b7eaaf85bc431bce6a36dfb401717986a16e4445b79
5
5
  SHA512:
6
- metadata.gz: 6bf335fbbf8fc003e83369b98b67c2af236bdfd2cee48b6a142ff13a34cea3d0f633a142f340924c61411755adb771171e1fb87498a70edc0e3c4d241f96ca22
7
- data.tar.gz: a5592277696b87dc3ec141b8d2155681da27d7d1f8369d919fd5d24dc1da8d1c2d8ca1070315083e334217f1ecf9d7e77e8879efcbcdc86ed9639ec4aeed0500
6
+ metadata.gz: 14a1f39bda2b687ff9784812eb8600ce792f5bca38a7eb542f268ebb7f23b20b482ef424f50e953cd0f268fee652f787de4f556192ba479d90543521c9a955cd
7
+ data.tar.gz: '08a48ae20f4716f2ea593054e74c684f31e8392a70177eb9076cd4b41fde6bd800000c4655545ade7385b366cd82d7fc985bbc66c0a69d1d1220e22e3a342f5b'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sevencop (0.32.2)
4
+ sevencop (0.33.0)
5
5
  activesupport
6
6
  rubocop
7
7
 
@@ -25,7 +25,7 @@ GEM
25
25
  ast (~> 2.4.1)
26
26
  rainbow (3.1.1)
27
27
  rake (13.0.6)
28
- regexp_parser (2.6.0)
28
+ regexp_parser (2.6.1)
29
29
  rexml (3.2.5)
30
30
  rspec (3.12.0)
31
31
  rspec-core (~> 3.12.0)
@@ -40,7 +40,7 @@ GEM
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
41
  rspec-support (~> 3.12.0)
42
42
  rspec-support (3.12.0)
43
- rubocop (1.38.0)
43
+ rubocop (1.39.0)
44
44
  json (~> 2.3)
45
45
  parallel (~> 1.10)
46
46
  parser (>= 3.1.2.1)
@@ -52,7 +52,7 @@ GEM
52
52
  unicode-display_width (>= 1.4.0, < 3.0)
53
53
  rubocop-ast (1.23.0)
54
54
  parser (>= 3.1.1.0)
55
- rubocop-performance (1.15.0)
55
+ rubocop-performance (1.15.1)
56
56
  rubocop (>= 1.7.0, < 2.0)
57
57
  rubocop-ast (>= 0.4.0)
58
58
  rubocop-rake (0.6.0)
data/README.md CHANGED
@@ -39,7 +39,7 @@ Note that all cops are `Enabled: false` by default.
39
39
  - [Sevencop/MethodDefinitionOrdered](lib/rubocop/cop/sevencop/method_definition_ordered.rb)
40
40
  - [Sevencop/RailsBelongsToOptional](lib/rubocop/cop/sevencop/rails_belongs_to_optional.rb)
41
41
  - [Sevencop/RailsDateAndTimeCalculation](lib/rubocop/cop/sevencop/rails_date_and_time_calculation.rb)
42
- - [Sevencop/RailsOrderField](lib/rubocop/cop/sevencop/rails_order_field.rb)
42
+ - [Sevencop/RailsOrderFieldArelSql](lib/rubocop/cop/sevencop/rails_order_field_arel_sql.rb)
43
43
  - [Sevencop/RailsOrderFieldInOrderOf](lib/rubocop/cop/sevencop/rails_order_field_in_order_of.rb)
44
44
  - [Sevencop/RailsSpecificActionName](lib/rubocop/cop/sevencop/rails_specific_action_name.rb)
45
45
  - [Sevencop/RailsUniquenessValidatorExplicitCaseSensitivity](lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb)
data/config/default.yml CHANGED
@@ -3,26 +3,22 @@ Sevencop/AutoloadOrdered:
3
3
  Sort `autoload` in alphabetical order.
4
4
  Enabled: false
5
5
  Safe: false
6
- VersionAdded: '0.12'
7
6
 
8
7
  Sevencop/ConstantBase:
9
8
  Description: |
10
9
  Avoid unnecessary `::` prefix on constant.
11
10
  Enabled: false
12
- VersionAdded: '0.31'
13
11
 
14
12
  Sevencop/FactoryBotAssociationOption:
15
13
  Description: |
16
14
  Avoid redundant options on FactoryBot associations.
17
15
  Enabled: false
18
- VersionAdded: '0.21'
19
16
 
20
17
  Sevencop/FactoryBotAssociationStyle:
21
18
  Description: |
22
19
  Use consistent style in FactoryBot associations.
23
20
  Enabled: false
24
21
  Safe: false
25
- VersionAdded: '0.21'
26
22
  EnforcedStyle: implicit
27
23
  SupportedStyles:
28
24
  - explicit
@@ -45,69 +41,58 @@ Sevencop/HashElementOrdered:
45
41
  Sort Hash elements by key.
46
42
  Enabled: false
47
43
  Safe: false
48
- VersionAdded: '0.6'
49
44
 
50
45
  Sevencop/MethodDefinitionArgumentsMultiline:
51
46
  Description: |
52
47
  Inserts new lines between method definition arguments.
53
48
  Enabled: false
54
- VersionAdded: '0.11'
55
49
 
56
50
  Sevencop/MethodDefinitionInIncluded:
57
51
  Description: |
58
52
  Do not define methods in `included` blocks.
59
53
  Enabled: false
60
54
  Safe: false
61
- VersionAdded: '0.19'
62
55
 
63
56
  Sevencop/MethodDefinitionOrdered:
64
57
  Description: |
65
58
  Sort method definitions in alphabetical order.
66
59
  Enabled: false
67
60
  Safe: false
68
- VersionAdded: '0.14'
69
61
 
70
62
  Sevencop/MethodDefinitionKeywordArgumentOrdered:
71
63
  Description: |
72
64
  Sort method definition keyword arguments in alphabetical order.
73
65
  Enabled: false
74
66
  Safe: false
75
- VersionAdded: '0.13'
76
67
 
77
68
  Sevencop/RailsBelongsToOptional:
78
69
  Description: |
79
70
  Force `belongs_to` with `optional: true` option.
80
71
  Enabled: false
81
72
  Safe: false
82
- VersionAdded: '0.5'
83
73
 
84
74
  Sevencop/RailsDateAndTimeCalculation:
85
75
  Description: |
86
76
  Prefer ActiveSupport date and time helper.
87
77
  Enabled: false
88
78
  Safe: false
89
- VersionAdded: '0.26'
90
79
 
91
- Sevencop/RailsOrderField:
80
+ Sevencop/RailsOrderFieldArelSql:
92
81
  Description: |
93
82
  Wrap safe SQL String by `Arel.sql`.
94
83
  Enabled: false
95
84
  Safe: false
96
- VersionAdded: '0.4'
97
85
 
98
86
  Sevencop/RailsOrderFieldInOrderOf:
99
87
  Description: |
100
- Prefer `in_order_of` to MySQL `FIELD` function.
88
+ Prefer `in_order_of` to MySQL `FIELD` function if possible.
101
89
  Enabled: false
102
- SafeAutoCorrect: false
103
- VersionAdded: '0.32'
90
+ Safe: false
104
91
 
105
92
  Sevencop/RailsSpecificActionName:
106
93
  Description: |
107
94
  Use only specific action names.
108
95
  Enabled: false
109
- VersionAdded: '0.24'
110
- VersionChanged: '0.29'
111
96
  ActionNames:
112
97
  - create
113
98
  - destroy
@@ -124,27 +109,23 @@ Sevencop/RailsUniquenessValidatorExplicitCaseSensitivity:
124
109
  Specify :case_sensitivity option on use of UniquenessValidator.
125
110
  Enabled: false
126
111
  Safe: false
127
- VersionAdded: '0.3'
128
112
 
129
113
  Sevencop/RailsWhereNot:
130
114
  Description: |
131
115
  Identifies passing multi-elements Hash literal to `where.not`.
132
116
  Enabled: false
133
117
  Safe: false
134
- VersionAdded: '0.7'
135
118
 
136
119
  Sevencop/RequireOrdered:
137
120
  Description: |
138
121
  Sort `require` and `require_relative` in alphabetical order.
139
122
  Enabled: false
140
123
  Safe: false
141
- VersionAdded: '0.16'
142
124
 
143
125
  Sevencop/RSpecDescribeHttpEndpoint:
144
126
  Description: |
145
127
  Pass HTTP endpoint identifier (e.g. `GET /users`) to top-level `describe` on request-specs.
146
128
  Enabled: false
147
- VersionAdded: '0.18'
148
129
  Include:
149
130
  - spec/requests/**/*.rb
150
131
 
@@ -152,7 +133,6 @@ Sevencop/RSpecEmptyLineAfterLet:
152
133
  Description: |
153
134
  Insert empty line after `let`.
154
135
  Enabled: false
155
- VersionAdded: '0.27'
156
136
  Include:
157
137
  - spec/**/*
158
138
 
@@ -160,7 +140,6 @@ Sevencop/RSpecExamplesInSameGroup:
160
140
  Description: |
161
141
  Combine examples in the same groups in the time-consuming kinds of specs.
162
142
  Enabled: false
163
- VersionAdded: '0.17'
164
143
  IncludeSharedExamples: false
165
144
  Include:
166
145
  - spec/controllers/**/*
@@ -170,7 +149,6 @@ Sevencop/RSpecMemoizedHelperBlockDelimiter:
170
149
  Description: |
171
150
  Use do-end block delimiter on RSpec memoized helper.
172
151
  Enabled: false
173
- VersionAdded: '0.27'
174
152
  Include:
175
153
  - spec/**/*
176
154
 
@@ -179,7 +157,6 @@ Sevencop/RSpecRailsResponseParsedBody:
179
157
  Prefer `response.parsed_body` to `JSON.parse(response.body)`.
180
158
  Enabled: false
181
159
  Safe: false
182
- VersionAdded: '0.28'
183
160
  Include:
184
161
  - spec/controllers/**/*
185
162
  - spec/requests/**/*
@@ -41,14 +41,8 @@ module RuboCop
41
41
 
42
42
  add_offense(node) do |corrector|
43
43
  swap(
44
- range_by_whole_lines(
45
- previous_older_sibling.location.expression,
46
- include_final_newline: true
47
- ),
48
- range_by_whole_lines(
49
- node.location.expression,
50
- include_final_newline: true
51
- ),
44
+ range_with_comments_and_lines(previous_older_sibling),
45
+ range_with_comments_and_lines(node),
52
46
  corrector: corrector
53
47
  )
54
48
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
-
5
3
  module RuboCop
6
4
  module Cop
7
5
  module Sevencop
@@ -110,42 +108,36 @@ module RuboCop
110
108
  class RailsDateAndTimeCalculation < Base
111
109
  extend AutoCorrector
112
110
 
113
- CALCULATION_METHOD_NAMES = ::Set.new(
114
- %i[
115
- -
116
- +
117
- ]
118
- ).freeze
119
-
120
- COMPARISON_METHOD_NAMES = ::Set.new(
121
- %i[
122
- <
123
- >
124
- after?
125
- before?
126
- ]
127
- ).freeze
128
-
129
- DURATION_METHOD_NAMES = ::Set.new(
130
- %i[
131
- day
132
- days
133
- fortnight
134
- fortnights
135
- hour
136
- hours
137
- minute
138
- minutes
139
- month
140
- months
141
- second
142
- seconds
143
- week
144
- weeks
145
- year
146
- years
147
- ]
148
- ).freeze
111
+ CALCULATION_METHOD_NAMES = %i[
112
+ -
113
+ +
114
+ ].to_set.freeze
115
+
116
+ COMPARISON_METHOD_NAMES = %i[
117
+ <
118
+ >
119
+ after?
120
+ before?
121
+ ].to_set.freeze
122
+
123
+ DURATION_METHOD_NAMES = %i[
124
+ day
125
+ days
126
+ fortnight
127
+ fortnights
128
+ hour
129
+ hours
130
+ minute
131
+ minutes
132
+ month
133
+ months
134
+ second
135
+ seconds
136
+ week
137
+ weeks
138
+ year
139
+ years
140
+ ].to_set.freeze
149
141
 
150
142
  MSG = 'Prefer ActiveSupport date and time helper.'
151
143
 
@@ -22,7 +22,7 @@ module RuboCop
22
22
  # # good
23
23
  # reorder(Arel.sql('field(id, ?)'), a)
24
24
  #
25
- class RailsOrderField < Base
25
+ class RailsOrderFieldArelSql < Base
26
26
  extend AutoCorrector
27
27
 
28
28
  MSG = 'Wrap safe SQL String by `Arel.sql`.'
@@ -3,9 +3,11 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Sevencop
6
- # Prefer `in_order_of` to MySQL `FIELD` function.
6
+ # Prefer `in_order_of` to MySQL `FIELD` function if possible.
7
7
  #
8
8
  # @safety
9
+ # This cop is unsafe because `in_order_of` also adds `WHERE` clause.
10
+ #
9
11
  # This cop's autocorrection is unsafe because in the original code the array value is interpolated as
10
12
  # literals on SQL query, but after its autocorrection, the value will be now passed directly to in_order_of,
11
13
  # which may produce different results.
@@ -89,7 +91,7 @@ module RuboCop
89
91
  \z
90
92
  /ix.freeze
91
93
 
92
- MSG = 'Prefer `in_order_of` to MySQL `FIELD` function.'
94
+ MSG = 'Prefer `in_order_of` to MySQL `FIELD` function if possible.'
93
95
 
94
96
  RESTRICT_ON_SEND = %i[
95
97
  order
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
-
5
3
  module RuboCop
6
4
  module Cop
7
5
  module Sevencop
@@ -36,19 +36,19 @@ module RuboCop
36
36
  # includes_examples 'creates Foo'
37
37
  # end
38
38
  class RSpecExamplesInSameGroup < Base
39
- METHOD_NAMES_FOR_REGULAR_EXAMPLE = ::Set[
40
- :example,
41
- :it,
42
- :its,
43
- :scenario,
44
- :specify
45
- ].freeze
39
+ METHOD_NAMES_FOR_REGULAR_EXAMPLE = %i[
40
+ example
41
+ it
42
+ its
43
+ scenario
44
+ specify
45
+ ].to_set.freeze
46
46
 
47
- METHOD_NAMES_FOR_SHARED_EXAMPLES = ::Set[
48
- :include_examples,
49
- :it_behaves_like,
50
- :it_should_behave_like
51
- ]
47
+ METHOD_NAMES_FOR_SHARED_EXAMPLES = %i[
48
+ include_examples
49
+ it_behaves_like
50
+ it_should_behave_like
51
+ ].to_set.freeze
52
52
 
53
53
  MSG = 'Combine examples in the same group in the time-consuming kinds of specs.'
54
54
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
-
5
3
  module RuboCop
6
4
  module Cop
7
5
  module Sevencop
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sevencop
4
- VERSION = '0.32.2'
4
+ VERSION = '0.33.0'
5
5
  end
data/lib/sevencop.rb CHANGED
@@ -15,7 +15,7 @@ require_relative 'rubocop/cop/sevencop/method_definition_keyword_argument_ordere
15
15
  require_relative 'rubocop/cop/sevencop/method_definition_ordered'
16
16
  require_relative 'rubocop/cop/sevencop/rails_belongs_to_optional'
17
17
  require_relative 'rubocop/cop/sevencop/rails_date_and_time_calculation'
18
- require_relative 'rubocop/cop/sevencop/rails_order_field'
18
+ require_relative 'rubocop/cop/sevencop/rails_order_field_arel_sql'
19
19
  require_relative 'rubocop/cop/sevencop/rails_order_field_in_order_of'
20
20
  require_relative 'rubocop/cop/sevencop/rails_specific_action_name'
21
21
  require_relative 'rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity'
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.32.2
4
+ version: 0.33.0
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-21 00:00:00.000000000 Z
11
+ date: 2022-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -67,7 +67,7 @@ files:
67
67
  - lib/rubocop/cop/sevencop/method_definition_ordered.rb
68
68
  - lib/rubocop/cop/sevencop/rails_belongs_to_optional.rb
69
69
  - lib/rubocop/cop/sevencop/rails_date_and_time_calculation.rb
70
- - lib/rubocop/cop/sevencop/rails_order_field.rb
70
+ - lib/rubocop/cop/sevencop/rails_order_field_arel_sql.rb
71
71
  - lib/rubocop/cop/sevencop/rails_order_field_in_order_of.rb
72
72
  - lib/rubocop/cop/sevencop/rails_specific_action_name.rb
73
73
  - lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.3.7
110
+ rubygems_version: 3.3.26
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Opinionated custom cops for RuboCop.