deprecation_collector 0.0.5 → 0.1.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: 6f45c8742c0a83f697b04d7a99af54749b354c25cfcffb78f152a680f8224584
4
- data.tar.gz: ab25a06b38f3ebfe82a48136c8a58da8d61e4db93614af0c66e283771f0b61b7
3
+ metadata.gz: 0b71c1caccaf15b1fac4574aa413071d8e9b14edc88f996f17421fd6b12eb5d3
4
+ data.tar.gz: 9312d3017f8c025247a77bbab1af84541cd4f7145f7433d5fe9d728807ae562f
5
5
  SHA512:
6
- metadata.gz: d395dc4cedb786ab398911e5de19568f44317040352f1b85a6fc45a45fce465d6c82b8092c2f74e0a6b1d18e4dedfbc3284d59767dad2f3a2202143acd969b81
7
- data.tar.gz: 0f9a6cd6f02b9b674710db839fcce21f69a2af31a41cc552ad3266b7cd1c3eaa21dac1ac7f94f0208833536e29c20d70e0261e6b087bc548597035c45bc47799
6
+ metadata.gz: dab3728079d5caa64c4001afbc22e355e66c2912bc3318983b5d8e147f1b2596f11ddfba532cd3c061319e4da2be00b86b5a8752055c10a0f26e4b3beeef2c83
7
+ data.tar.gz: ac0133a1048a0644a2dab5b48ae5ebe97751210edc1da39c28248c8f6a1ee3c00732b09bbc8462a93ac06956fee40f672d5d193ff0be84c5ff57ae51570956ee
data/.rubocop.yml CHANGED
@@ -1,7 +1,9 @@
1
1
  AllCops:
2
- # spec/ have TargetRubyVersion: 2.6
3
- TargetRubyVersion: 2.4
2
+ # note additional conf in spec/
3
+ TargetRubyVersion: 2.5
4
4
  NewCops: enable
