railsdog/spree_shipping_labels

View on GitHub
app/models/spree/shipment_provider/stamps.rb

Summary

Maintainability
A
0 mins
Test Coverage

Assignment Branch Condition size for generate_label! is too high. [22.76/15]
Open

  def generate_label!
    add_ons = ['SC-A-HP'] # Make the postage cost hidden on the printout

    # Only assign the insurance add-on IF the package has insurable value
    add_ons << 'SC-A-INS' if package_for_label.value

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [12/10]
Open

  def generate_label!
    add_ons = ['SC-A-HP'] # Make the postage cost hidden on the printout

    # Only assign the insurance add-on IF the package has insurable value
    add_ons << 'SC-A-INS' if package_for_label.value

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Line is too long. [84/80]
Open

    response = io.create_shipment from_location, to_location, package_for_label, [],

Line is too long. [92/80]
Open

      service: ActiveShipping::Stamps::SERVICE_TYPES.invert[@service_type], add_ons: add_ons

Missing top-level class documentation comment.
Open

class Spree::ShipmentProvider::Stamps

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Align the parameters of a method call if they span more than one line.
Open

      service: ActiveShipping::Stamps::SERVICE_TYPES.invert[@service_type], add_ons: add_ons

Here we check if the parameters on a multi-line method call or definition are aligned.

Example: EnforcedStyle: withfirstparameter (default)

# good

foo :bar,
    :baz

# bad

foo :bar,
  :baz

Example: EnforcedStyle: withfixedindentation

# good

foo :bar,
  :baz

# bad

foo :bar,
    :baz

Use def with parentheses when there are parameters.
Open

  def config options

This cops checks for parentheses around the arguments in method definitions. Both instance and class/singleton methods are checked.

Example: EnforcedStyle: require_parentheses (default)

# The `require_parentheses` style requires method definitions
# to always use parentheses

# bad
def bar num1, num2
  num1 + num2
end

def foo descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name
  do_something
end

# good
def bar(num1, num2)
  num1 + num2
end

def foo(descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name)
  do_something
end

Example: EnforcedStyle: requirenoparentheses

# The `require_no_parentheses` style requires method definitions
# to never use parentheses

# bad
def bar(num1, num2)
  num1 + num2
end

def foo(descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name)
  do_something
end

# good
def bar num1, num2
  num1 + num2
end

def foo descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name
  do_something
end

Example: EnforcedStyle: requirenoparenthesesexceptmultiline

# The `require_no_parentheses_except_multiline` style prefers no
# parantheses when method definition arguments fit on single line,
# but prefers parantheses when arguments span multiple lines.

# bad
def bar(num1, num2)
  num1 + num2
end

def foo descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name
  do_something
end

# good
def bar num1, num2
  num1 + num2
end

def foo(descriptive_var_name,
        another_descriptive_var_name,
        last_descriptive_var_name)
  do_something
end

Use nested module/class definitions instead of compact style.
Open

class Spree::ShipmentProvider::Stamps

This cop checks the style of children definitions at classes and modules. Basically there are two different styles:

Example: EnforcedStyle: nested (default)

# good
# have each child on its own line
class Foo
  class Bar
  end
end

Example: EnforcedStyle: compact

# good
# combine definitions as much as possible
class Foo::Bar
end

The compact style is only forced for classes/modules with one child.

Favor a normal if-statement over a modifier clause in a multiline statement.
Open

    ActiveRecord::Base.transaction do
      @package.update_attributes! tracking: response.tracking_number
      label = @package.label || @package.build_label
      label.cost = response.rate.price.to_f / 100
      label.label_image = response.label_url

Checks for uses of if/unless modifiers with multiple-lines bodies.

Example:

# bad
{
  result: 'this should not happen'
} unless cond

# good
{ result: 'ok' } if cond

Avoid comma after the last item of a hash.
Open

      integration_id: options['integration_id'],

This cop checks for trailing comma in array and hash literals.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = [1, 2,]

# good
a = [
  1, 2,
  3,
]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: comma

# bad
a = [1, 2,]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = [1, 2,]

# good
a = [
  1,
  2
]

There are no issues that match your filters.

Category
Status