initiatived21/d21

View on GitHub
app/lib/card_renderer.rb

Summary

Maintainability
A
0 mins
Test Coverage

Put empty method definitions on a single line.
Open

  def request
  end
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks for the formatting of empty method definitions. By default it enforces empty method definitions to go on a single line (compact style), but it can be configured to enforce the end to go on its own line (expanded style).

Note: A method definition is not considered empty if it contains comments.

Example: EnforcedStyle: compact (default)

# bad
def foo(bar)
end

def self.foo(bar)
end

# good
def foo(bar); end

def foo(bar)
  # baz
end

def self.foo(bar); end

Example: EnforcedStyle: expanded

# bad
def foo(bar); end

def self.foo(bar); end

# good
def foo(bar)
end

def self.foo(bar)
end

Use meaningful heredoc delimiters.
Open

  EOF
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks that your heredocs are using meaningful delimiters. By default it disallows END and EO*, and can be configured through blacklisting additional delimiters.

Example:

# good
<<-SQL
  SELECT * FROM foo
SQL

# bad
<<-END
  SELECT * FROM foo
END

# bad
<<-EOS
  SELECT * FROM foo
EOS

Put empty method definitions on a single line.
Open

  def controller
  end
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks for the formatting of empty method definitions. By default it enforces empty method definitions to go on a single line (compact style), but it can be configured to enforce the end to go on its own line (expanded style).

Note: A method definition is not considered empty if it contains comments.

Example: EnforcedStyle: compact (default)

# bad
def foo(bar)
end

def self.foo(bar)
end

# good
def foo(bar); end

def foo(bar)
  # baz
end

def self.foo(bar); end

Example: EnforcedStyle: expanded

# bad
def foo(bar); end

def self.foo(bar); end

# good
def foo(bar)
end

def self.foo(bar)
end

Freeze mutable objects assigned to constants.
Open

  CARD_FILENAME_EN = 'pledge_card_en.png'
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Missing magic comment # frozen_string_literal: true.
Open

require 'image_optim'
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop is designed to help upgrade to Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

Example: EnforcedStyle: when_needed (default)

# The `when_needed` style will add the frozen string literal comment
# to files only when the `TargetRubyVersion` is set to 2.3+.
# bad
module Foo
  # ...
end

# good
# frozen_string_literal: true

module Foo
  # ...
end

Example: EnforcedStyle: always

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

Method definitions must not be nested. Use lambda instead.
Open

      def @image_data.original_filename; CARD_FILENAME_DE; end
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks for nested method definitions.

Example:

# bad

# `bar` definition actually produces methods in the same scope
# as the outer `foo` method. Furthermore, the `bar` method
# will be redefined every time `foo` is invoked.
def foo
  def bar
  end
end

Example:

# good

def foo
  bar = -> { puts 'hello' }
  bar.call
end

Example:

# good

def foo
  self.class_eval do
    def bar
    end
  end
end

def foo
  self.module_exec do
    def bar
    end
  end
end

Example:

# good

def foo
  class << self
    def bar
    end
  end
end

Freeze mutable objects assigned to constants.
Open

  IMAGE_OPTIM_CONFIG = {
    nice: 20,
    optipng: {
      level: 2
    },
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

  TEMPLATE = <<-EOF
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Method definitions must not be nested. Use lambda instead.
Open

      def @image_data.original_filename; CARD_FILENAME_EN; end
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks for nested method definitions.

Example:

# bad

# `bar` definition actually produces methods in the same scope
# as the outer `foo` method. Furthermore, the `bar` method
# will be redefined every time `foo` is invoked.
def foo
  def bar
  end
end

Example:

# good

def foo
  bar = -> { puts 'hello' }
  bar.call
end

Example:

# good

def foo
  self.class_eval do
    def bar
    end
  end
end

def foo
  self.module_exec do
    def bar
    end
  end
end

Example:

# good

def foo
  class << self
    def bar
    end
  end
end

Avoid single-line method definitions.
Open

      def @image_data.original_filename; CARD_FILENAME_DE; end
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Avoid single-line method definitions.
Open

      def @image_data.original_filename; CARD_FILENAME_EN; end
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Freeze mutable objects assigned to constants.
Open

  CARD_FILENAME_DE = 'pledge_card_de.png'
Severity: Minor
Found in app/lib/card_renderer.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

There are no issues that match your filters.

Category
Status