Method: Warning::Processor#ignore
- Defined in:
- lib/warning.rb
#ignore(regexp, path = '') ⇒ Object
Ignore any warning messages matching the given regexp, if they start with the given path. The regexp can also be one of the following symbols (or an array including them), which will use an appropriate regexp for the given warning:
- :arg_prefix
-
Ignore warnings when using * or & as an argument prefix
- :ambiguous_slash
-
Ignore warnings for things like
method /regexp/ - :bignum
-
Ignore warnings when referencing the ::Bignum constant.
- :default_gem_removal
-
Ignore warnings that a gem will be removed from the default gems in a future Ruby version.
- :fixnum
-
Ignore warnings when referencing the ::Fixnum constant.
- :keyword_separation
-
Ignore warnings related to keyword argument separation.
- :method_redefined
-
Ignore warnings when defining a method in a class/module where a method of the same name was already defined in that class/module.
- :missing_gvar
-
Ignore warnings for accesses to global variables that have not yet been initialized
- :missing_ivar
-
Ignore warnings for accesses to instance variables that have not yet been initialized
- :not_reached
-
Ignore statement not reached warnings.
- :safe
-
Ignore warnings related to $SAFE and related C-API functions.
- :shadow
-
Ignore warnings related to shadowing outer local variables.
- :taint
-
Ignore warnings related to taint and related methods and C-API functions.
- :unused_var
-
Ignore warnings for unused variables.
- :useless_operator
-
Ignore warnings when using operators such as == and > when the result is not used.
- :void_context
- Ignore warnings for
-
to reference constants when the result is not
used (often used to trigger autoload).
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 uninitialized instance variable and method redefined warnings in current file
Warning.ignore([:missing_ivar, :method_redefined], __FILE__)
132 133 134 135 136 137 138 139 140 141 |
# File 'lib/warning.rb', line 132 def ignore(regexp, path='') unless regexp = convert_regexp(regexp) raise TypeError, "first argument to Warning.ignore should be Regexp, Symbol, or Array of Symbols, got #{regexp.inspect}" end synchronize do @ignore << [path, regexp] end nil end |