Module: ActiveSupport::RaiseWarnings

Defined in:
lib/active_support/testing/strict_warnings.rb

Overview

:nodoc:

Constant Summary collapse

PROJECT_ROOT =
File.expand_path("../../../../", __dir__)
ALLOWED_WARNINGS =
Regexp.union(
  /circular require considered harmful.*delayed_job/, # Bug in delayed job.

  # Expected non-verbose warning emitted by Rails.
  /Ignoring .*\.yml because it has expired/,
  /Failed to validate the schema cache because/,
)
SUPPRESSED_WARNINGS =
Regexp.union(
  # TODO: remove if https://github.com/mikel/mail/pull/1557 or similar fix
  %r{/lib/mail/parsers/.*statement not reached},
  %r{/lib/mail/parsers/.*assigned but unused variable - disp_type_s},
  %r{/lib/mail/parsers/.*assigned but unused variable - testEof}
)

Instance Method Summary collapse

Instance Method Details

#warn(message) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/active_support/testing/strict_warnings.rb', line 24

def warn(message, *)
  return if SUPPRESSED_WARNINGS.match?(message)

  super

  return unless message.include?(PROJECT_ROOT)
  return if ALLOWED_WARNINGS.match?(message)
  return unless ENV["RAILS_STRICT_WARNINGS"] || ENV["CI"]

  raise message
end