warning_signs 0.0.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +7 -3
- data/README.md +31 -1
- data/lib/warning_signs/deprecation.rb +14 -9
- data/lib/warning_signs/environment.rb +5 -3
- data/lib/warning_signs/handler.rb +9 -9
- data/lib/warning_signs/pattern.rb +11 -0
- data/lib/warning_signs/regex_pattern.rb +13 -0
- data/lib/warning_signs/ruby_deprecation_catcher.rb +10 -1
- data/lib/warning_signs/string_pattern.rb +13 -0
- data/lib/warning_signs/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5dd43f86a3822293460f2d79efb2c2e98a5cb6a86ca5b85a3d762b4e9b82a8e
|
4
|
+
data.tar.gz: 9dd3da0dbd012564356f1c477038f9cd5b00652149c064aea4006224b408940f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e73a2bc35a1283b56061fad2717c6b0c9ce19f91c34b81645bf57c9e4c09eee2f93f727529c107a54c2e47fa6a8d88b9958af522b3a12929d18f505924b734f
|
7
|
+
data.tar.gz: eb2050074df9f17103a57ebbf506cba97a9f0a4b17d82db8b968c359751edbb8787033c708d19b5bb2e2b57b49346f138576f9cd98552cca80f12578d4ce908a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
|
3
|
+
* Allow multiple behaviors in a single environment
|
4
|
+
* Allow only and except matchers to be regular expressions
|
5
|
+
|
6
|
+
## 0.2.0
|
7
|
+
|
8
|
+
* Test for "other environment"
|
9
|
+
|
1
10
|
## 0.1.0
|
2
11
|
|
12
|
+
* Smarter caller information for Ruby warnings
|
13
|
+
|
14
|
+
## 0.0.1
|
15
|
+
|
3
16
|
* Initial public release
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
warning_signs (0.0
|
4
|
+
warning_signs (0.3.0)
|
5
5
|
awesome_print
|
6
6
|
railties
|
7
7
|
|
@@ -48,6 +48,10 @@ GEM
|
|
48
48
|
minitest (5.18.0)
|
49
49
|
nokogiri (1.14.3-arm64-darwin)
|
50
50
|
racc (~> 1.4)
|
51
|
+
nokogiri (1.14.3-x86_64-darwin)
|
52
|
+
racc (~> 1.4)
|
53
|
+
nokogiri (1.14.3-x86_64-linux)
|
54
|
+
racc (~> 1.4)
|
51
55
|
parallel (1.23.0)
|
52
56
|
parser (3.2.2.1)
|
53
57
|
ast (~> 2.4.1)
|
@@ -104,7 +108,7 @@ GEM
|
|
104
108
|
rubocop-ast (>= 1.28.0, < 2.0)
|
105
109
|
ruby-progressbar (~> 1.7)
|
106
110
|
unicode-display_width (>= 2.4.0, < 3.0)
|
107
|
-
rubocop-ast (1.28.
|
111
|
+
rubocop-ast (1.28.1)
|
108
112
|
parser (>= 3.2.1.0)
|
109
113
|
rubocop-performance (1.16.0)
|
110
114
|
rubocop (>= 1.7.0, < 2.0)
|
@@ -115,7 +119,7 @@ GEM
|
|
115
119
|
json (>= 1.8, < 3)
|
116
120
|
simplecov-html (~> 0.10.0)
|
117
121
|
simplecov-html (0.10.2)
|
118
|
-
standard (1.28.
|
122
|
+
standard (1.28.2)
|
119
123
|
language_server-protocol (~> 3.17.0.2)
|
120
124
|
lint_roller (~> 1.0)
|
121
125
|
rubocop (~> 1.50.2)
|
data/README.md
CHANGED
@@ -83,6 +83,21 @@ handlers:
|
|
83
83
|
behavior: ignore
|
84
84
|
```
|
85
85
|
|
86
|
+
A single environment can have multiple behaviors. This is helpful if you are,
|
87
|
+
say dealing with end-to-end specs that swallow exceptions:
|
88
|
+
|
89
|
+
```yaml
|
90
|
+
handlers:
|
91
|
+
- environment: all
|
92
|
+
behaviors:
|
93
|
+
- raise
|
94
|
+
- log
|
95
|
+
```
|
96
|
+
|
97
|
+
No matter what order you have the behaviors in, a `raise` behavior will be
|
98
|
+
executed last so that the other behaviors happen before the exception is
|
99
|
+
invoked.
|
100
|
+
|
86
101
|
A common pattern is to focus only on specific deprecations and ignore others.
|
87
102
|
For example, this setting file would raise on Ruby keyword argument
|
88
103
|
deprecations and ignore other ruby deprecations
|
@@ -99,7 +114,22 @@ handlers:
|
|
99
114
|
```
|
100
115
|
|
101
116
|
Patterns are matched if the deprecation message contains the pattern as a
|
102
|
-
substring
|
117
|
+
substring.
|
118
|
+
|
119
|
+
The pattern can be a regular expression, denoted by using regular expression
|
120
|
+
syntax _inside_ the string in the YAML:
|
121
|
+
|
122
|
+
```yaml
|
123
|
+
handlers:
|
124
|
+
- source: ruby
|
125
|
+
only:
|
126
|
+
- "/Using .* argument/"
|
127
|
+
environment: all
|
128
|
+
behavior: log
|
129
|
+
```
|
130
|
+
|
131
|
+
The pattern inside the slashes is converted to a Ruby `Regexp` and patterns
|
132
|
+
are matched if the regexp and the deprecation warning message match.
|
103
133
|
|
104
134
|
Another pattern is to have a list of ignored deprecations and then remove
|
105
135
|
messages one by one and manage them individually.
|
@@ -11,18 +11,23 @@ module WarningSigns
|
|
11
11
|
World.instance.handler_for(self)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
# force raise to be the last element if it is present
|
15
|
+
def behaviors
|
16
|
+
result = (handler&.environment&.behaviors || []).inquiry
|
17
|
+
return result if !result.raise?
|
18
|
+
(result - ["raise"]) << "raise"
|
16
19
|
end
|
17
20
|
|
18
21
|
def invoke
|
19
|
-
|
20
|
-
|
21
|
-
raise
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
behaviors.each do |behavior|
|
23
|
+
case behavior
|
24
|
+
when "raise"
|
25
|
+
raise UnhandledDeprecationError, message
|
26
|
+
when "log"
|
27
|
+
Rails.logger.warn(message)
|
28
|
+
when "stderr"
|
29
|
+
$stderr.puts(message) # standard:disable Style/StderrPuts
|
30
|
+
end
|
26
31
|
end
|
27
32
|
end
|
28
33
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module WarningSigns
|
2
2
|
class Environment
|
3
|
-
attr_accessor :environment, :
|
3
|
+
attr_accessor :environment, :behaviors
|
4
4
|
|
5
|
-
def initialize(environment:, behavior:)
|
5
|
+
def initialize(environment:, behaviors: [], behavior: nil)
|
6
6
|
@environment = environment.to_s.downcase.inquiry
|
7
|
-
@
|
7
|
+
@behaviors = (behaviors + [behavior])
|
8
|
+
.compact
|
9
|
+
.map { _1.to_s.downcase.inquiry }
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -1,25 +1,25 @@
|
|
1
1
|
module WarningSigns
|
2
2
|
class Handler
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :environments, :except, :only, :source
|
4
4
|
|
5
5
|
def self.from_hash(hash)
|
6
6
|
new(**hash.symbolize_keys)
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize(
|
10
|
-
behavior:
|
10
|
+
behavior: nil,
|
11
|
+
behaviors: [],
|
11
12
|
environment: nil,
|
12
13
|
except: [],
|
13
14
|
only: [],
|
14
15
|
source: "any",
|
15
16
|
environments: []
|
16
17
|
)
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@only = only
|
18
|
+
@except = except.map { Pattern.for(_1) }
|
19
|
+
@only = only.map { Pattern.for(_1) }
|
20
20
|
@environments = environments.map { Environment.new(**_1.symbolize_keys) }
|
21
21
|
if environment.present?
|
22
|
-
@environments << Environment.new(environment: environment, behavior: behavior)
|
22
|
+
@environments << Environment.new(environment: environment, behaviors: behaviors, behavior: behavior)
|
23
23
|
end
|
24
24
|
@source = source.to_s.downcase.inquiry
|
25
25
|
raise InvalidHandlerError unless valid?
|
@@ -50,14 +50,14 @@ module WarningSigns
|
|
50
50
|
def only_match?(message)
|
51
51
|
return true if only.empty?
|
52
52
|
only.any? do |only_pattern|
|
53
|
-
|
53
|
+
only_pattern.match?(message)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
def except_match?(message)
|
58
58
|
return true if except.empty?
|
59
|
-
except.none? do |
|
60
|
-
|
59
|
+
except.none? do |except_pattern|
|
60
|
+
except_pattern.match?(message)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -5,7 +5,16 @@ module WarningSigns
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def augmented_message(message)
|
8
|
-
"RUBY DEPRECATION WARNING: #{message} called from #{
|
8
|
+
"RUBY DEPRECATION WARNING: #{message} called from #{caller_location}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def caller_location
|
12
|
+
caller_locations.find do |location|
|
13
|
+
!location.to_s.include?("internal:warning") &&
|
14
|
+
!location.to_s.include?("warning_signs") &&
|
15
|
+
!location.to_s.include?("rubygems") &&
|
16
|
+
!location.to_s.include?("/gems")
|
17
|
+
end
|
9
18
|
end
|
10
19
|
end
|
11
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warning_signs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noel Rappin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|
@@ -173,9 +173,12 @@ files:
|
|
173
173
|
- lib/warning_signs/deprecation.rb
|
174
174
|
- lib/warning_signs/environment.rb
|
175
175
|
- lib/warning_signs/handler.rb
|
176
|
+
- lib/warning_signs/pattern.rb
|
176
177
|
- lib/warning_signs/rails_deprecation_catcher.rb
|
177
178
|
- lib/warning_signs/railtie.rb
|
179
|
+
- lib/warning_signs/regex_pattern.rb
|
178
180
|
- lib/warning_signs/ruby_deprecation_catcher.rb
|
181
|
+
- lib/warning_signs/string_pattern.rb
|
179
182
|
- lib/warning_signs/version.rb
|
180
183
|
- lib/warning_signs/world.rb
|
181
184
|
- warning_signs.gemspec
|