sevencop 0.16.0 → 0.17.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c55fa975db18f38f073127cff1b736321d599328040959966ca3c7ee68e576f4
4
- data.tar.gz: a976b6455cf9083a81dca72c0ecd2b7df79e963ca1fd49124d6c756799975ee3
3
+ metadata.gz: 822706ee0729871b2da9cb6fdc7de31d891a53bfb5aa633c55cdb862b2689e36
4
+ data.tar.gz: 326bb123620fed30e14cab5ac033228b1cddd9a3ace6b06efccb4cca24534658
5
5
  SHA512:
6
- metadata.gz: 8f9f873aead1ae719deb96b16f46850fb8daa55a81dbb7709f548352b624bffdb34f639176f5580bbc25bd279c8acd679b175b0a9755c89260c23ef303975a18
7
- data.tar.gz: 43e716bfb540bfa7a607aeefae2bef61334518b636d277fcff4155af7145734d17f6eec10494a72b09e40b3d6736175f28b84db18091f89dad4c179bd5479320
6
+ metadata.gz: 0dc0f7ac09c0262566fb15f2d397a546b54c80f56e933350a00e2e1c96b3cc5d0d04249350ac2f837ea83057d0308b241c54b236670eb384c43968bde8d9e28d
7
+ data.tar.gz: 064e3454888d29fb35f585b30f58609d01db1ed5da17ecf50c8ebb2ec309b111d769ee2a2cacae7d3988c48a49cc46d303df87a66a93def0b44dd1227141d037
data/.rubocop.yml CHANGED
@@ -10,6 +10,9 @@ AllCops:
10
10
  SuggestExtensions: false
11
11
  TargetRubyVersion: 2.6
12
12
 
13
+ Gemspec/RequireMFA:
14
+ Enabled: false
15
+
13
16
  Metrics:
14
17
  Enabled: false
15
18
 
@@ -23,6 +26,10 @@ RSpec:
23
26
  RSpec/ExampleLength:
24
27
  Enabled: false
25
28
 
29
+ RSpec/FilePath:
30
+ CustomTransform:
31
+ RSpecExamplesInSameGroup: rspec_examples_in_same_group
32
+
26
33
  RSpec/MultipleExpectations:
27
34
  Enabled: false
28
35
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sevencop (0.16.0)
4
+ sevencop (0.17.1)
5
5
  rubocop
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -39,5 +39,6 @@ Choose the cops you want to use and enable them on your .rubocop.yml.
39
39
  - [Sevencop/RailsUniquenessValidatorExplicitCaseSensitivity](lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb)
40
40
  - [Sevencop/RailsWhereNot](lib/rubocop/cop/sevencop/rails_where_not.rb)
41
41
  - [Sevencop/RequireOrdered](lib/rubocop/cop/sevencop/require_ordered.rb)
42
+ - [Sevencop/RSpecExamplesInSameGroup](lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb)
42
43
 
43
44
  Note that all cops are `Enabled: false` by default.
data/config/default.yml CHANGED
@@ -67,3 +67,12 @@ Sevencop/RequireOrdered:
67
67
  Sort `require` and `require_relative` in alphabetical order.
68
68
  Enabled: false
69
69
  VersionAdded: '0.16'
70
+
71
+ Sevencop/RSpecExamplesInSameGroup:
72
+ Description: |
73
+ Combine examples in the same groups in the time-consuming kinds of specs.
74
+ Enabled: false
75
+ VersionAdded: '0.17'
76
+ Include:
77
+ - spec/controllers/**/*
78
+ - spec/requests/**/*
@@ -15,6 +15,7 @@ module RuboCop
15
15
  # a,
16
16
  # b
17
17
  # )
18
+ # end
18
19
  #
19
20
  # # good
