rubocop:disable Metrics/AbcSize
 rubocop:disable Metrics/MethodLength
422611
def merge!(rel)
      return self if rel.nil?
      MULTI_VALUE_METHODS.each do |method|
        (@values[method] ||= []).concat(rel.values[method]).uniq! unless rel.values[method].nil?
      end

      MULTI_KEY_METHODS.each do |method|
        (@values[method] ||= {}).merge!(rel.values[method]) unless rel.values[method].nil?
      end

      SINGLE_VALUE_METHODS.each do |method|
        @values[method] = rel.values[method] unless rel.values[method].nil?
      end

      self
    end
546488
def method_missing(method, *args, **kwrest, &proc)
      method_name = method.to_s
      case
      when method_name.start_with?('on')
        event_name = method_name[(method_name[2] == '_' ? 3 : 2)..method_name.size]
        add_event(event_name.to_sym, *args, **kwrest, &proc)
      when method_name.start_with?('filter')
        event_name = method_name[(method_name[6] == '_' ? 7 : 6)..method_name.size]
        add_event_filter(event_name.to_sym, **kwrest, &proc)
      end
    end
456214
def standard?
      self.syntax = :invalid
      self.valid_size? or return false
      self.valid_encoding? or return false
      if self.local =~ STANDARD_LOCAL_REGEX
        self.syntax = :standard
        true
      else
        false
      end
    end
164369
def attributes!(object, *attrs)
      attrs.each do |attr|
        method_missing attr, object.send(attr)
      end
    end
739087
def method_missing m, *args, &block
      if method_name_is_tag_name? m
        return assign_tag(m, args, &block)
      elsif method_name_is_tag_adder_method? m 
        return extend_tag_list(m, args, &block)
      elsif method_name_is_tag_list_method? m
        return child_tags[m[0..-6].to_sym] ||= []
      elsif method_name_is_attr_accessor_method? m
        return assign_attribute(m[0..-6].to_sym, args, &block)
      end
      super(m, *args, &block)
    end
934320
def method_missing(name, *args, &block)
      return attr(name[0..-2], args[0]) if args.size == 1 and name[-1] == '='
    end
584210
def index
      if defined?(ActiveRecord)
        @ar_error_messages = params[:app] ? RailsExceptionHandler::ActiveRecord::ErrorMessage.where(app_name: params[:app]).order('created_at DESC') : RailsExceptionHandler::ActiveRecord::ErrorMessage.order('created_at DESC')
      end
      if defined?(Mongoid)
        @mg_error_messages = params[:app] ? RailsExceptionHandler::Mongoid::ErrorMessage.where(app_name: params[:app]).order(created_at: 'desc') : RailsExceptionHandler::Mongoid::ErrorMessage.order_by(created_at: 'desc')
      end
      if defined?(WillPaginate)
        @ar_error_messages = @ar_error_messages.paginate(page: params[:page] || 1, per_page: params[:per_page] || 100)
      elsif defined?(Kaminari)
        @ar_error_messages = @ar_error_messages.page(params[:page] || 1).per(params[:per_page] || 100)
      end

      respond_to do |format|
        format.html # index.html.erb
        format.json {
          if @ar_error_messages.present? && @mg_error_messages.present?
            json = {active_record: @ar_error_messages, mongoid: @mg_error_messages}
          elsif @ar_error_messages.present? && @mg_error_messages.blank?
            json = @ar_error_messages
          elsif @ar_error_messages.blank? && @mg_error_messages.present?
            json = @mg_error_messages
          end
          render json: json
        }
      end
    end
597262
def method_missing(*args, &block)
      if Namespace.exists?(args.first)
        create_namespace(args.first)
      else
        call_method(args, &block)
      end
    end
353468
def method_missing(name, *args, &block)
      if args.empty? && !block_given? && @arg_names.include?(name)
        @args[name]
      else
        super
      end
    end
895522
def method_missing(meth, *args, &block)
      if args.size == 1 and meth =~ /^(.+)=$/
        self[$1.to_sym] = args[0]
      else
        super meth, *args, &block
      end
    end
920244
def run # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
      original_directory = FileUtils.pwd
      box_name = ''

      # render the template
      rendered_template = template.render(name: name,
                                          provider: provider,
                                          scripts: scripts)

      # write the template to a file
      File.open(Boxes.config.working_dir + "#{build_name}.json", 'w') do |f|
        f.puts rendered_template
      end

      # set the environment vars
      Boxes.config.environment_vars.each do |e|
        e.each do |k, v|
          ENV[k] = v.to_s
        end
      end

      # execute the packer command
      FileUtils.chdir(Boxes.config.working_dir)
      cmd = "packer build #{build_name}.json"
      status = Subprocess.run(cmd) do |stdout, stderr, _thread|
        puts stdout unless stdout.nil?
        puts stderr unless stderr.nil?

        # catch the name of the artifact
        if stdout =~ /\.box/
          box_name = stdout.gsub(/[a-zA-Z0-9:\-_]*?\.box/).first
        end
      end

      if status.exitstatus == 0
        FileUtils.mv(Boxes.config.working_dir + box_name,
                     "#{original_directory}/#{name}.box")
      else
        fail BuildRunError,
             'The build didn\'t complete successfully. Check the logs.'
      end
    end
575880
def hash_for_railsbp(error)
        {
          'linter' => error['message'].gsub(/\((.*)\)/, '').strip.parameterize('_').camelize,
          'severity' => 'warning',
          'reason' => error['message'],
          'column' => 0,
          'line' => error['line_number'].to_i
        }
      end
1329526
def ! options = {}
      merged_options = merge_headers_and_queries options
      unless @stubbed
        self.class.send(@method, @path || '/', merged_options)
      else
        uri = "#{self.class.base_uri}#{@path}"

        stub_request(@method.to_sym, uri.to_s).with merged_options
      end
    end
243714
def sizes
      @attrs.fetch(:sizes, []).each_with_object({}) do |(key, value), object|
        object[key] = Size.new(value)
      end
    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
1072451
def method_missing(method, *args)
      attr_name, suffix = method.to_s.scan(/([a-z0-9\_]+)(\?|\=)?$/i).first
      if suffix == ATTR_SETTER
        @_metaclass.send(:attr_accessor, attr_name)
        @_fields << attr_name.to_sym
        send(method, args.first)
      elsif attr_name && @_fields.include?(attr_name.to_sym)
        value = @attrs[attr_name.to_sym]
        case suffix
        when nil
          @_metaclass.send(:attr_accessor, attr_name)
          value
        when ATTR_PREDICATE then !!value
        end
      elsif suffix.nil? && SPECIAL_METHODS.include?(attr_name)
        instance_variable_get "@_#{attr_name}"
      elsif attr_name && !@_fields.include?(attr_name.to_sym)
        nil
      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