Sha256: e11723d9aa5de896008a531dc5acbf18f950c3faaae14fc07e9abf12fd26ebc8

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

$VERBOSE = true
Warning[:deprecated] = true

module ActiveSupport
  module RaiseWarnings # :nodoc:
    class WarningError < StandardError; end

    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/,

      # TODO: We need to decide what to do with this.
      /Status code :unprocessable_entity is deprecated/
    )

    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}
    )

    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["BUILDKITE"]

      raise WarningError.new(message)
    end
  end
end

Warning.singleton_class.prepend(ActiveSupport::RaiseWarnings)

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
activesupport-7.2.2.1 lib/active_support/testing/strict_warnings.rb
activesupport-7.2.2 lib/active_support/testing/strict_warnings.rb
activesupport-8.0.0.beta1 lib/active_support/testing/strict_warnings.rb
omg-activesupport-8.0.0.alpha9 lib/active_support/testing/strict_warnings.rb
omg-activesupport-8.0.0.alpha8 lib/active_support/testing/strict_warnings.rb
omg-activesupport-8.0.0.alpha7 lib/active_support/testing/strict_warnings.rb
omg-activesupport-8.0.0.alpha4 lib/active_support/testing/strict_warnings.rb
omg-activesupport-8.0.0.alpha3 lib/active_support/testing/strict_warnings.rb
omg-activesupport-8.0.0.alpha2 lib/active_support/testing/strict_warnings.rb
omg-activesupport-8.0.0.alpha1 lib/active_support/testing/strict_warnings.rb