rt_rubocop_defaults 2.7.1 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +5 -0
- data/lib/rt_rubocop_defaults/version.rb +1 -1
- data/lib/rt_rubocop_defaults.rb +2 -0
- data/lib/rubocop/cop/rspec/unexpected_requires.rb +53 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8222f836d95f9d35647d6875b30347491754bf9b5fd704868246c7ef8b91684b
|
4
|
+
data.tar.gz: f3d6c565037f1afcde1b03005637243c9b39ca6b3e513b32dfdec4638561ac63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca74896b5e1f47bd082570f6f276e978c358566fc9d93413efe36a50ee9172778da98ef9ae4094212cde1728ded9650d157c7aa630e3534c4aecc4a57c0510ca
|
7
|
+
data.tar.gz: 4f4990c983cdc12e8ee7fb6ebfc72d2a4b4ee4d7aee64fe443b0b29c8bacfb81e7f43c477c2f74dd0bbe0bfee222632785141c013602b9e0afee94fccced9fb4
|
data/config/default.yml
CHANGED
data/lib/rt_rubocop_defaults.rb
CHANGED
@@ -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.
|
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-
|
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.
|
67
|
+
rubygems_version: 3.5.3
|
67
68
|
signing_key:
|
68
69
|
specification_version: 4
|
69
70
|
summary: rubocop defaults used at runtastic
|