3scale/porta

View on GitHub
app/workers/report_traffic_worker.rb

Summary

Maintainability
A
35 mins
Test Coverage

ReportTrafficWorker#perform has 5 parameters
Open

  def perform(account_id, metric_system_name, request, response, timestamp = Time.now)
Severity: Minor
Found in app/workers/report_traffic_worker.rb by reek

A Long Parameter List occurs when a method has a lot of parameters.

Example

Given

class Dummy
  def long_list(foo,bar,baz,fling,flung)
    puts foo,bar,baz,fling,flung
  end
end

Reek would report the following warning:

test.rb -- 1 warning:
  [2]:Dummy#long_list has 5 parameters (LongParameterList)

A common solution to this problem would be the introduction of parameter objects.

ReportTrafficWorker#enqueue has 4 parameters
Open

    def enqueue(account, metric_system_name, request, response)
Severity: Minor
Found in app/workers/report_traffic_worker.rb by reek

A Long Parameter List occurs when a method has a lot of parameters.

Example

Given

class Dummy
  def long_list(foo,bar,baz,fling,flung)
    puts foo,bar,baz,fling,flung
  end
end

Reek would report the following warning:

test.rb -- 1 warning:
  [2]:Dummy#long_list has 5 parameters (LongParameterList)

A common solution to this problem would be the introduction of parameter objects.

Method perform has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def perform(account_id, metric_system_name, request, response, timestamp = Time.now)
Severity: Minor
Found in app/workers/report_traffic_worker.rb - About 35 mins to fix

    ReportTrafficWorker#filter_response_attrs calls 'response.status' 2 times
    Open

            code:   response.status,
            length: response.body.length,
            body:   (DISCARD_CODES.cover?(response.status) ? "discarded" : response.body),
    Severity: Minor
    Found in app/workers/report_traffic_worker.rb by reek

    Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

    Reek implements a check for Duplicate Method Call.

    Example

    Here's a very much simplified and contrived example. The following method will report a warning:

    def double_thing()
      @other.thing + @other.thing
    end

    One quick approach to silence Reek would be to refactor the code thus:

    def double_thing()
      thing = @other.thing
      thing + thing
    end

    A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

    class Other
      def double_thing()
        thing + thing
      end
    end

    The approach you take will depend on balancing other factors in your code.

    ReportTrafficWorker#filter_response_attrs calls 'response.body' 2 times
    Open

            length: response.body.length,
            body:   (DISCARD_CODES.cover?(response.status) ? "discarded" : response.body),
    Severity: Minor
    Found in app/workers/report_traffic_worker.rb by reek

    Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

    Reek implements a check for Duplicate Method Call.

    Example

    Here's a very much simplified and contrived example. The following method will report a warning:

    def double_thing()
      @other.thing + @other.thing
    end

    One quick approach to silence Reek would be to refactor the code thus:

    def double_thing()
      thing = @other.thing
      thing + thing
    end

    A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

    class Other
      def double_thing()
        thing + thing
      end
    end

    The approach you take will depend on balancing other factors in your code.

    ReportTrafficWorker#filter_request_attrs has the variable name 'k'
    Open

            headers:   request.headers.select { |k, v| k =~ /HTTP_/ },
    Severity: Minor
    Found in app/workers/report_traffic_worker.rb by reek

    An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

    Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

    ReportTrafficWorker#filter_request_attrs has the variable name 'v'
    Open

            headers:   request.headers.select { |k, v| k =~ /HTTP_/ },
    Severity: Minor
    Found in app/workers/report_traffic_worker.rb by reek

    An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

    Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

    There are no issues that match your filters.

    Category
    Status