sevencop 0.33.0 → 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 +0 -1
- data/config/default.yml +0 -9
- data/lib/sevencop/rubocop_extension.rb +1 -1
- data/lib/sevencop/version.rb +1 -1
- data/lib/sevencop.rb +0 -1
- metadata +2 -3
- 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
@@ -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
@@ -151,12 +151,3 @@ Sevencop/RSpecMemoizedHelperBlockDelimiter:
|
|
151
151
|
Enabled: false
|
152
152
|
Include:
|
153
153
|
- spec/**/*
|
154
|
-
|
155
|
-
Sevencop/RSpecRailsResponseParsedBody:
|
156
|
-
Description: |
|
157
|
-
Prefer `response.parsed_body` to `JSON.parse(response.body)`.
|
158
|
-
Enabled: false
|
159
|
-
Safe: false
|
160
|
-
Include:
|
161
|
-
- spec/controllers/**/*
|
162
|
-
- spec/requests/**/*
|
data/lib/sevencop/version.rb
CHANGED
data/lib/sevencop.rb
CHANGED
@@ -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
|
@@ -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
|
@@ -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
|