5
+ Exclude:
6
+ - gemfiles/*
5
7
 
6
8
  Style/StringLiterals:
7
9
  Enabled: true
@@ -14,7 +16,8 @@ Style/StringLiteralsInInterpolation:
14
16
  Layout/LineLength:
15
17
  Max: 120
16
18
 
17
- Metrics/ClassLength: { Max: 200 }
19
+ Metrics/ClassLength: { Max: 230 }
18
20
  Metrics/MethodLength: { Max: 15 }
21
+ Metrics/AbcSize: { Max: 20}
19
22
  Metrics/CyclomaticComplexity: { Max: 9 }
20
23
  Metrics/PerceivedComplexity: { Max: 9 }
data/Appraisals ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise "rails_none" do
4
+ # none here
5
+ end
6
+
7
+ appraise "rails_6" do
8
+ gem "rails", "~>6.0"
9
+ end
10
+
11
+ appraise "rails_7" do
12
+ gem "rails", "~>7.0"
13
+ end
data/CHANGELOG.md CHANGED
@@ -1,4 +1,16 @@
1
- == 0.0.5 (unreleased)
1
+ == 0.1.0
2
+ - kinda-breaking: ruby 2.4 was in fact not supported, so changed requirement to 2.5
3
+ - prevent recursion when deprecation fires in `context_saver` hook
4
+ - prevent recursion in most cases if a deprecation fires in collector itself
5
+
6
+ - changed all `caller` use to `caller_locations` to match rails (and take advantage of it), `#collect` now expects backtrace with an array of `Thread::Backtrace::Location`
7
+ - added GitHub Actions CI
8
+ - added ability to run without rails
9
+
10
+ == 0.0.6
11
+ - added custom context saving ability
12
+
13
+ == 0.0.5
2
14
  - options `print_to_stderr`, `print_recurring`
3
15
  - fix redis deprecated `pipelined` block arity (support for redis 5)
4
16
 
data/Gemfile CHANGED
@@ -10,13 +10,17 @@ gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
  gem "timecop"
12
12
 
13
- gem "rubocop", "~> 1.21"
14
- gem "rubocop-performance"
15
- gem "rubocop-rails"
16
- gem "rubocop-rake"
17
- gem "rubocop-rspec"
13
+ unless defined?(Appraisal)
14
+ group :lint do
15
+ gem "rubocop", "~> 1.21"
16
+ gem "rubocop-performance"
17
+ gem "rubocop-rails"
18
+ gem "rubocop-rake"
19
+ gem "rubocop-rspec"
20
+ end
18
21
 
19
- # TODO: appraisals
20
- gem "rails", "6.0"
22
+ gem "rails", "~>6.0.0"
23
+ end
21
24
 
22
- gem 'redis', '~>4.8'
25
+ gem "fakeredis"
26
+ gem "redis", "~>4.8"
data/Gemfile.lock CHANGED
@@ -1,172 +1,193 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deprecation_collector (0.0.5)
4
+ deprecation_collector (0.1.0)
5
5
  redis (>= 3.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (6.0.0)
11
- actionpack (= 6.0.0)
10
+ actioncable (6.0.6)
11
+ actionpack (= 6.0.6)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailbox (6.0.0)
15
- actionpack (= 6.0.0)
16
- activejob (= 6.0.0)
17
- activerecord (= 6.0.0)
18
- activestorage (= 6.0.0)
19
- activesupport (= 6.0.0)
14
+ actionmailbox (6.0.6)
15
+ actionpack (= 6.0.6)
16
+ activejob (= 6.0.6)
17
+ activerecord (= 6.0.6)
18
+ activestorage (= 6.0.6)
19
+ activesupport (= 6.0.6)
20
20
  mail (>= 2.7.1)
21
- actionmailer (6.0.0)
22
- actionpack (= 6.0.0)
23
- actionview (= 6.0.0)
24
- activejob (= 6.0.0)
21
+ actionmailer (6.0.6)
22
+ actionpack (= 6.0.6)
23
+ actionview (= 6.0.6)
24
+ activejob (= 6.0.6)
25
25
  mail (~> 2.5, >= 2.5.4)
26
26
  rails-dom-testing (~> 2.0)
27
- actionpack (6.0.0)
28
- actionview (= 6.0.0)
29
- activesupport (= 6.0.0)
30
- rack (~> 2.0)
27
+ actionpack (6.0.6)
28
+ actionview (= 6.0.6)
29
+ activesupport (= 6.0.6)
30
+ rack (~> 2.0, >= 2.0.8)
31
31
  rack-test (>= 0.6.3)
32
32
  rails-dom-testing (~> 2.0)
33
33
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
- actiontext (6.0.0)
35
- actionpack (= 6.0.0)
36
- activerecord (= 6.0.0)
37
- activestorage (= 6.0.0)
38
- activesupport (= 6.0.0)
34
+ actiontext (6.0.6)
35
+ actionpack (= 6.0.6)
36
+ activerecord (= 6.0.6)
37
+ activestorage (= 6.0.6)
38
+ activesupport (= 6.0.6)
39
39
  nokogiri (>= 1.8.5)
40
- actionview (6.0.0)
41
- activesupport (= 6.0.0)
40
+ actionview (6.0.6)
41
+ activesupport (= 6.0.6)
42
42
  builder (~> 3.1)
43
43
  erubi (~> 1.4)
44
44
  rails-dom-testing (~> 2.0)
45
45
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
- activejob (6.0.0)
47
- activesupport (= 6.0.0)
46
+ activejob (6.0.6)
47
+ activesupport (= 6.0.6)
48
48
  globalid (>= 0.3.6)
49
- activemodel (6.0.0)
50
- activesupport (= 6.0.0)
51
- activerecord (6.0.0)
52
- activemodel (= 6.0.0)
53
- activesupport (= 6.0.0)
54
- activestorage (6.0.0)
55
- actionpack (= 6.0.0)
56
- activejob (= 6.0.0)
57
- activerecord (= 6.0.0)
58
- marcel (~> 0.3.1)
59
- activesupport (6.0.0)
49
+ activemodel (6.0.6)
50
+ activesupport (= 6.0.6)
51
+ activerecord (6.0.6)
52
+ activemodel (= 6.0.6)
53
+ activesupport (= 6.0.6)
54
+ activestorage (6.0.6)
55
+ actionpack (= 6.0.6)
56
+ activejob (= 6.0.6)
57
+ activerecord (= 6.0.6)
58
+ marcel (~> 1.0)
59
+ activesupport (6.0.6)
60
60
  concurrent-ruby (~> 1.0, >= 1.0.2)
61
61
  i18n (>= 0.7, < 2)
62
62
  minitest (~> 5.1)
63
63
  tzinfo (~> 1.1)
64
- zeitwerk (~> 2.1, >= 2.1.8)
64
+ zeitwerk (~> 2.2, >= 2.2.2)
65
+ appraisal (2.4.1)
66
+ bundler
67
+ rake
68
+ thor (>= 0.14.0)
65
69
  ast (2.4.2)
66
70
  builder (3.2.4)
67
71
  concurrent-ruby (1.1.10)
68
72
  crass (1.0.6)
73
+ date (3.3.1)
69
74
  diff-lcs (1.5.0)
70
- erubi (1.10.0)
75
+ erubi (1.11.0)
76
+ fakeredis (0.8.0)
77
+ redis (~> 4.1)
71
78
  globalid (1.0.0)
72
79
  activesupport (>= 5.0)
73
- i18n (1.10.0)
80
+ i18n (1.12.0)
74
81
  concurrent-ruby (~> 1.0)
75
- loofah (2.18.0)
82
+ json (2.6.3)
83
+ loofah (2.19.1)
76
84
  crass (~> 1.0.2)
77
85
  nokogiri (>= 1.5.9)
78
- mail (2.7.1)
86
+ mail (2.8.0)
79
87
  mini_mime (>= 0.1.1)
80
- marcel (0.3.3)
81
- mimemagic (~> 0.3.2)
88
+ net-imap
89
+ net-pop
90
+ net-smtp
91
+ marcel (1.0.2)
82
92
  method_source (1.0.0)
83
- mimemagic (0.3.10)
84
- nokogiri (~> 1)
85
- rake
86
93
  mini_mime (1.1.2)
87
94
  mini_portile2 (2.8.0)
88
- minitest (5.15.0)
95
+ minitest (5.16.3)
96
+ net-imap (0.3.2)
97
+ date
98
+ net-protocol
99
+ net-pop (0.1.2)
100
+ net-protocol
101
+ net-protocol (0.2.1)
102
+ timeout
103
+ net-smtp (0.3.3)
104
+ net-protocol
89
105
  nio4r (2.5.8)
90
- nokogiri (1.13.6)
106
+ nokogiri (1.13.10)
91
107
  mini_portile2 (~> 2.8.0)
92
108
  racc (~> 1.4)
93
- nokogiri (1.13.6-x86_64-darwin)
109
+ nokogiri (1.13.10-arm64-darwin)
110
+ racc (~> 1.4)
111
+ nokogiri (1.13.10-x86_64-darwin)
112
+ racc (~> 1.4)
113
+ nokogiri (1.13.10-x86_64-linux)
94
114
  racc (~> 1.4)
95
115
  parallel (1.22.1)
96
- parser (3.1.2.0)
116
+ parser (3.1.3.0)
97
117
  ast (~> 2.4.1)
98
- racc (1.6.0)
99
- rack (2.2.3.1)
100
- rack-test (1.1.0)
101
- rack (>= 1.0, < 3)
102
- rails (6.0.0)
103
- actioncable (= 6.0.0)
104
- actionmailbox (= 6.0.0)
105
- actionmailer (= 6.0.0)
106
- actionpack (= 6.0.0)
107
- actiontext (= 6.0.0)
108
- actionview (= 6.0.0)
109
- activejob (= 6.0.0)
110
- activemodel (= 6.0.0)
111
- activerecord (= 6.0.0)
112
- activestorage (= 6.0.0)
113
- activesupport (= 6.0.0)
118
+ racc (1.6.1)
119
+ rack (2.2.4)
120
+ rack-test (2.0.2)
121
+ rack (>= 1.3)
122
+ rails (6.0.6)
123
+ actioncable (= 6.0.6)
124
+ actionmailbox (= 6.0.6)
125
+ actionmailer (= 6.0.6)
126
+ actionpack (= 6.0.6)
127
+ actiontext (= 6.0.6)
128
+ actionview (= 6.0.6)
129
+ activejob (= 6.0.6)
130
+ activemodel (= 6.0.6)
131
+ activerecord (= 6.0.6)
132
+ activestorage (= 6.0.6)
133
+ activesupport (= 6.0.6)
114
134
  bundler (>= 1.3.0)
115
- railties (= 6.0.0)
135
+ railties (= 6.0.6)
116
136
  sprockets-rails (>= 2.0.0)
117
137
  rails-dom-testing (2.0.3)
118
138
  activesupport (>= 4.2.0)
119
139
  nokogiri (>= 1.6)
120
- rails-html-sanitizer (1.4.2)
121
- loofah (~> 2.3)
122
- railties (6.0.0)
123
- actionpack (= 6.0.0)
124
- activesupport (= 6.0.0)
140
+ rails-html-sanitizer (1.4.4)
141
+ loofah (~> 2.19, >= 2.19.1)
142
+ railties (6.0.6)
143
+ actionpack (= 6.0.6)
144
+ activesupport (= 6.0.6)
125
145
  method_source
126
146
  rake (>= 0.8.7)
127
147
  thor (>= 0.20.3, < 2.0)
128
148
  rainbow (3.1.1)
129
149
  rake (13.0.6)
130
150
  redis (4.8.0)
131
- regexp_parser (2.5.0)
151
+ regexp_parser (2.6.1)
132
152
  rexml (3.2.5)
133
- rspec (3.11.0)
134
- rspec-core (~> 3.11.0)
135
- rspec-expectations (~> 3.11.0)
136
- rspec-mocks (~> 3.11.0)
137
- rspec-core (3.11.0)
138
- rspec-support (~> 3.11.0)
139
- rspec-expectations (3.11.0)
153
+ rspec (3.12.0)
154
+ rspec-core (~> 3.12.0)
155
+ rspec-expectations (~> 3.12.0)
156
+ rspec-mocks (~> 3.12.0)
157
+ rspec-core (3.12.0)
158
+ rspec-support (~> 3.12.0)
159
+ rspec-expectations (3.12.0)
140
160
  diff-lcs (>= 1.2.0, < 2.0)
141
- rspec-support (~> 3.11.0)
142
- rspec-mocks (3.11.1)
161
+ rspec-support (~> 3.12.0)
162
+ rspec-mocks (3.12.1)
143
163
  diff-lcs (>= 1.2.0, < 2.0)
144
- rspec-support (~> 3.11.0)
145
- rspec-support (3.11.0)
146
- rubocop (1.30.0)
164
+ rspec-support (~> 3.12.0)
165
+ rspec-support (3.12.0)
166
+ rubocop (1.40.0)
167
+ json (~> 2.3)
147
168
  parallel (~> 1.10)
148
- parser (>= 3.1.0.0)
169
+ parser (>= 3.1.2.1)
149
170
  rainbow (>= 2.2.2, < 4.0)
150
171
  regexp_parser (>= 1.8, < 3.0)
151
172
  rexml (>= 3.2.5, < 4.0)
152
- rubocop-ast (>= 1.18.0, < 2.0)
173
+ rubocop-ast (>= 1.23.0, < 2.0)
153
174
  ruby-progressbar (~> 1.7)
154
175
  unicode-display_width (>= 1.4.0, < 3.0)
155
- rubocop-ast (1.18.0)
176
+ rubocop-ast (1.24.0)
156
177
  parser (>= 3.1.1.0)
157
- rubocop-performance (1.14.3)
178
+ rubocop-performance (1.15.1)
158
179
  rubocop (>= 1.7.0, < 2.0)
159
180
  rubocop-ast (>= 0.4.0)
160
- rubocop-rails (2.15.2)
181
+ rubocop-rails (2.17.3)
161
182
  activesupport (>= 4.2.0)
162
183
  rack (>= 1.1)
163
- rubocop (>= 1.7.0, < 2.0)
184
+ rubocop (>= 1.33.0, < 2.0)
164
185
  rubocop-rake (0.6.0)
165
186
  rubocop (~> 1.0)
166
- rubocop-rspec (2.11.1)
167
- rubocop (~> 1.19)
187
+ rubocop-rspec (2.16.0)
188
+ rubocop (~> 1.33)
168
189
  ruby-progressbar (1.11.0)
169
- sprockets (4.0.3)
190
+ sprockets (4.1.1)
170
191
  concurrent-ruby (~> 1.0)
171
192
  rack (> 1, < 3)
172
193
  sprockets-rails (3.4.2)
@@ -175,22 +196,27 @@ GEM
175
196
  sprockets (>= 3.0.0)
176
197
  thor (1.2.1)
177
198
  thread_safe (0.3.6)
178
- timecop (0.9.5)
179
- tzinfo (1.2.9)
199
+ timecop (0.9.6)
200
+ timeout (0.3.1)
201
+ tzinfo (1.2.10)
180
202
  thread_safe (~> 0.1)
181
- unicode-display_width (2.1.0)
203
+ unicode-display_width (2.3.0)
182
204
  websocket-driver (0.7.5)
183
205
  websocket-extensions (>= 0.1.0)
184
206
  websocket-extensions (0.1.5)
185
- zeitwerk (2.5.4)
207
+ zeitwerk (2.6.6)
186
208
 
187
209
  PLATFORMS
210
+ arm64-darwin
188
211
  ruby
189
- x86_64-darwin-21
212
+ x86_64-darwin
213
+ x86_64-linux
190
214
 
191
215
  DEPENDENCIES
216
+ appraisal
192
217
  deprecation_collector!
193
- rails (= 6.0)
218
+ fakeredis
219
+ rails (~> 6.0.0)
194
220
  rake (~> 13.0)
195
221
  redis (~> 4.8)
196
222
  rspec (~> 3.0)
data/README.md CHANGED
@@ -33,6 +33,10 @@ Add an initializer with configuration, like
33
33
  instance.ignored_messages = [
34
34
  "Ignoring db/schema_cache.yml because it has expired"
35
35
  ]
36
+ instance.context_saver do
37
+ # this will only be called for new deprecations, return value must be json-compatible
38
+ { some: "custom", context: "for example request.id" }
39
+ end
36
40
  end
37
41
  end
38
42
  ```
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "Collects and aggregates warnings and deprecations. Optimized for production environment."
13
13
  spec.homepage = "https://github.com/Vasfed/deprecation_collector"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.4.0"
15
+ spec.required_ruby_version = ">= 2.5.0"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/Vasfed/deprecation_collector"
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_dependency "redis", ">= 3.0"
31
+ spec.add_development_dependency "appraisal"
31
32
  end
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "timecop"
8
+ gem "fakeredis"
9
+ gem "redis", "~>4.8"
10
+ gem "rails", "~>6.0"
11
+
12
+ gemspec path: "../"
@@ -0,0 +1,194 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ deprecation_collector (0.1.0)
5
+ redis (>= 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.1.7)
11
+ actionpack (= 6.1.7)
12
+ activesupport (= 6.1.7)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.1.7)
16
+ actionpack (= 6.1.7)
17
+ activejob (= 6.1.7)
18
+ activerecord (= 6.1.7)
19
+ activestorage (= 6.1.7)
20
+ activesupport (= 6.1.7)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.7)
23
+ actionpack (= 6.1.7)
24
+ actionview (= 6.1.7)
25
+ activejob (= 6.1.7)
26
+ activesupport (= 6.1.7)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.1.7)
30
+ actionview (= 6.1.7)
31
+ activesupport (= 6.1.7)
32
+ rack (~> 2.0, >= 2.0.9)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.7)
37
+ actionpack (= 6.1.7)
38
+ activerecord (= 6.1.7)
39
+ activestorage (= 6.1.7)
40
+ activesupport (= 6.1.7)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.7)
43
+ activesupport (= 6.1.7)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.7)
49
+ activesupport (= 6.1.7)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.1.7)
52
+ activesupport (= 6.1.7)
53
+ activerecord (6.1.7)
54
+ activemodel (= 6.1.7)
55
+ activesupport (= 6.1.7)
56
+ activestorage (6.1.7)
57
+ actionpack (= 6.1.7)
58
+ activejob (= 6.1.7)
59
+ activerecord (= 6.1.7)
60
+ activesupport (= 6.1.7)
61
+ marcel (~> 1.0)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (6.1.7)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ appraisal (2.4.1)
70
+ bundler
71
+ rake
72
+ thor (>= 0.14.0)
73
+ builder (3.2.4)
74
+ concurrent-ruby (1.1.10)
75
+ crass (1.0.6)
76
+ diff-lcs (1.5.0)
77
+ digest (3.1.1)
78
+ erubi (1.11.0)
79
+ fakeredis (0.8.0)
80
+ redis (~> 4.1)
81
+ globalid (1.0.0)
82
+ activesupport (>= 5.0)
83
+ i18n (1.12.0)
84
+ concurrent-ruby (~> 1.0)
85
+ io-wait (0.2.3)
86
+ loofah (2.19.1)
87
+ crass (~> 1.0.2)
88
+ nokogiri (>= 1.5.9)
89
+ mail (2.8.0)
90
+ mini_mime (>= 0.1.1)
91
+ net-imap
92
+ net-pop
93
+ net-smtp
94
+ marcel (1.0.2)
95
+ method_source (1.0.0)
96
+ mini_mime (1.1.2)
97
+ minitest (5.15.0)
98
+ net-imap (0.2.2)
99
+ digest
100
+ net-protocol
101
+ strscan
102
+ net-pop (0.1.2)
103
+ net-protocol
104
+ net-protocol (0.1.2)
105
+ io-wait
106
+ timeout
107
+ net-smtp (0.3.0)
108
+ digest
109
+ net-protocol
110
+ timeout
111
+ nio4r (2.5.8)
112
+ nokogiri (1.12.5-x86_64-darwin)
113
+ racc (~> 1.4)
114
+ nokogiri (1.12.5-x86_64-linux)
115
+ racc (~> 1.4)
116
+ racc (1.6.1)
117
+ rack (2.2.4)
118
+ rack-test (2.0.2)
119
+ rack (>= 1.3)
120
+ rails (6.1.7)
121
+ actioncable (= 6.1.7)
122
+ actionmailbox (= 6.1.7)
123
+ actionmailer (= 6.1.7)
124
+ actionpack (= 6.1.7)
125
+ actiontext (= 6.1.7)
126
+ actionview (= 6.1.7)
127
+ activejob (= 6.1.7)
128
+ activemodel (= 6.1.7)
129
+ activerecord (= 6.1.7)
130
+ activestorage (= 6.1.7)
131
+ activesupport (= 6.1.7)
132
+ bundler (>= 1.15.0)
133
+ railties (= 6.1.7)
134
+ sprockets-rails (>= 2.0.0)
135
+ rails-dom-testing (2.0.3)
136
+ activesupport (>= 4.2.0)
137
+ nokogiri (>= 1.6)
138
+ rails-html-sanitizer (1.4.4)
139
+ loofah (~> 2.19, >= 2.19.1)
140
+ railties (6.1.7)
141
+ actionpack (= 6.1.7)
142
+ activesupport (= 6.1.7)
143
+ method_source
144
+ rake (>= 12.2)
145
+ thor (~> 1.0)
146
+ rake (13.0.6)
147
+ redis (4.8.0)
148
+ rspec (3.12.0)
149
+ rspec-core (~> 3.12.0)
150
+ rspec-expectations (~> 3.12.0)
151
+ rspec-mocks (~> 3.12.0)
152
+ rspec-core (3.12.0)
153
+ rspec-support (~> 3.12.0)
154
+ rspec-expectations (3.12.0)
155
+ diff-lcs (>= 1.2.0, < 2.0)
156
+ rspec-support (~> 3.12.0)
157
+ rspec-mocks (3.12.1)
158
+ diff-lcs (>= 1.2.0, < 2.0)
159
+ rspec-support (~> 3.12.0)
160
+ rspec-support (3.12.0)
161
+ sprockets (4.1.1)
162
+ concurrent-ruby (~> 1.0)
163
+ rack (> 1, < 3)
164
+ sprockets-rails (3.4.2)
165
+ actionpack (>= 5.2)
166
+ activesupport (>= 5.2)
167
+ sprockets (>= 3.0.0)
168
+ strscan (3.0.5)
169
+ thor (1.2.1)
170
+ timecop (0.9.6)
171
+ timeout (0.3.1)
172
+ tzinfo (2.0.5)
173
+ concurrent-ruby (~> 1.0)
174
+ websocket-driver (0.7.5)
175
+ websocket-extensions (>= 0.1.0)
176
+ websocket-extensions (0.1.5)
177
+ zeitwerk (2.6.6)
178
+
179
+ PLATFORMS
180
+ x86_64-darwin-21
181
+ x86_64-linux
182
+
183
+ DEPENDENCIES
184
+ appraisal
185
+ deprecation_collector!
186
+ fakeredis
187
+ rails (~> 6.0)
188
+ rake (~> 13.0)
189
+ redis (~> 4.8)
190
+ rspec (~> 3.0)
191
+ timecop
192
+
193
+ BUNDLED WITH
194
+ 2.3.10
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "timecop"
8
+ gem "fakeredis"
9
+ gem "redis", "~>4.8"
10
+ gem "rails", "~>7.0"
11
+
12
+ gemspec path: "../"
@@ -0,0 +1,187 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ deprecation_collector (0.1.0)
5
+ redis (>= 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.4)
11
+ actionpack (= 7.0.4)
12
+ activesupport (= 7.0.4)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (7.0.4)
16
+ actionpack (= 7.0.4)
17
+ activejob (= 7.0.4)
18
+ activerecord (= 7.0.4)
19
+ activestorage (= 7.0.4)
20
+ activesupport (= 7.0.4)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.4)
26
+ actionpack (= 7.0.4)
27
+ actionview (= 7.0.4)
28
+ activejob (= 7.0.4)
29
+ activesupport (= 7.0.4)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.4)
36
+ actionview (= 7.0.4)
37
+ activesupport (= 7.0.4)
38
+ rack (~> 2.0, >= 2.2.0)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.0)
41
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
+ actiontext (7.0.4)
43
+ actionpack (= 7.0.4)
44
+ activerecord (= 7.0.4)
45
+ activestorage (= 7.0.4)
46
+ activesupport (= 7.0.4)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.4)
50
+ activesupport (= 7.0.4)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.4)
53
+ rails-dom-testing (~> 2.0)
54
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
+ activejob (7.0.4)
56
+ activesupport (= 7.0.4)
57
+ globalid (>= 0.3.6)
58
+ activemodel (7.0.4)
59
+ activesupport (= 7.0.4)
60
+ activerecord (7.0.4)
61
+ activemodel (= 7.0.4)
62
+ activesupport (= 7.0.4)
63
+ activestorage (7.0.4)
64
+ actionpack (= 7.0.4)
65
+ activejob (= 7.0.4)
66
+ activerecord (= 7.0.4)
67
+ activesupport (= 7.0.4)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.4)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ appraisal (2.4.1)
76
+ bundler
77
+ rake
78
+ thor (>= 0.14.0)
79
+ builder (3.2.4)
80
+ concurrent-ruby (1.1.10)
81
+ crass (1.0.6)
82
+ date (3.3.1)
83
+ diff-lcs (1.5.0)
84
+ erubi (1.11.0)
85
+ fakeredis (0.8.0)
86
+ redis (~> 4.1)
87
+ globalid (1.0.0)
88
+ activesupport (>= 5.0)
89
+ i18n (1.12.0)
90
+ concurrent-ruby (~> 1.0)
91
+ loofah (2.19.1)
92
+ crass (~> 1.0.2)
93
+ nokogiri (>= 1.5.9)
94
+ mail (2.8.0)
95
+ mini_mime (>= 0.1.1)
96
+ net-imap
97
+ net-pop
98
+ net-smtp
99
+ marcel (1.0.2)
100
+ method_source (1.0.0)
101
+ mini_mime (1.1.2)
102
+ minitest (5.16.3)
103
+ net-imap (0.3.2)
104
+ date
105
+ net-protocol
106
+ net-pop (0.1.2)
107
+ net-protocol
108
+ net-protocol (0.2.1)
109
+ timeout
110
+ net-smtp (0.3.3)
111
+ net-protocol
112
+ nio4r (2.5.8)
113
+ nokogiri (1.13.10-x86_64-darwin)
114
+ racc (~> 1.4)
115
+ nokogiri (1.13.10-x86_64-linux)
116
+ racc (~> 1.4)
117
+ racc (1.6.1)
118
+ rack (2.2.4)
119
+ rack-test (2.0.2)
120
+ rack (>= 1.3)
121
+ rails (7.0.4)
122
+ actioncable (= 7.0.4)
123
+ actionmailbox (= 7.0.4)
124
+ actionmailer (= 7.0.4)
125
+ actionpack (= 7.0.4)
126
+ actiontext (= 7.0.4)
127
+ actionview (= 7.0.4)
128
+ activejob (= 7.0.4)
129
+ activemodel (= 7.0.4)
130
+ activerecord (= 7.0.4)
131
+ activestorage (= 7.0.4)
132
+ activesupport (= 7.0.4)
133
+ bundler (>= 1.15.0)
134
+ railties (= 7.0.4)
135
+ rails-dom-testing (2.0.3)
136
+ activesupport (>= 4.2.0)
137
+ nokogiri (>= 1.6)
138
+ rails-html-sanitizer (1.4.4)
139
+ loofah (~> 2.19, >= 2.19.1)
140
+ railties (7.0.4)
141
+ actionpack (= 7.0.4)
142
+ activesupport (= 7.0.4)
143
+ method_source
144
+ rake (>= 12.2)
145
+ thor (~> 1.0)
146
+ zeitwerk (~> 2.5)
147
+ rake (13.0.6)
148
+ redis (4.8.0)
149
+ rspec (3.12.0)
150
+ rspec-core (~> 3.12.0)
151
+ rspec-expectations (~> 3.12.0)
152
+ rspec-mocks (~> 3.12.0)
153
+ rspec-core (3.12.0)
154
+ rspec-support (~> 3.12.0)
155
+ rspec-expectations (3.12.0)
156
+ diff-lcs (>= 1.2.0, < 2.0)
157
+ rspec-support (~> 3.12.0)
158
+ rspec-mocks (3.12.1)
159
+ diff-lcs (>= 1.2.0, < 2.0)
160
+ rspec-support (~> 3.12.0)
161
+ rspec-support (3.12.0)
162
+ thor (1.2.1)
163
+ timecop (0.9.6)
164
+ timeout (0.3.1)
165
+ tzinfo (2.0.5)
166
+ concurrent-ruby (~> 1.0)
167
+ websocket-driver (0.7.5)
168
+ websocket-extensions (>= 0.1.0)
169
+ websocket-extensions (0.1.5)
170
+ zeitwerk (2.6.6)
171
+
172
+ PLATFORMS
173
+ x86_64-darwin-21
174
+ x86_64-linux
175
+
176
+ DEPENDENCIES
177
+ appraisal
178
+ deprecation_collector!
179
+ fakeredis
180
+ rails (~> 7.0)
181
+ rake (~> 13.0)
182
+ redis (~> 4.8)
183
+ rspec (~> 3.0)
184
+ timecop
185
+
186
+ BUNDLED WITH
187
+ 2.3.10
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "timecop"
8
+ gem "fakeredis"
9
+ gem "redis", "~>4.8"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ deprecation_collector (0.1.0)
5
+ redis (>= 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (2.4.1)
11
+ bundler
12
+ rake
13
+ thor (>= 0.14.0)
14
+ diff-lcs (1.5.0)
15
+ fakeredis (0.8.0)
16
+ redis (~> 4.1)
17
+ rake (13.0.6)
18
+ redis (4.8.0)
19
+ rspec (3.12.0)
20
+ rspec-core (~> 3.12.0)
21
+ rspec-expectations (~> 3.12.0)
22
+ rspec-mocks (~> 3.12.0)
23
+ rspec-core (3.12.0)
24
+ rspec-support (~> 3.12.0)
25
+ rspec-expectations (3.12.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-mocks (3.12.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-support (3.12.0)
32
+ thor (1.2.1)
33
+ timecop (0.9.6)
34
+
35
+ PLATFORMS
36
+ x86_64-darwin-21
37
+ x86_64-linux
38
+
39
+ DEPENDENCIES
40
+ appraisal
41
+ deprecation_collector!
42
+ fakeredis
43
+ rake (~> 13.0)
44
+ redis (~> 4.8)
45
+ rspec (~> 3.0)
46
+ timecop
47
+
48
+ BUNDLED WITH
49
+ 2.3.10
@@ -39,7 +39,7 @@ class DeprecationCollector
39
39
  remove_method :warn
40
40
  end
41
41
  module_function(define_method(:warn) do |*messages, **kwargs|
42
- KernelWarningCollector.warn(*messages, backtrace: caller, **kwargs)
42
+ KernelWarningCollector.warn(*messages, backtrace: caller_locations, **kwargs)
43
43
  end)
44
44
  end
45
45
  end
@@ -83,7 +83,7 @@ class DeprecationCollector
83
83
  # taps into ruby core Warning#warn
84
84
  module WarningCollector
85
85
  def warn(str)
86
- backtrace = caller
86
+ backtrace = caller_locations
87
87
  MultipartWarningJoiner.handle(str) do |multi_str|
88
88
  DeprecationCollector.collect(multi_str, backtrace, :warning)
89
89
  end
@@ -95,7 +95,7 @@ class DeprecationCollector
95
95
  module_function
96
96
 
97
97
  def warn(*messages, backtrace: nil, **_kwargs)
98
- backtrace ||= caller
98
+ backtrace ||= caller_locations
99
99
  str = messages.map(&:to_s).join("\n").strip
100
100
  DeprecationCollector.collect(str, backtrace, :kernel)
101
101
  # not passing to `super` - it will pass to Warning#warn, we do not want that
@@ -4,6 +4,7 @@ class DeprecationCollector
4
4
  # :nodoc:
5
5
  class Deprecation
6
6
  attr_reader :message, :realm, :gem_traceline, :app_traceline, :occurences, :first_timestamp, :full_backtrace
7
+ attr_accessor :context
7
8
 
8
9
  CLEANUP_REGEXES = {
9
10
  # rails views generated methods names are unique per-worker
@@ -70,16 +71,21 @@ class DeprecationCollector
70
71
  revision: DeprecationCollector.instance.app_revision,
71
72
  count: @occurences, # output anyway for frequency estimation (during write_interval inside single process)
72
73
  first_timestamp: first_timestamp, # this may not be accurate, a worker with later timestamp may dump earlier
73
- digest_base: digest_base # for debug purposes
74
+ digest_base: digest_base, # for debug purposes
75
+ context: context
74
76
  }.compact
75
77
  end
76
78
 
79
+ def to_json(_options = {})
80
+ as_json.to_json
81
+ end
82
+
77
83
  protected
78
84
 
79
85
  def find_app_traceline(backtrace)
80
86
  app_root = DeprecationCollector.instance.app_root_prefix
81
87
  backtrace.find do |line|
82
- line = line.to_s
88
+ line = line.path if line.respond_to?(:path) # in production always passes, strings should only come in test
83
89
  (!line.start_with?("/") || line.start_with?(app_root)) && !line.include?("/gems/")
84
90
  end&.to_s&.dup&.delete_prefix(app_root)
85
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class DeprecationCollector
4
- VERSION = "0.0.5"
4
+ VERSION = "0.1.0"
5
5
  end
@@ -6,6 +6,7 @@ require_relative "deprecation_collector/collectors"
6
6
  require "time"
7
7
  require "redis"
8
8
  require "json"
9
+ require "set"
9
10
 
10
11
  # singleton class for collector
11
12
  class DeprecationCollector
@@ -56,7 +57,7 @@ class DeprecationCollector
56
57
  :write_interval, :write_interval_jitter,
57
58
  :app_revision, :app_root,
58
59
  :print_to_stderr, :print_recurring
59
- attr_writer :redis
60
+ attr_writer :redis, :context_saver
60
61
 
61
62
  def initialize(mutex: nil)
62
63
  # on cruby hash itself is threadsafe, but we need to prevent races
@@ -79,12 +80,19 @@ class DeprecationCollector
79
80
  # NB: in production with hugreds of workers may easily overload redis with writes, so more delay needed:
80
81
  @write_interval = 900 # 15.minutes
81
82
  @write_interval_jitter = 60
83
+ @context_saver = nil
82
84
  end
83
85
 
84
86
  def ignored_messages=(val)
85
87
  @ignore_message_regexp = (val && Regexp.union(val)) || nil
86
88
  end
87
89
 
90
+ def context_saver(&block)
91
+ return @context_saver unless block_given?
92
+
93
+ @context_saver = block
94
+ end
95
+
88
96
  def app_root_prefix
89
97
  "#{app_root}/"
90
98
  end
@@ -93,17 +101,20 @@ class DeprecationCollector
93
101
  @cleanup_prefixes ||= Gem.path + [app_root_prefix]
94
102
  end
95
103
 
96
- def collect(message, backtrace, realm = :unknown)
104
+ def collect(message, backtrace = caller_locations, realm = :unknown)
97
105
  return if !@enabled || exclude_realms.include?(realm) || @ignore_message_regexp&.match?(message)
98
106
  raise "Deprecation: #{message}" if @raise_on_deprecation
99
107
 
108
+ recursion_iterations_detected = backtrace.count { |l| l.path == __FILE__ && l.base_label == __method__.to_s }
109
+ return if recursion_iterations_detected > 1 # we have a loop, ignore deep nested deprecations
110
+
100
111
  deprecation = Deprecation.new(message, realm, backtrace, cleanup_prefixes)
101
- fresh = store_deprecation(deprecation)
112
+ fresh = store_deprecation(deprecation, allow_context: recursion_iterations_detected.zero?)
102
113
  log_deprecation_if_needed(deprecation, fresh)
103
114
  end
104
115
 
105
116
  def unsent_data?
106
- @deprecations.any?
117
+ unsent_deprecations.any?
107
118
  end
108
119
 
109
120
  def count?
@@ -116,7 +127,7 @@ class DeprecationCollector
116
127
  @redis
117
128
  end
118
129
 
119
- def write_to_redis(force: false) # rubocop:disable Metrics/AbcSize
130
+ def write_to_redis(force: false)
120
131
  return unless force || (@enabled && (current_time > @last_write_time + @write_interval))
121
132
 
122
133
  deprecations_to_flush = nil
@@ -225,9 +236,15 @@ class DeprecationCollector
225
236
 
226
237
  protected
227
238
 
228
- def store_deprecation(deprecation)
239
+ def unsent_deprecations
240
+ @deprecations
241
+ end
242
+
243
+ def store_deprecation(deprecation, allow_context: true)
229
244
  return if deprecation.ignored?
245
+
230
246
  fresh = !@deprecations.key?(deprecation.digest)
247
+ deprecation.context = context_saver.call if context_saver && allow_context
231
248
 
232
249
  @deprecations_mutex.synchronize do
233
250
  (@deprecations[deprecation.digest] ||= deprecation).touch
@@ -240,8 +257,9 @@ class DeprecationCollector
240
257
  def log_deprecation_if_needed(deprecation, fresh)
241
258
  return unless print_to_stderr && !deprecation.ignored?
242
259
  return unless fresh || print_recurring
260
+
243
261
  msg = deprecation.message
244
- msg = "DEPRECATION: #{msg}" unless msg.start_with?('DEPRECAT')
262
+ msg = "DEPRECATION: #{msg}" unless msg.start_with?("DEPRECAT")
245
263
  $stderr.puts(msg) # rubocop:disable Style/StderrPuts
246
264
  end
247
265
 
@@ -253,11 +271,13 @@ class DeprecationCollector
253
271
 
254
272
  def decode_deprecation(digest, data, count, notes)
255
273
  return nil unless data
274
+
256
275
  data = JSON.parse(data, symbolize_names: true)
257
276
  unless data.is_a?(Hash)
258
- binding.irb
277
+ # this should not happen (this means broken Deprecation#to_json or some data curruption)
259
278
  return nil
260
279
  end
280
+
261
281
  data[:digest] = digest
262
282
  data[:notes] = JSON.parse(notes, symbolize_names: true) if notes
263
283
  data[:count] = count.to_i if count
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecation_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Fedoseyev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-02 00:00:00.000000000 Z
11
+ date: 2022-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: appraisal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Collects and aggregates warnings and deprecations. Optimized for production
28
42
  environment.
29
43
  email:
@@ -34,6 +48,7 @@ extra_rdoc_files: []
34
48
  files:
35
49
  - ".rspec"
36
50
  - ".rubocop.yml"
51
+ - Appraisals
37
52
  - CHANGELOG.md
38
53
  - Gemfile
39
54
  - Gemfile.lock
@@ -42,6 +57,12 @@ files:
42
57
  - README.md
43
58
  - Rakefile
44
59
  - deprecation_collector.gemspec
60
+ - gemfiles/rails_6.gemfile
61
+ - gemfiles/rails_6.gemfile.lock
62
+ - gemfiles/rails_7.gemfile
63
+ - gemfiles/rails_7.gemfile.lock
64
+ - gemfiles/rails_none.gemfile
65
+ - gemfiles/rails_none.gemfile.lock
45
66
  - lib/deprecation_collector.rb
46
67
  - lib/deprecation_collector/collectors.rb
47
68
  - lib/deprecation_collector/deprecation.rb
@@ -54,7 +75,7 @@ metadata:
54
75
  homepage_uri: https://github.com/Vasfed/deprecation_collector
55
76
  source_code_uri: https://github.com/Vasfed/deprecation_collector
56
77
  changelog_uri: https://github.com/Vasfed/deprecation_collector/blob/main/CHANGELOG.md
57
- post_install_message:
78
+ post_install_message:
58
79
  rdoc_options: []
59
80
  require_paths:
60
81
  - lib
@@ -62,15 +83,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
83
  requirements:
63
84
  - - ">="
64
85
  - !ruby/object:Gem::Version
65
- version: 2.4.0
86
+ version: 2.5.0
66
87
  required_rubygems_version: !ruby/object:Gem::Requirement
67
88
  requirements:
68
89
  - - ">="
69
90
  - !ruby/object:Gem::Version
70
91
  version: '0'
71
92
  requirements: []
72
- rubygems_version: 3.1.6
73
- signing_key:
93
+ rubygems_version: 3.3.7
94
+ signing_key:
74
95
  specification_version: 4
75
96
  summary: Collector for ruby/rails deprecations and warnings, suitable for production
76
97
  test_files: []