https://github.com/jeremyevans/ruby-warning
Add custom processing for warnings
https://github.com/jeremyevans/ruby-warning
Keywords from Contributors
activejob activerecord mvc ruby-gem rubygems repl rack static-code-analysis rubocop code-formatter
Last synced: about 16 hours ago
JSON representation
Repository metadata
Add custom processing for warnings
- Host: GitHub
- URL: https://github.com/jeremyevans/ruby-warning
- Owner: jeremyevans
- License: other
- Created: 2016-08-09T16:37:28.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-12-22T00:51:15.000Z (2 months ago)
- Last Synced: 2026-02-28T10:16:45.178Z (4 days ago)
- Language: Ruby
- Size: 64.5 KB
- Stars: 296
- Watchers: 7
- Forks: 12
- Open Issues: 0
- Releases: 0
-
Metadata Files:
- Readme: README.rdoc
- Changelog: CHANGELOG
- License: MIT-LICENSE
README.rdoc
= ruby-warning
ruby-warning adds custom processing for warnings, including the
ability to ignore specific warning messages, ignore warnings
in specific files/directories, include backtraces with warnings,
treat warnings as errors, deduplicate warnings, and add
custom handling for all warnings in specific files/directories.
ruby-warning requires ruby 2.4+, as previous versions of ruby do
not support custom processing of warnings.
= Installation
gem install warning
= Source Code
Source code is available on GitHub at https://github.com/jeremyevans/ruby-warning
= Usage
By default, requiring the library does not make changes to how ruby processes
warnings, it just adds methods that allow you to customize the processing.
Warning.ignore takes a regexp and optionally a path prefix, and ignores
any warning that matches the regular expression if it starts with the path
prefix. It can also take a symbol or an array of symbols, and will use an
appropriate regexp. The supported symbols are:
* :arg_prefix
* :ambiguous_slash
* :bignum
* :default_gem_removal
* :fixnum
* :ignored_block
* :keyword_separation
* :method_redefined
* :mismatched_indentations
* :missing_gvar
* :missing_ivar
* :not_reached
* :safe
* :shadow
* :taint
* :unused_var
* :useless_operator
* :void_context
Warning.process takes an optional path prefix and a block, and if the
warning string starts with the path prefix, it calls the block with the warning
string instead of performing the default behavior. You can call
Warning.process multiple times and it will operate intelligently,
choosing the longest path prefix that the string starts with.
Warning.process blocks can return +:default+ to use the default
behavior, +:backtrace+ to use the default behavior and also print the backtrace
or +:raise+ to raise the warning string as a RuntimeError.
Warning.process can also accept a hash of actions instead of a block,
with keys being regexps (or symbols supported by Warning.ignore) and
values being callable objects (or +:default+, +:backtrace+, or +:raise+).
Warning.dedup deduplicates warnings, so that if a warning is received
that is the same as a warning that has already been processed, the warning is
ignored. Note that this should be used with care, since if the application
generates an arbitrary number of unique warnings, that can lead to unbounded
memory growth.
Warning.clear resets the library to its initial state, clearing the
current ignored warnings and warning processors, and turning off deduplication.
By using path prefixes, it's fairly easy for a gem to set that specific warnings
should be ignored inside the gem's directory.
Note that path prefixes will not correctly handle warnings raised by
Kernel#warn, unless the warning message given to Kernel#warn
starts with the filename where the warning is used. The Kernel#warn
+:uplevel+ option will make sure the warning starts with the filename.
Note that many of the warnings this library can ignore are warnings caused
during compilation (i.e. when files are loaded via require). You should
require this library and setup the appropriate warning handling before
loading any code that could cause warnings.
= Examples
# Ignore all uninitialized instance variable warnings
Warning.ignore(/instance variable @\w+ not initialized/)
# Ignore all uninitialized instance variable warnings in current file
Warning.ignore(/instance variable @\w+ not initialized/, __FILE__)
# Ignore all uninitialized instance variable warnings in current file
Warning.ignore(:missing_ivar, __FILE__)
# Ignore all Fixnum and Bignum warnings in current file
Warning.ignore([:fixnum, :bignum], __FILE__)
# Write warning to LOGGER at level warning
Warning.process do |warning|
LOGGER.warning(warning)
end
# Write warnings in the current file to LOGGER at level error
Warning.process(__FILE__) do |warning|
LOGGER.error(warning)
end
# Write warnings in the current file to $stderr, but include backtrace
Warning.process(__FILE__) do |warning|
:backtrace
end
# Raise warnings in the current file as RuntimeErrors, with the warning
# string as the exception message
Warning.process(__FILE__) do |warning|
:raise
end
# Raise keyword argument separation warnings in the current file as
# RuntimeErrors, and write ambiguous slash warnings to $stderr, including
# the backtrace
Warning.process(__FILE__, keyword_separation: :raise,
ambiguous_slash: :backtrace)
# Deduplicate warnings
Warning.dedup
# Ignore all warnings in Gem dependencies
Gem.path.each do |path|
Warning.ignore(//, path)
end
= License
MIT
= Author
Jeremy Evans
Owner metadata
- Name: Jeremy Evans
- Login: jeremyevans
- Email:
- Kind: user
- Description: Ruby Committer. Author of "Polished Ruby Programming". Lead developer of Sequel, Roda, and Rodauth. OpenBSD ruby ports maintainer.
- Website: http://code.jeremyevans.net
- Location: Sacramento, California, USA
- Twitter: jeremyevans0
- Company:
- Icon url: https://avatars.githubusercontent.com/u/3846?u=42e153d8b1f8e31db8d838217fd6f849ad0f6b1c&v=4
- Repositories: 218
- Last ynced at: 2023-04-10T07:45:58.723Z
- Profile URL: https://github.com/jeremyevans
GitHub Events
Total
- Watch event: 13
- Issue comment event: 2
- Push event: 5
- Fork event: 1
- Create event: 1
Last Year
- Watch event: 11
- Push event: 2
- Fork event: 1
Committers metadata
Last synced: 2 days ago
Total Commits: 74
Total Committers: 7
Avg Commits per committer: 10.571
Development Distribution Score (DDS): 0.122
Commits in past year: 3
Committers in past year: 1
Avg Commits per committer in past year: 3.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Jeremy Evans | c****e@j****t | 65 |
| Peter Leitzen | p****r@l****e | 2 |
| MicMicMon | m****o@q****o | 2 |
| Kenichi Kamiya | k****1@g****m | 2 |
| Masataka Pocke Kuwabara | k****a@p****e | 1 |
| Jamie McCarthy | j****e@m****g | 1 |
| Adam Daniels | a****m@m****a | 1 |
Committer domains:
- mediadrive.ca: 1
- mccarthy.vg: 1
- pocke.me: 1
- qontrol.io: 1
- leitzen.de: 1
- jeremyevans.net: 1
Issue and Pull Request metadata
Last synced: 8 days ago
Total issues: 12
Total pull requests: 9
Average time to close issues: about 8 hours
Average time to close pull requests: about 5 hours
Total issue authors: 9
Total pull request authors: 6
Average comments per issue: 2.33
Average comments per pull request: 2.44
Merged pull request: 7
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- splattael (3)
- AlexWayfer (2)
- bubaflub (1)
- ngouy (1)
- Nowaker (1)
- yosiat (1)
- veganstraightedge (1)
- ttrmw (1)
- samnissen (1)
Top Pull Request Authors
- kachick (3)
- splattael (2)
- qortex (1)
- Rylan12 (1)
- jamiemccarthy (1)
- adam12 (1)
- pocke (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 9
-
Total downloads:
- rubygems: 124,545,568 total
- Total docker downloads: 872,353,460
- Total dependent packages: 53 (may contain duplicates)
- Total dependent repositories: 962 (may contain duplicates)
- Total versions: 27
- Total maintainers: 1
gem.coop: warning
ruby-warning adds custom processing for warnings, including the ability to ignore specific warning messages, ignore warnings in specific files/directories, include backtraces with warnings, treat warnings as errors, deduplicate warnings, and add custom handling for all warnings in specific files/directories.
- Homepage: https://github.com/jeremyevans/ruby-warning
- Documentation: http://www.rubydoc.info/gems/warning/
- Licenses: MIT
- Latest release: 1.5.0 (published about 1 year ago)
- Last Synced: 2026-03-01T21:01:36.204Z (2 days ago)
- Versions: 10
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 62,280,422 Total
- Docker Downloads: 436,176,730
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.183%
- Docker downloads count: 0.276%
- Downloads: 0.456%
- Maintainers (1)
debian-12: ruby-warning
- Homepage: https://github.com/jeremyevans/ruby-warning
- Documentation: https://packages.debian.org/bookworm/ruby-warning
- Licenses: other
- Latest release: 1.3.0-1 (published 19 days ago)
- Last Synced: 2026-02-12T23:44:07.431Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 1.28%
- Stargazers count: 1.862%
- Forks count: 3.259%
rubygems.org: warning
ruby-warning adds custom processing for warnings, including the ability to ignore specific warning messages, ignore warnings in specific files/directories, include backtraces with warnings, treat warnings as errors, deduplicate warnings, and add custom handling for all warnings in specific files/directories.
- Homepage: https://github.com/jeremyevans/ruby-warning
- Documentation: http://www.rubydoc.info/gems/warning/
- Licenses: MIT
- Latest release: 1.5.0 (published about 1 year ago)
- Last Synced: 2026-02-28T06:01:30.641Z (4 days ago)
- Versions: 10
- Dependent Packages: 53
- Dependent Repositories: 962
- Downloads: 62,265,146 Total
- Docker Downloads: 436,176,730
-
Rankings:
- Docker downloads count: 0.343%
- Dependent packages count: 0.522%
- Downloads: 0.58%
- Dependent repos count: 1.057%
- Average: 2.323%
- Stargazers count: 3.452%
- Forks count: 7.986%
- Maintainers (1)
ubuntu-23.10: ruby-warning
- Homepage: https://github.com/jeremyevans/ruby-warning
- Licenses:
- Latest release: 1.3.0-1 (published 18 days ago)
- Last Synced: 2026-02-13T18:35:35.829Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.04: ruby-warning
- Homepage: https://github.com/jeremyevans/ruby-warning
- Licenses:
- Latest release: 1.3.0-1 (published 21 days ago)
- Last Synced: 2026-02-11T06:52:26.637Z (21 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-22.04: ruby-warning
- Homepage: https://github.com/jeremyevans/ruby-warning
- Licenses:
- Latest release: 1.2.1-2 (published 18 days ago)
- Last Synced: 2026-02-13T13:28:28.626Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-13: ruby-warning
- Homepage: https://github.com/jeremyevans/ruby-warning
- Documentation: https://packages.debian.org/trixie/ruby-warning
- Licenses:
- Latest release: 1.3.0-1 (published 19 days ago)
- Last Synced: 2026-02-13T13:20:47.704Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- minitest-global_expectations >= 0 development
- actions/checkout v2 composite
- ruby/setup-ruby v1 composite
Score: 28.356431175076235