rt_rubocop_defaults 2.7.1 → 2.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11489ab87e42886abe3ec639b325ae09565d9c02604bb71add836f7a940d58c6
4
- data.tar.gz: aa948688f3aa934a7306fbf61fd0b9014c129cedf98e9488e039e9ca66b01482
3
+ metadata.gz: 8222f836d95f9d35647d6875b30347491754bf9b5fd704868246c7ef8b91684b
4
+ data.tar.gz: f3d6c565037f1afcde1b03005637243c9b39ca6b3e513b32dfdec4638561ac63
5
5
  SHA512:
6
- metadata.gz: 776ab8550a8e773616a1958ba47557b66c4b3f1b2f0f92a00934570f365d5ad5bc186772a3e19276991187792a27b9dbee7a30d46dc86d39a3555141437cd54f
7
- data.tar.gz: c060997be8f1c5e0087502962000dea349b5fd72d169ece525e9ce808885b27c742a110334b738c8072cd49198970501b163acece977e232ac4f1c4c7868a0ca
6
+ metadata.gz: ca74896b5e1f47bd082570f6f276e978c358566fc9d93413efe36a50ee9172778da98ef9ae4094212cde1728ded9650d157c7aa630e3534c4aecc4a57c0510ca
7
+ data.tar.gz: 4f4990c983cdc12e8ee7fb6ebfc72d2a4b4ee4d7aee64fe443b0b29c8bacfb81e7f43c477c2f74dd0bbe0bfee222632785141c013602b9e0afee94fccced9fb4
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.0"
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
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.0
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-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -42,6 +42,7 @@ files:
42
42
  - lib/rt_rubocop_defaults.rb
43
43
  - lib/rt_rubocop_defaults/inject.rb
44
44
  - lib/rt_rubocop_defaults/version.rb
45
+ - lib/rubocop/cop/rspec/unexpected_requires.rb
45
46
  - rt_rubocop_defaults.gemspec
46
47
  homepage: https://github.com/runtastic/rt_rubocop_defaults
47
48
  licenses:
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  - !ruby/object:Gem::Version
64
65
  version: '0'
65
66
  requirements: []
66
- rubygems_version: 3.2.3
67
+ rubygems_version: 3.5.3
67
68
  signing_key:
68
69
  specification_version: 4
69
70
  summary: rubocop defaults used at runtastic