rt_rubocop_defaults 2.7.1 → 2.8.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: 11489ab87e42886abe3ec639b325ae09565d9c02604bb71add836f7a940d58c6
4
- data.tar.gz: aa948688f3aa934a7306fbf61fd0b9014c129cedf98e9488e039e9ca66b01482
3
+ metadata.gz: f63a1da86e4b5eb679400632e400c4cbf243696cc7bbc70966c699c7b9277181
4
+ data.tar.gz: d53cf09810e47e2747bd5939e011331debe7e70d3f1fd9105a5077f764b54a9e
5
5
  SHA512:
6
- metadata.gz: 776ab8550a8e773616a1958ba47557b66c4b3f1b2f0f92a00934570f365d5ad5bc186772a3e19276991187792a27b9dbee7a30d46dc86d39a3555141437cd54f
7
- data.tar.gz: c060997be8f1c5e0087502962000dea349b5fd72d169ece525e9ce808885b27c742a110334b738c8072cd49198970501b163acece977e232ac4f1c4c7868a0ca
6
+ metadata.gz: 71f634a74709be61b9acca582b74a87150394b184cfd0d729fdfd64eb6b66b2d740678edb39eab70cf85ab29c81fb0e870663fbaa34d68f825e002e97fbbb118
7
+ data.tar.gz: 7b231c67e17bb9825e6ab19ffd586593d3ac9272173e72cf12bb6fb763a5aae04d1d83670aa3ed620e6a2ca5d4c66ba3d1af1850bf3282e2b6bee9647ed3dab6
data/config/default.yml CHANGED
@@ -208,3 +208,8 @@ RSpec/Rails/HaveHttpStatus:
208
208
  # New cop name
209
209
  RSpecRails/HaveHttpStatus:
210
210
  Enabled: false
211
+
212
+ RSpec/UnexpectedRequires:
213
+ Description: Check that rspec files do not contain requires.
214
+ Enabled: true
215
+ VersionAdded: "2.8.0"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RTRuboCopDefaults
4
- VERSION = "2.7.1"
4
+ VERSION = "2.8.1"
5
5
  end
@@ -4,3 +4,5 @@ require "rt_rubocop_defaults/version"
4
4
  require "rt_rubocop_defaults/inject"
5
5
 
6
6
  RTRuboCopDefaults::Inject.defaults!
7
+
8
+ require "rubocop/cop/rspec/unexpected_requires"
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module RSpec
6
+ # Checks that rspec files do not contain requires.
7
+ #
8
+ # As this can lead to unexpected behavior
9
+ # later when the code is not used with rspec.
10
+ #
11
+ # Require the necessary files in the projects config or
12
+ # where you need it instead.
13
+ #
14
+ # @example
15
+ # # bad
16
+ # require "lib/use_cases/my_work"
17
+ #
18
+ # describe UseCases::MyWork do
19
+ #
20
+ # end
21
+ #
22
+ # # good
23
+ # describe UseCases::MyWork do
24
+ #
25
+ # end
26
+ #
27
+ class UnexpectedRequires < Base
28
+ MSG = 'Do not require anything in a test file.'
29
+
30
+ IGNORED_PATTERN = /(spec|rails)_helper/
31
+
32
+ def_node_matcher :require_symbol?, <<~PATTERN
33
+ (send #rspec? :require $_ ...)
34
+ PATTERN
35
+
36
+ def on_new_investigation
37
+ @ignore_file = processed_source.path.match?(IGNORED_PATTERN)
38
+ end
39
+
40
+ def on_send(node)
41
+ return if @ignore_file
42
+
43
+ require_symbol?(node) do |match|
44
+ next if match.respond_to?(:value) &&
45
+ match.value.match?(IGNORED_PATTERN)
46
+
47
+ add_offense(node, message: MSG)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -25,4 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.metadata["rubygems_mfa_required"] = "true"
26
26
 
27
27
  spec.add_dependency "rubocop", "~> 1.61"
28
+ # HINT: Needed as long as the `RSpec::UnexpectedRequires` cop is part of this repo
29
+ spec.add_dependency "rubocop-rspec", "~> 3.1"
28
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rt_rubocop_defaults
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Eger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-18 00:00:00.000000000 Z
11
+ date: 2024-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.61'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.1'
27
41
  description: rubocop defaults used at runtastic
28
42
  email:
29
43
  - andreas.eger@runtastic.com
@@ -42,6 +56,7 @@ files:
42
56
  - lib/rt_rubocop_defaults.rb
43
57
  - lib/rt_rubocop_defaults/inject.rb
44
58
  - lib/rt_rubocop_defaults/version.rb
59
+ - lib/rubocop/cop/rspec/unexpected_requires.rb
45
60
  - rt_rubocop_defaults.gemspec
46
61
  homepage: https://github.com/runtastic/rt_rubocop_defaults
47
62
  licenses: