workitcop 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/config/default.yml +7 -5
- data/lib/rubocop/cop/workit/comittee_assert_schema_confirm.rb +49 -0
- data/lib/rubocop/cop/workit/restrict_on_send.rb +3 -1
- data/lib/workitcop/version.rb +1 -1
- data/lib/workitcop.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9a1c429544b92ec47ac6a467cef8d26a1bea4c43371299d323441636b0ecbfc
|
4
|
+
data.tar.gz: 255c41e5e4995120ebea4370b3ef9e3a95773614d580b719c17041eec1883df9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6513c422e88c53f8287f61fbfeedf160232340bebeea000ebfd2389b6d92b6ffa4b4a657d1a6fff5072281b09ebbc413ace375de128eb686605956dd56b4a869
|
7
|
+
data.tar.gz: 5ea74291617530ff065df00d6ecbd3c9a5f339feb446417fae198667249e746f137424028158df6fe4ad91d364dcf6af10fc71725df7e33513e82688afdd5e50
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.3.0 - 2022-12-08
|
6
|
+
|
7
|
+
- Fix an error for `Workit/RestrictOnSend` when not in class. ([@ydah])
|
8
|
+
- Add new `Workit/ComitteeAssertSchemaConfirm` cop. ([@ydah])
|
9
|
+
- Remove VersionAdded for default.yml. ([@ydah])
|
10
|
+
- Change default to `Enabled: false`. ([@ydah])
|
11
|
+
|
5
12
|
## 0.2.0 - 2022-11-07
|
6
13
|
|
7
14
|
- Add new `Workit/ActionArgs` cop. ([@ydah])
|
data/config/default.yml
CHANGED
@@ -6,8 +6,7 @@ inherit_mode:
|
|
6
6
|
Workit/ActionArgs:
|
7
7
|
Description: |
|
8
8
|
Check for controller action must be using `action_args`.
|
9
|
-
Enabled:
|
10
|
-
VersionAdded: '0.2'
|
9
|
+
Enabled: false
|
11
10
|
Include:
|
12
11
|
- 'controllers/**/*'
|
13
12
|
ControllerMethods:
|
@@ -18,13 +17,16 @@ Workit/ActionArgs:
|
|
18
17
|
- cancel
|
19
18
|
- destroy
|
20
19
|
|
20
|
+
Workit/ComitteeAssertSchemaConfirm:
|
21
|
+
Description: |
|
22
|
+
Check for not pass expected response status code to check it against the corresponding schema explicitly.
|
23
|
+
Enabled: false
|
24
|
+
|
21
25
|
Workit/NoopRescue:
|
22
26
|
Description: 'Check for suppress or ignore checked exception.'
|
23
27
|
Enabled: false
|
24
|
-
VersionAdded: '0.2'
|
25
28
|
|
26
29
|
Workit/RestrictOnSend:
|
27
30
|
Description: |
|
28
31
|
Check for `RESTRICT_ON_SEND` is defined if `on_send` or `after_send` are defined.
|
29
|
-
Enabled:
|
30
|
-
VersionAdded: '0.1'
|
32
|
+
Enabled: false
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Workit
|
6
|
+
# Check for not pass expected response status code to check it against the corresponding schema explicitly.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # bad
|
10
|
+
# it 'something' do
|
11
|
+
# subject
|
12
|
+
# expect(response).to have_http_status 400
|
13
|
+
# do_something
|
14
|
+
# assert_schema_conform
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# # good
|
18
|
+
# it 'something' do
|
19
|
+
# subject
|
20
|
+
# do_something
|
21
|
+
# assert_schema_conform(400)
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
class ComitteeAssertSchemaConfirm < Base
|
25
|
+
include RangeHelp
|
26
|
+
extend AutoCorrector
|
27
|
+
|
28
|
+
MSG = "Pass expected response status code to check it against the corresponding schema explicitly."
|
29
|
+
RESTRICT_ON_SEND = %i[assert_schema_conform assert_response_schema_confirm].freeze
|
30
|
+
|
31
|
+
# @!method have_http_status(node)
|
32
|
+
def_node_search :have_http_status, <<~PATTERN
|
33
|
+
$(send nil? :have_http_status (:int $_))
|
34
|
+
PATTERN
|
35
|
+
|
36
|
+
def on_send(node)
|
37
|
+
return if node.arguments?
|
38
|
+
|
39
|
+
have_http_status(node.parent) do |child_node, value|
|
40
|
+
add_offense(node) do |corrector|
|
41
|
+
corrector.remove(range_by_whole_lines(child_node.parent.loc.expression, include_final_newline: true))
|
42
|
+
corrector.insert_after(node, "(#{value})")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -30,12 +30,14 @@ module RuboCop
|
|
30
30
|
|
31
31
|
def on_def(node)
|
32
32
|
return unless NEED_RESTRICT_ON_SEND.include?(node.method_name)
|
33
|
+
return unless (class_node = class_node(node))
|
33
34
|
|
34
|
-
class_node = class_node(node)
|
35
35
|
add_offense(class_node) unless defined_restrict_on_send?(class_node)
|
36
36
|
end
|
37
37
|
|
38
38
|
def class_node(node)
|
39
|
+
return if node.parent.nil?
|
40
|
+
|
39
41
|
if node.parent.class_type?
|
40
42
|
node.parent
|
41
43
|
else
|
data/lib/workitcop/version.rb
CHANGED
data/lib/workitcop.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative "workitcop/inject"
|
|
4
4
|
require_relative "workitcop/version"
|
5
5
|
|
6
6
|
require_relative "rubocop/cop/workit/action_args"
|
7
|
+
require_relative "rubocop/cop/workit/comittee_assert_schema_confirm"
|
7
8
|
require_relative "rubocop/cop/workit/noop_rescue"
|
8
9
|
require_relative "rubocop/cop/workit/restrict_on_send"
|
9
10
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workitcop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ydah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- README.md
|
40
40
|
- config/default.yml
|
41
41
|
- lib/rubocop/cop/workit/action_args.rb
|
42
|
+
- lib/rubocop/cop/workit/comittee_assert_schema_confirm.rb
|
42
43
|
- lib/rubocop/cop/workit/noop_rescue.rb
|
43
44
|
- lib/rubocop/cop/workit/restrict_on_send.rb
|
44
45
|
- lib/workitcop.rb
|
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '0'
|
69
70
|
requirements: []
|
70
|
-
rubygems_version: 3.
|
71
|
+
rubygems_version: 3.3.3
|
71
72
|
signing_key:
|
72
73
|
specification_version: 4
|
73
74
|
summary: Custom cops for `RuboCop`.
|