sevencop 0.44.0 → 0.46.0
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 +4 -4
- data/.rubocop.yml +4 -0
- data/Gemfile.lock +8 -6
- data/README.md +2 -0
- data/config/default.yml +16 -0
- data/lib/rubocop/cop/sevencop/bundler_gem_group_ordered.rb +87 -0
- data/lib/rubocop/cop/sevencop/rspec_pending_only_example_group.rb +40 -0
- data/lib/sevencop/version.rb +1 -1
- data/lib/sevencop.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f3da941ce26e523263ae349b642de04f08c6fafb25c65ee87a1552700336a59
|
4
|
+
data.tar.gz: 57c17da50da92c2fc735ea23b1acaf216885069afc651a14386a288ce93f400c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5b76d4613a1d575720c9aa07cc3253608ef19cd0cf9e7c25fedebbb8355d0af46a2701b3282147b4058646b4ef9123f7c39b34eb217a53cadd93a6947556fea
|
7
|
+
data.tar.gz: 139c3d03d5ed0441d78564bbe21e7037273bab082e72c47c530e631869f4654fbc070b31a6d82a194c76f98a27ac5c8db5170993a584bec0f4a0f87656c7e4f0
|
data/.rubocop.yml
CHANGED
@@ -43,12 +43,16 @@ RSpec/SpecFilePathFormat:
|
|
43
43
|
RSpecExamplesInSameGroup: rspec_examples_in_same_group
|
44
44
|
RSpecMatcherConsistentParentheses: rspec_matcher_consistent_parentheses
|
45
45
|
RSpecMemoizedHelperBlockDelimiter: rspec_memoized_helper_block_delimiter
|
46
|
+
RSpecPendingOnlyExampleGroup: rspec_pending_only_example_group
|
46
47
|
RSpecRailsHaveHttpStatus: rspec_rails_have_http_status
|
47
48
|
RSpecRailsStatusCodeCheckBySubject: rspec_rails_status_code_check_by_subject
|
48
49
|
|
49
50
|
Sevencop/AutoloadOrdered:
|
50
51
|
Enabled: true
|
51
52
|
|
53
|
+
Sevencop/BundlerGemGroupOrdered:
|
54
|
+
Enabled: true
|
55
|
+
|
52
56
|
Sevencop/HashElementOrdered:
|
53
57
|
Enabled: true
|
54
58
|
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sevencop (0.
|
4
|
+
sevencop (0.46.0)
|
5
5
|
activesupport
|
6
6
|
rubocop
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (7.2.
|
11
|
+
activesupport (7.2.2)
|
12
12
|
base64
|
13
|
+
benchmark (>= 0.3)
|
13
14
|
bigdecimal
|
14
15
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
15
16
|
connection_pool (>= 2.2.5)
|
@@ -21,17 +22,18 @@ GEM
|
|
21
22
|
tzinfo (~> 2.0, >= 2.0.5)
|
22
23
|
ast (2.4.2)
|
23
24
|
base64 (0.2.0)
|
25
|
+
benchmark (0.4.0)
|
24
26
|
bigdecimal (3.1.8)
|
25
27
|
concurrent-ruby (1.3.4)
|
26
28
|
connection_pool (2.4.1)
|
27
29
|
diff-lcs (1.5.1)
|
28
30
|
drb (2.2.1)
|
29
|
-
i18n (1.14.
|
31
|
+
i18n (1.14.6)
|
30
32
|
concurrent-ruby (~> 1.0)
|
31
33
|
json (2.7.2)
|
32
34
|
language_server-protocol (3.17.0.3)
|
33
|
-
logger (1.6.
|
34
|
-
minitest (5.25.
|
35
|
+
logger (1.6.2)
|
36
|
+
minitest (5.25.2)
|
35
37
|
parallel (1.26.3)
|
36
38
|
parser (3.3.5.0)
|
37
39
|
ast (~> 2.4.1)
|
@@ -73,7 +75,7 @@ GEM
|
|
73
75
|
rubocop-rspec (3.0.4)
|
74
76
|
rubocop (~> 1.61)
|
75
77
|
ruby-progressbar (1.13.0)
|
76
|
-
securerandom (0.
|
78
|
+
securerandom (0.4.0)
|
77
79
|
tzinfo (2.0.6)
|
78
80
|
concurrent-ruby (~> 1.0)
|
79
81
|
unicode-display_width (2.5.0)
|
data/README.md
CHANGED
@@ -29,6 +29,7 @@ Note that all cops are `Enabled: false` by default.
|
|
29
29
|
## Cops
|
30
30
|
|
31
31
|
- [Sevencop/AutoloadOrdered](lib/rubocop/cop/sevencop/autoload_ordered.rb)
|
32
|
+
- [Sevencop/BundlerGemGroupOrdered](lib/rubocop/cop/sevencop/bundler_gem_group_ordered.rb)
|
32
33
|
- [Sevencop/HashElementOrdered](lib/rubocop/cop/sevencop/hash_element_ordered.rb)
|
33
34
|
- [Sevencop/MapMethodChain](lib/rubocop/cop/sevencop/map_method_chain.rb)
|
34
35
|
- [Sevencop/MethodDefinitionArgumentsMultiline](lib/rubocop/cop/sevencop/method_definition_arguments_multiline.rb)
|
@@ -49,6 +50,7 @@ Note that all cops are `Enabled: false` by default.
|
|
49
50
|
- [Sevencop/RSpecExamplesInSameGroup](lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb)
|
50
51
|
- [Sevencop/RSpecMatcherConsistentParentheses](lib/rubocop/cop/sevencop/rspec_matcher_consistent_parentheses.rb)
|
51
52
|
- [Sevencop/RSpecMemoizedHelperBlockDelimiter](lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb)
|
53
|
+
- [Sevencop/RSpecPendingOnlyExampleGroup](lib/rubocop/cop/sevencop/rspec_pending_only_example_group.rb)
|
52
54
|
- [Sevencop/RSpecRailsHaveHttpStatus](lib/rubocop/cop/sevencop/rspec_rails_have_http_status.rb)
|
53
55
|
- [Sevencop/RSpecRailsStatusCodeCheckBySubject](lib/rubocop/cop/sevencop/rspec_rails_status_code_check_by_subject.rb)
|
54
56
|
|
data/config/default.yml
CHANGED
@@ -4,6 +4,16 @@ Sevencop/AutoloadOrdered:
|
|
4
4
|
Enabled: false
|
5
5
|
Safe: false
|
6
6
|
|
7
|
+
Sevencop/BundlerGemGroupOrdered:
|
8
|
+
Description: |
|
9
|
+
Sort `group` in alphabetical order.
|
10
|
+
Enabled: false
|
11
|
+
Safe: false
|
12
|
+
Include:
|
13
|
+
- '**/*.gemfile'
|
14
|
+
- '**/Gemfile'
|
15
|
+
- '**/gems.rb'
|
16
|
+
|
7
17
|
Sevencop/HashElementOrdered:
|
8
18
|
Description: |
|
9
19
|
Sort Hash elements by key.
|
@@ -142,6 +152,12 @@ Sevencop/RSpecMemoizedHelperBlockDelimiter:
|
|
142
152
|
Include:
|
143
153
|
- "**/spec/**/*.rb"
|
144
154
|
|
155
|
+
Sevencop/RSpecPendingOnlyExampleGroup:
|
156
|
+
Description: Remove pending-only test files.
|
157
|
+
Enabled: false
|
158
|
+
Include:
|
159
|
+
- "**/spec/**/*.rb"
|
160
|
+
|
145
161
|
Sevencop/RSpecRailsHaveHttpStatus:
|
146
162
|
Description: |
|
147
163
|
Always check status code with `have_http_status`.
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Sevencop
|
6
|
+
# Sort `group` in alphabetical order.
|
7
|
+
#
|
8
|
+
# Note that the sort key is computed from the sorted and concatenated `group` arguments.
|
9
|
+
# For example, the sort key for `group :test, :development` is `development-test`.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# # bad
|
13
|
+
# group :test do
|
14
|
+
# gem 'rspec'
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# group :development do
|
18
|
+
# gem 'better_errors'
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# # good
|
22
|
+
# group :development do
|
23
|
+
# gem 'better_errors'
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# group :test do
|
27
|
+
# gem 'rspec'
|
28
|
+
# end
|
29
|
+
class BundlerGemGroupOrdered < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
include ::Sevencop::CopConcerns::Ordered
|
35
|
+
|
36
|
+
MSG = 'Sort `group` in alphabetical order.'
|
37
|
+
|
38
|
+
RESTRICT_ON_SEND = %i[
|
39
|
+
group
|
40
|
+
].freeze
|
41
|
+
|
42
|
+
# @param [RuboCop::AST::SendNode] node
|
43
|
+
# @return [void]
|
44
|
+
def on_send(node)
|
45
|
+
block_node = node.block_node
|
46
|
+
return unless block_node
|
47
|
+
|
48
|
+
previous_older_sibling = find_previous_older_sibling(block_node)
|
49
|
+
return unless previous_older_sibling
|
50
|
+
|
51
|
+
add_offense(block_node) do |corrector|
|
52
|
+
corrector.swap(
|
53
|
+
range_with_comments_and_lines(previous_older_sibling),
|
54
|
+
range_with_comments_and_lines(block_node)
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
# @param [RuboCop::AST::BlockNode] node
|
62
|
+
# @return [String, nil]
|
63
|
+
def calculate_sort_key(node)
|
64
|
+
return unless node.send_node.arguments.all? { |argument| argument.respond_to?(:value) }
|
65
|
+
|
66
|
+
node.send_node.arguments.map(&:value).sort.join('-')
|
67
|
+
end
|
68
|
+
|
69
|
+
# @param [RuboCop::AST::BlockNode] node
|
70
|
+
# @return [RuboCop::AST::BlockNode, nil]
|
71
|
+
def find_previous_older_sibling(node)
|
72
|
+
node.left_siblings.grep(::RuboCop::AST::Node).reverse.find do |sibling|
|
73
|
+
break unless sibling.block_type?
|
74
|
+
break unless sibling.method?(:group)
|
75
|
+
|
76
|
+
current_sort_key = calculate_sort_key(node)
|
77
|
+
sibling_sort_key = calculate_sort_key(sibling)
|
78
|
+
break unless current_sort_key
|
79
|
+
break unless sibling_sort_key
|
80
|
+
|
81
|
+
calculate_sort_key(node) < calculate_sort_key(sibling)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Sevencop
|
6
|
+
# Remove pending-only test files.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # bad
|
10
|
+
# RSpec.describe Post do
|
11
|
+
# pending "add some examples to (or delete) #{__FILE__}"
|
12
|
+
# end
|
13
|
+
class RSpecPendingOnlyExampleGroup < ::RuboCop::Cop::Base
|
14
|
+
MSG = 'Remove pending-only test files.'
|
15
|
+
|
16
|
+
RESTRICT_ON_SEND = %i[
|
17
|
+
describe
|
18
|
+
].freeze
|
19
|
+
|
20
|
+
def on_send(node)
|
21
|
+
block_node = node.parent
|
22
|
+
return unless pending_only_example_group?(block_node)
|
23
|
+
|
24
|
+
add_offense(block_node)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# @!method pending_only_example_group?(node)
|
30
|
+
def_node_matcher :pending_only_example_group?, <<~PATTERN
|
31
|
+
(block
|
32
|
+
(send (const nil? :RSpec) :describe ...)
|
33
|
+
(args)
|
34
|
+
(send nil? :pending ...)
|
35
|
+
)
|
36
|
+
PATTERN
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/sevencop/version.rb
CHANGED
data/lib/sevencop.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative 'sevencop/rubocop_extension'
|
|
5
5
|
require_relative 'sevencop/version'
|
6
6
|
|
7
7
|
require_relative 'rubocop/cop/sevencop/autoload_ordered'
|
8
|
+
require_relative 'rubocop/cop/sevencop/bundler_gem_group_ordered'
|
8
9
|
require_relative 'rubocop/cop/sevencop/hash_element_ordered'
|
9
10
|
require_relative 'rubocop/cop/sevencop/map_method_chain'
|
10
11
|
require_relative 'rubocop/cop/sevencop/method_definition_arguments_multiline'
|
@@ -25,5 +26,6 @@ require_relative 'rubocop/cop/sevencop/rspec_empty_line_after_let'
|
|
25
26
|
require_relative 'rubocop/cop/sevencop/rspec_examples_in_same_group'
|
26
27
|
require_relative 'rubocop/cop/sevencop/rspec_matcher_consistent_parentheses'
|
27
28
|
require_relative 'rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter'
|
29
|
+
require_relative 'rubocop/cop/sevencop/rspec_pending_only_example_group'
|
28
30
|
require_relative 'rubocop/cop/sevencop/rspec_rails_have_http_status'
|
29
31
|
require_relative 'rubocop/cop/sevencop/rspec_rails_status_code_check_by_subject'
|
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.46.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: 2024-
|
11
|
+
date: 2024-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- config/default.yml
|
58
58
|
- data/reserved_words_mysql.txt
|
59
59
|
- lib/rubocop/cop/sevencop/autoload_ordered.rb
|
60
|
+
- lib/rubocop/cop/sevencop/bundler_gem_group_ordered.rb
|
60
61
|
- lib/rubocop/cop/sevencop/hash_element_ordered.rb
|
61
62
|
- lib/rubocop/cop/sevencop/map_method_chain.rb
|
62
63
|
- lib/rubocop/cop/sevencop/method_definition_arguments_multiline.rb
|
@@ -77,6 +78,7 @@ files:
|
|
77
78
|
- lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb
|
78
79
|
- lib/rubocop/cop/sevencop/rspec_matcher_consistent_parentheses.rb
|
79
80
|
- lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb
|
81
|
+
- lib/rubocop/cop/sevencop/rspec_pending_only_example_group.rb
|
80
82
|
- lib/rubocop/cop/sevencop/rspec_rails_have_http_status.rb
|
81
83
|
- lib/rubocop/cop/sevencop/rspec_rails_status_code_check_by_subject.rb
|
82
84
|
- lib/sevencop.rb
|