rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
 rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity
 rubocop:disable Metrics/BlockNesting, Metrics/BlockLength
775353
def print_string(s)
      s = s.to_s.dup
      until s.empty?
        if s.sub!(/([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)/, '\5')
          @out.write(concealed(Regexp.last_match(1)))
          if Regexp.last_match(2) == '[' && Regexp.last_match(4) == 'm'
            attrs = Regexp.last_match(3).split(';')
            attrs.push(nil) unless attrs
            attrs.each do |attr|
              atv = attr.to_i
              case atv
              when 0
                reset_colors
              when 1
                @bold = true
              when 21
                @bold = false
              when 4
                @underline = true
              when 24
                @underline = false
              when 7
                @revideo = true
              when 27
                @revideo = false
              when 8
                @concealed = true
              when 28
                @concealed = false
              when 30..37
                @foreground = ANSI2WIN[atv - 30]
              when 39
                @foreground = @default_foreground
              when 40..47
                @background = ANSI2WIN[atv - 40]
              when 49
                @background = @default_background
              end
            end

            attrib = @revideo ? (@background | (@foreground << 4)) : (@foreground | (@background << 4))
            attrib |= 0x08 if @bold
            attrib |= 0x400 if @underline

            WinColors.SetConsoleTextAttribute(@handle, attrib)
          end
        else
          @out.write(concealed(s))
          s = ''
        end
      end
    end
575066
def method_missing(meth, *args, &block)
      @namespace = meth.to_s
      @message   = (args.first.to_s == 'debug') ? nil : args.first.to_s
      self.send :output!
    end
763039
def method_missing(method, *args, &block)
      super
    rescue NoMethodError
      return regs(method) if self.has_reg?(method)
      return ports(method) if self.has_port?(method)
      if method.to_s =~ /=$/
        define_singleton_method(method) do |val|
          instance_variable_set("@#{method.to_s.sub('=', '')}", val)
        end
      else
        define_singleton_method(method) do
          instance_variable_get("@#{method}")
        end
      end
      send(method, *args, &block)
    end
1290131
def content_length
      # http://greenbytes.de/tech/webdav/rfc7230.html#rfc.section.3.3.3
      # Clause 3: "If a message is received with both a Transfer-Encoding
      # and a Content-Length header field, the Transfer-Encoding overrides the Content-Length.
      return nil if @headers.include?(Headers::TRANSFER_ENCODING)

      value = @headers[Headers::CONTENT_LENGTH]
      return nil unless value

      begin
        Integer(value)
      rescue ArgumentError
        nil
      end
    end
223223
def big_endian_lengths(bytes)
      lengths = [] # we can't use a hash since the order will be screwed in Ruby 1.8
      lengths << [:options, (bytes.shift << 8) | bytes.shift]                                             # 2 bytes   Length of the "options" field
      lengths << [:id,      (bytes.shift << 8) | bytes.shift]                                             # 2 bytes   Length of the "ID" or "name" field
      lengths << [:type,    (bytes.shift << 8) | bytes.shift]                                             # 2 bytes   Length of the "type" field
      lengths << [:data,    (bytes.shift << 24) | (bytes.shift << 16) | (bytes.shift << 8) | bytes.shift] # 4 bytes   Size of the included file
      lengths
    end
255275
def method_missing(meth, *args, &block)
      db.to_hash(:key, :value).send(meth, *args, &block)
    end
530776
def method_missing(method, *args, &block)
      if method[-1] == '='
        # setter
        key = method.slice(0...-1).to_sym

        unless has_key?(key)
          super
        end
        self[key] = args[0]
      else
        unless has_key?(method)
          super
        end

        prop = self[method]
        if prop.is_a? JSFunction
          prop.call_with_instance(self, *args, &block)
        else
          prop
        end
      end
    end
336415
def method_missing(method, *args)
      unless args.size == 1 && [Hash, Array].include?(args[0].class)
        raise 'Expected 1 Hash or Array argument'
      end

      call_remote method, args[0]
    end
85349
def calculate_block_size
      char_amount = 1
      base_length = @oracle.encipher(DUMMY * char_amount).length
      result = nil
      (1..MAX_KNOWN_BLOCK_LENGTH).each do |length|
        new_length   = @oracle.encipher(DUMMY * char_amount).length
        if new_length > base_length
          result = new_length - base_length
          break
        end
        char_amount += 1
      end
      result
    end
663345
def method_missing(meth, *args, &block)
      meth_str = meth.to_s

      if /^(\w+)\=$/.match(meth_str)
        _set($1, *args, &block)
      elsif args.length > 0 || block_given?
        _add(meth, *args, &block)
      elsif /^(\w+)\?$/.match(meth_str)
        !!_get($1)
      else
        _get_or_create_namespace(meth)
      end
    end
1304308
def method_missing(name, *args, &block)
      if name.to_s[-1] == '='
        config[name[0..-2].to_s.upcase] = args[0]
      else
        config.fetch(name.to_s.upcase) {nil}
      end
    end
392899
def method_missing mtd, *args
      if mtd.to_s.chars.to_a.last == '='
        raise ArgumentError, "Invalid number of arguments (#{args.length} for 1)" if args.length != 1
        attributes[mtd.to_s.slice(0,mtd.to_s.length-1)] = args.first
      else
        raise ArgumentError, "Invalid number of arguments (#{args.length} for 0)" if args.length != 0
        attributes[mtd.to_s]
      end
    end
182657
def method_missing(method, *args, &code)
    success = false
    result  = nil

    if method.to_s.match(/^set\_([a-z].*)$/)
      name = $1.to_sym

      if @types.has_key?(name) && args.length > 2
        @types[name].set([ args[0], args[1] ], args[2]) if args.length > 2
        success = true
      end

    elsif method.to_s.match(/^remove\_([a-z].*)$/)
      name = $1.to_sym

      if @types.has_key?(name) && args.length > 0
        @types[name].delete([ args[0], args[1] ])
        success = true
      end

    else
      name = @plurals[method.to_sym]

      if name && @types.has_key?(name)
        result  = @types[name]
        success = true
      end
    end
    super unless success # Raise NoMethodError
    result
  end
700577
def method_missing(id_or_class, *args, &block)
      if id_or_class.to_s =~ /(.*)!$/
        @attrs[:id] = $1
      else
        id = id_or_class
        @attrs[:class] = @attrs[:class] ? "#{@attrs[:class]} #{id}".strip : id
      end

      unless args.empty?
        if args.last.respond_to? :to_hash
          @attrs.merge! args.pop.to_hash
        end
      end

      args.push(@attrs)

      while @stream.length > @original_stream_length
        @stream.pop
      end

      if block
        @builder.tag! @sym, *args, &block
      else
        @builder.tag! @sym, *args
      end

      self
    end
780013
def mentions_erb
      retdict = {
        enabled: @config[:mentions][:enabled],
        top: [],
        nottop: []
      }

      if @config[:mentions][:enabled]
        top = @parsed[:mentions].slice(0, @config[:mentions][:top]) # top X mentions
        top.each do |mention|
          retdict[:top] << mention[1]
        end

        nottop = @parsed[:mentions].slice(@config[:mentions][:top], @config[:mentions][:notop]) # not in the top X
        unless nottop.nil?
          nottop.each do |mention|
            mention[1].delete(:example)
            retdict[:nottop] << mention[1]
          end
        end
      end

      retdict
    end
662873
def method_missing(meth, *args, &block)

      if @categories.include?(meth)

        if block_given?
          args[0] = yield block
        end

        self::msg(meth, args[0])

      else
        super
      end

    end
636241
def destroy_all
      if defined?(ActiveRecord)
        if params[:app]
          RailsExceptionHandler::ActiveRecord::ErrorMessage.destroy_all(app_name: params[:app])
        else
          RailsExceptionHandler::ActiveRecord::ErrorMessage.destroy_all
        end
      end
      if defined?(Mongoid)
        if params[:app]
          RailsExceptionHandler::Mongoid::ErrorMessage.where(app_name: params[:app]).destroy
        else
          RailsExceptionHandler::Mongoid::ErrorMessage.all.destroy
        end
      end

      respond_to do |format|
        format.html { redirect_to error_messages_url }
        format.json { head :no_content }
      end
    end