rt_rubocop_defaults 2.7.0 → 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: aa2a8249676db757cefd40551140632f9269940a564e294086794cb00dad4e14
4
- data.tar.gz: efc89668d9719dc2f6679e0f95404095ddca6ad8d7a06fcfc5a7e6027fa1aefe
3
+ metadata.gz: 8222f836d95f9d35647d6875b30347491754bf9b5fd704868246c7ef8b91684b
4
+ data.tar.gz: f3d6c565037f1afcde1b03005637243c9b39ca6b3e513b32dfdec4638561ac63
5
5
  SHA512:
6
- metadata.gz: d7f06b18449f697ebe4b1cef8106d0d195663b8c8babdde619044cb8c86bdc4f2bf09d46b3e23d6f34d20cd064584262662ea31fd0acaa78d990bd14e509aaae
7
- data.tar.gz: 351f754a6c29d318b2fb77b0da96bfdb61707303adb390944d579b0635ed91f055861c7b27b8aa0c7943439fe5207ffec8a877eeeb0ce825cb6db7e8dafd0c34
6
+ metadata.gz: ca74896b5e1f47bd082570f6f276e978c358566fc9d93413efe36a50ee9172778da98ef9ae4094212cde1728ded9650d157c7aa630e3534c4aecc4a57c0510ca
7
+ data.tar.gz: 4f4990c983cdc12e8ee7fb6ebfc72d2a4b4ee4d7aee64fe443b0b29c8bacfb81e7f43c477c2f74dd0bbe0bfee222632785141c013602b9e0afee94fccced9fb4
data/config/default.yml CHANGED
@@ -199,7 +199,17 @@ RSpec/NoExpectationExample:
199
199
  RSpec/FactoryBot/SyntaxMethods:
200
200
  Enabled: false
201
201
 
202
- #### RSpec/
202
+ #### Rails/
203
203
  # https://docs.rubocop.org/rubocop-rspec/cops_rspec_rails.html#rspecrailshavehttpstatus
204
+ # Old cop name
204
205
  RSpec/Rails/HaveHttpStatus:
205
- Enabled: false
206
+ Enabled: false
207
+
208
+ # New cop name
209
+ RSpecRails/HaveHttpStatus:
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.0"
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.0
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-03-05 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