<commit_before>require 'mspec/guards/version'

if RUBY_ENGINE == "ruby" and ruby_version_is("2.4")
  ruby_version_is "2.4"..."2.5" do
    # Kernel#warn does not delegate to Warning.warn in 2.4
    module Kernel
      remove_method :warn
      def warn(*messages)
        return if $VERBOSE == nil or messages.empty?
        msg = messages.join("\n")
        msg += "\n" unless msg.end_with?("\n")
        Warning.warn(msg)
      end
      private :warn
    end
  end

  def Warning.warn(message)
    # Suppress any warning inside the method to prevent recurse
    verbose = $VERBOSE
    $VERBOSE = nil

    if Thread.current[:in_mspec_complain_matcher]
      return $stderr.write(message)
    end

    case message
    # $VERBOSE = true warnings
    when /(.+\.rb):(\d+):.+possibly useless use of (<|<=|==|>=|>) in void context/
      # Make sure there is a .should otherwise it is missing
      line_nb = Integer($2)
      unless File.exist?($1) and /\.should(_not)? (<|<=|==|>=|>)/ === File.readlines($1)[line_nb-1]<commit_msg>Fix typo<commit_after>require 'mspec/guards/version'

if RUBY_ENGINE == "ruby" and ruby_version_is("2.4")
  ruby_version_is "2.4"..."2.5" do
    # Kernel#warn does not delegate to Warning.warn in 2.4
    module Kernel
      remove_method :warn
      def warn(*messages)
        return if $VERBOSE == nil or messages.empty?
        msg = messages.join("\n")
        msg += "\n" unless msg.end_with?("\n")
        Warning.warn(msg)
      end
      private :warn
    end
  end

  def Warning.warn(message)
    # Suppress any warning inside the method to prevent recursion
    verbose = $VERBOSE
    $VERBOSE = nil

    if Thread.current[:in_mspec_complain_matcher]
      return $stderr.write(message)
    end

    case message
    # $VERBOSE = true warnings
    when /(.+\.rb):(\d+):.+possibly useless use of (<|<=|==|>=|>) in void context/
      # Make sure there is a .should otherwise it is missing
      line_nb = Integer($2)
      unless File.exist?($1) and /\.should(_not)? (<|<=|==|>=|>)/ === File.readlines($1)[line_nb-1]
{'fraction_non_alphanumeric': 0.14793187347931874, 'fraction_numerical': 0.01167883211678832, 'mean_word_length': 2.7246376811594204, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5540203', 'n_tokens_mistral': 720, 'n_tokens_neox': 676, 'n_words': 184}