20
21
  # def foo(a)
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Sevencop
6
+ # Combine examples in same group in the time-consuming kinds of specs.
7
+ #
8
+ # @example
9
+ #
10
+ # # bad
11
+ # context 'when user is logged in' do
12
+ # it 'returns 200' do
13
+ # subject
14
+ # expect(response).to have_http_status(200)
15
+ # end
16
+ #
17
+ # it 'creates Foo' do
18
+ # expect { subject }.to change(Foo, :count).by(1)
19
+ # end
20
+ # end
21
+ #
22
+ # # good
23
+ # context 'when user is logged in' do
24
+ # it 'creates Foo and returns 200' do
25
+ # expect { subject }.to change(Foo, :count).by(1)
26
+ # expect(response).to have_http_status(200)
27
+ # end
28
+ # end
29
+ #
30
+ class RSpecExamplesInSameGroup < Base
31
+ EXAMPLE_METHOD_NAMES_REGULAR = ::Set[
32
+ :it,
33
+ :its,
34
+ :specify,
35
+ :example,
36
+ :scenario,
37
+ ].freeze
38
+
39
+ MSG = 'Combine examples in the same group in the time-consuming kinds of specs.'
40
+
41
+ # @param node [RuboCop::AST::BlockNode]
42
+ # @return [void]
43
+ def on_block(node)
44
+ return unless example?(node)
45
+
46
+ previous_sibling_example = previous_sibling_example_of(node)
47
+ return unless previous_sibling_example
48
+
49
+ add_offense(node)
50
+ end
51
+ alias on_numblock on_block
52
+
53
+ private
54
+
55
+ # @!method example?(node)
56
+ # @param node [RuboCop::AST::Node]
57
+ # @return [Boolean]
58
+ def_node_matcher :example?, <<~PATTERN
59
+ (block
60
+ (send nil? EXAMPLE_METHOD_NAMES_REGULAR ...)
61
+ ...
62
+ )
63
+ PATTERN
64
+
65
+ # @param node [RuboCop::AST::BlockNode]
66
+ # @return [RuboCop::AST::BlockNode, nil]
67
+ def previous_sibling_example_of(node)
68
+ node.left_siblings.find do |sibling|
69
+ sibling.is_a?(::RuboCop::AST::Node) && example?(sibling)
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sevencop
4
- VERSION = '0.16.0'
4
+ VERSION = '0.17.1'
5
5
  end
data/lib/sevencop.rb CHANGED
@@ -15,3 +15,4 @@ require_relative 'rubocop/cop/sevencop/rails_order_field'
15
15
  require_relative 'rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity'
16
16
  require_relative 'rubocop/cop/sevencop/rails_where_not'
17
17
  require_relative 'rubocop/cop/sevencop/require_ordered'
18
+ require_relative 'rubocop/cop/sevencop/rspec_examples_in_same_group'
data/sevencop.gemspec CHANGED
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata['homepage_uri'] = spec.homepage
17
17
  spec.metadata['source_code_uri'] = spec.homepage
18
18
  spec.metadata['changelog_uri'] = "#{spec.homepage}/releases"
19
- spec.metadata['rubygems_mfa_required'] = 'true'
20
19
 
21
20
  # Specify which files should be added to the gem when it is released.
22
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
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.16.0
4
+ version: 0.17.1
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-09-30 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -52,6 +52,7 @@ files:
52
52
  - lib/rubocop/cop/sevencop/rails_uniqueness_validator_explicit_case_sensitivity.rb
53
53
  - lib/rubocop/cop/sevencop/rails_where_not.rb
54
54
  - lib/rubocop/cop/sevencop/require_ordered.rb
55
+ - lib/rubocop/cop/sevencop/rspec_examples_in_same_group.rb
55
56
  - lib/sevencop.rb
56
57
  - lib/sevencop/config_loader.rb
57
58
  - lib/sevencop/cop_concerns.rb
@@ -66,7 +67,6 @@ metadata:
66
67
  homepage_uri: https://github.com/r7kamura/sevencop
67
68
  source_code_uri: https://github.com/r7kamura/sevencop
68
69
  changelog_uri: https://github.com/r7kamura/sevencop/releases
69
- rubygems_mfa_required: 'true'
70
70
  post_install_message:
71
71
  rdoc_options: []
72
72
  require_paths: