sevencop 0.32.2 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -1
- data/Gemfile.lock +23 -20
- data/README.md +1 -2
- data/config/default.yml +3 -35
- data/lib/rubocop/cop/sevencop/autoload_ordered.rb +2 -8
- data/lib/rubocop/cop/sevencop/rails_date_and_time_calculation.rb +30 -38
- data/lib/rubocop/cop/sevencop/{rails_order_field.rb → rails_order_field_arel_sql.rb} +1 -1
- data/lib/rubocop/cop/sevencop/rails_order_field_in_order_of.rb +4 -2
- data/lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb +0 -2
- data/lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb +12 -12
- data/lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb +0 -2
- data/lib/sevencop/rubocop_extension.rb +1 -1
- data/lib/sevencop/version.rb +1 -1
- data/lib/sevencop.rb +1 -2
- metadata +4 -5
- data/lib/rubocop/cop/sevencop/rspec_rails_response_parsed_body.rb +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33aea941e4f044a45b702d9c9e700c1d9a42aa5f4f44819e506e83b9b939849b
|
4
|
+
data.tar.gz: 83f1c6d8f55256f5a6f89a9cbc632efe084b6acd70cdbc2aaef4f6c7a339fbdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc6b9622262cee943fe8d5274155ea7a3d5c46948d3f5b22c3f6b651e37b032eeaa6f3c63757de06e347c4d3fbcab22723ca612c4acb28445662671ca5f5dae9
|
7
|
+
data.tar.gz: 3e4400c2c7c2b63c7f0733888e05793f5c752d59771aae2308d5a19164d177843296a31bfecfef4b2d789cc998a172df4973412c4a8eb04d658e6366ba669cbe
|
data/.rubocop.yml
CHANGED
@@ -39,7 +39,6 @@ RSpec/FilePath:
|
|
39
39
|
RSpecEmptyLineAfterLet: rspec_empty_line_after_let
|
40
40
|
RSpecExamplesInSameGroup: rspec_examples_in_same_group
|
41
41
|
RSpecMemoizedHelperBlockDelimiter: rspec_memoized_helper_block_delimiter
|
42
|
-
RSpecRailsResponseParsedBody: rspec_rails_response_parsed_body
|
43
42
|
|
44
43
|
RSpec/MultipleExpectations:
|
45
44
|
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,68 +1,71 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sevencop (0.
|
4
|
+
sevencop (0.34.0)
|
5
5
|
activesupport
|
6
6
|
rubocop
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (7.0.4)
|
11
|
+
activesupport (7.0.4.3)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 1.6, < 2)
|
14
14
|
minitest (>= 5.1)
|
15
15
|
tzinfo (~> 2.0)
|
16
16
|
ast (2.4.2)
|
17
|
-
concurrent-ruby (1.
|
17
|
+
concurrent-ruby (1.2.2)
|
18
18
|
diff-lcs (1.5.0)
|
19
|
-
i18n (1.
|
19
|
+
i18n (1.13.0)
|
20
20
|
concurrent-ruby (~> 1.0)
|
21
|
-
json (2.6.
|
22
|
-
minitest (5.
|
21
|
+
json (2.6.3)
|
22
|
+
minitest (5.18.0)
|
23
23
|
parallel (1.22.1)
|
24
|
-
parser (3.
|
24
|
+
parser (3.2.0.0)
|
25
25
|
ast (~> 2.4.1)
|
26
26
|
rainbow (3.1.1)
|
27
27
|
rake (13.0.6)
|
28
|
-
regexp_parser (2.
|
28
|
+
regexp_parser (2.7.0)
|
29
29
|
rexml (3.2.5)
|
30
30
|
rspec (3.12.0)
|
31
31
|
rspec-core (~> 3.12.0)
|
32
32
|
rspec-expectations (~> 3.12.0)
|
33
33
|
rspec-mocks (~> 3.12.0)
|
34
|
-
rspec-core (3.12.
|
34
|
+
rspec-core (3.12.1)
|
35
35
|
rspec-support (~> 3.12.0)
|
36
|
-
rspec-expectations (3.12.
|
36
|
+
rspec-expectations (3.12.2)
|
37
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
38
|
rspec-support (~> 3.12.0)
|
39
|
-
rspec-mocks (3.12.
|
39
|
+
rspec-mocks (3.12.3)
|
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.
|
43
|
+
rubocop (1.45.1)
|
44
44
|
json (~> 2.3)
|
45
45
|
parallel (~> 1.10)
|
46
|
-
parser (>= 3.
|
46
|
+
parser (>= 3.2.0.0)
|
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.
|
50
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
51
51
|
ruby-progressbar (~> 1.7)
|
52
|
-
unicode-display_width (>=
|
53
|
-
rubocop-ast (1.
|
52
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
53
|
+
rubocop-ast (1.24.1)
|
54
54
|
parser (>= 3.1.1.0)
|
55
|
-
rubocop-
|
55
|
+
rubocop-capybara (2.17.0)
|
56
|
+
rubocop (~> 1.41)
|
57
|
+
rubocop-performance (1.16.0)
|
56
58
|
rubocop (>= 1.7.0, < 2.0)
|
57
59
|
rubocop-ast (>= 0.4.0)
|
58
60
|
rubocop-rake (0.6.0)
|
59
61
|
rubocop (~> 1.0)
|
60
|
-
rubocop-rspec (2.
|
62
|
+
rubocop-rspec (2.18.1)
|
61
63
|
rubocop (~> 1.33)
|
64
|
+
rubocop-capybara (~> 2.17)
|
62
65
|
ruby-progressbar (1.11.0)
|
63
|
-
tzinfo (2.0.
|
66
|
+
tzinfo (2.0.6)
|
64
67
|
concurrent-ruby (~> 1.0)
|
65
|
-
unicode-display_width (2.
|
68
|
+
unicode-display_width (2.4.2)
|
66
69
|
|
67
70
|
PLATFORMS
|
68
71
|
x86_64-linux
|
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/
|
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)
|
@@ -49,7 +49,6 @@ Note that all cops are `Enabled: false` by default.
|
|
49
49
|
- [Sevencop/RSpecEmptyLineAfterLet](lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb)
|
50
50
|
- [Sevencop/RSpecExamplesInSameGroup](lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb)
|
51
51
|
- [Sevencop/RSpecMemoizedHelperBlockDelimiter](lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb)
|
52
|
-
- [Sevencop/RSpecRailsResponseParsedBody](lib/rubocop/cop/sevencop/rspec_rails_response_parsed_body.rb)
|
53
52
|
|
54
53
|
## Notes
|
55
54
|
|
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/
|
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
|
-
|
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,16 +149,5 @@ 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
|
-
|
177
|
-
Sevencop/RSpecRailsResponseParsedBody:
|
178
|
-
Description: |
|
179
|
-
Prefer `response.parsed_body` to `JSON.parse(response.body)`.
|
180
|
-
Enabled: false
|
181
|
-
Safe: false
|
182
|
-
VersionAdded: '0.28'
|
183
|
-
Include:
|
184
|
-
- spec/controllers/**/*
|
185
|
-
- spec/requests/**/*
|
@@ -41,14 +41,8 @@ module RuboCop
|
|
41
41
|
|
42
42
|
add_offense(node) do |corrector|
|
43
43
|
swap(
|
44
|
-
|
45
|
-
|
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 =
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
|
@@ -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
|
@@ -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 =
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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 =
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
|
data/lib/sevencop/version.rb
CHANGED
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/
|
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'
|
@@ -25,4 +25,3 @@ require_relative 'rubocop/cop/sevencop/rspec_describe_http_endpoint'
|
|
25
25
|
require_relative 'rubocop/cop/sevencop/rspec_empty_line_after_let'
|
26
26
|
require_relative 'rubocop/cop/sevencop/rspec_examples_in_same_group'
|
27
27
|
require_relative 'rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter'
|
28
|
-
require_relative 'rubocop/cop/sevencop/rspec_rails_response_parsed_body'
|
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.
|
4
|
+
version: 0.34.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:
|
11
|
+
date: 2023-05-08 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/
|
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
|
@@ -77,7 +77,6 @@ files:
|
|
77
77
|
- lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb
|
78
78
|
- lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb
|
79
79
|
- lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb
|
80
|
-
- lib/rubocop/cop/sevencop/rspec_rails_response_parsed_body.rb
|
81
80
|
- lib/sevencop.rb
|
82
81
|
- lib/sevencop/config_loader.rb
|
83
82
|
- lib/sevencop/cop_concerns.rb
|
@@ -107,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
106
|
- !ruby/object:Gem::Version
|
108
107
|
version: '0'
|
109
108
|
requirements: []
|
110
|
-
rubygems_version: 3.3.
|
109
|
+
rubygems_version: 3.3.26
|
111
110
|
signing_key:
|
112
111
|
specification_version: 4
|
113
112
|
summary: Opinionated custom cops for RuboCop.
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Sevencop
|
6
|
-
# Prefer `response.parsed_body` to `JSON.parse(response.body)`.
|
7
|
-
#
|
8
|
-
# @safety
|
9
|
-
# This cop is unsafe because Content-Type may not be `application/json`.
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# # bad
|
13
|
-
# JSON.parse(response.body)
|
14
|
-
#
|
15
|
-
# # good
|
16
|
-
# response.parsed_body
|
17
|
-
class RSpecRailsResponseParsedBody < Base
|
18
|
-
extend AutoCorrector
|
19
|
-
|
20
|
-
MSG = 'Prefer `response.parsed_body` to `JSON.parse(response.body)`.'
|
21
|
-
|
22
|
-
RESTRICT_ON_SEND = %i[parse].freeze
|
23
|
-
|
24
|
-
# @param node [RuboCop::AST::SendNode]
|
25
|
-
# @return [void]
|
26
|
-
def on_send(node)
|
27
|
-
return unless bad?(node)
|
28
|
-
|
29
|
-
add_offense(node) do |corrector|
|
30
|
-
autocorrect(corrector, node)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
# @!method json_parse_response_body?(node)
|
37
|
-
# @param node [RuboCop::AST::Node]
|
38
|
-
# @return [Boolean]
|
39
|
-
def_node_matcher :json_parse_response_body?, <<~PATTERN
|
40
|
-
(send
|
41
|
-
(const
|
42
|
-
{nil? cbase}
|
43
|
-
:JSON
|
44
|
-
)
|
45
|
-
:parse
|
46
|
-
(send
|
47
|
-
(send
|
48
|
-
nil?
|
49
|
-
:response
|
50
|
-
)
|
51
|
-
:body
|
52
|
-
)
|
53
|
-
)
|
54
|
-
PATTERN
|
55
|
-
alias bad? json_parse_response_body?
|
56
|
-
|
57
|
-
# @param corrector [RuboCop::Cop::Corrector]
|
58
|
-
# @param node [RuboCop::AST::SendNode]
|
59
|
-
# @return [void]
|
60
|
-
def autocorrect(
|
61
|
-
corrector,
|
62
|
-
node
|
63
|
-
)
|
64
|
-
corrector.replace(node, 'response.parsed_body')
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|