decko-commons/decko

View on GitHub

Showing 661 of 695 total issues

Missing top-level class documentation comment.
Open

  class HaveTag

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

Non-local exit from iterator, without return value. next, break, Array#find, Array#any?, etc. is preferred.
Open

    return unless (@field = card.fetch(field_key))

This cop checks for non-local exits from iterators without a return value. It registers an offense under these conditions:

  • No value is returned,
  • the block is preceded by a method chain,
  • the block has arguments,
  • the method which receives the block is not define_method or define_singleton_method,
  • the return is not contained in an inner scope, e.g. a lambda or a method definition.

Example:

class ItemApi
  rescue_from ValidationError do |e| # non-iteration block with arg
    return { message: 'validation error' } unless e.errors # allowed
    error_array = e.errors.map do |error| # block with method chain
      return if error.suppress? # warned
      return "#{error.param}: invalid" unless error.message # allowed
      "#{error.param}: #{error.message}"
    end
    { message: 'validation error', errors: error_array }
  end

  def update_items
    transaction do # block without arguments
      return unless update_necessary? # allowed
      find_each do |item| # block without method chain
        return if item.stock == 0 # false-negative...
        item.update!(foobar: true)
      end
    end
  end
end

Avoid the use of the case equality operator ===.
Open

    @size === @file.file.size

This cop checks for uses of the case equality operator(===).

Example:

# bad
Array === something
(1..100) === 7
/something/ === some_string

# good
something.is_a?(Array)
(1..100).include?(7)
some_string =~ /something/

Start context description with 'when', 'with', or 'without'.
Open

  context "Class" do
Severity: Minor
Found in card/spec/card/chunk_spec.rb by rubocop

Prefer have_received for setting message expectations. Setup format as a spy using allow or instance_spy.
Open

    expect(format).to receive(:render!).with("viewname", { structure: :crooked })

Do not suppress exceptions.
Open

      rescue Card::Error
Severity: Minor
Found in card/spec/card/director_spec.rb by rubocop

This cop checks for rescue blocks with no body.

Example:

# bad

def some_method
  do_something
rescue
  # do nothing
end

Example:

# bad

begin
  do_something
rescue
  # do nothing
end

Example:

# good

def some_method
  do_something
rescue
  handle_exception
end

Example:

# good

begin
  do_something
rescue
  handle_exception
end

The first argument to describe should be the class or module being tested.
Open

RSpec.describe "Card::Director" do
Severity: Minor
Found in card/spec/card/director_spec.rb by rubocop

Prefer have_received for setting message expectations. Setup store as a spy using allow or instance_spy.
Open

      expect(store).to receive(:read).with("#{prefix}/foo")
Severity: Minor
Found in card/spec/card/cache_spec.rb by rubocop

Missing top-level class documentation comment.
Open

class CardSpecLoader

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

include is used at the top level. Use inside class or module.
Open

    include RSpecHtmlMatchers::SyntaxHighlighting

This cop checks that include, extend and prepend exists at the top level. Using these at the top level affects the behavior of Object. There will not be using include, extend and prepend at the top level. Let's use it inside class or module.

Example:

# bad
include M

class C
end

# bad
extend M

class C
end

# bad
prepend M

class C
end

# good
class C
  include M
end

# good
class C
  extend M
end

# good
class C
  prepend M
end

Missing top-level module documentation comment.
Open

    module ClassMethods

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

Use let instead of an instance variable.
Open

      trans = @current_trans && !reset ? @current_trans : __current_trans
Severity: Minor
Found in card/spec/card/subcards/all_spec.rb by rubocop

Prefer have_received for setting message expectations. Setup card_double as a spy using allow or instance_spy.
Open

      expect(card_double).not_to receive(:find_by_key_and_trash)
Severity: Minor
Found in card/spec/card/fetch_spec.rb by rubocop

Spec path should end with /codename*Codename*_spec.rb.
Open

RSpec.describe Card::Codename, "Codename" do
Severity: Minor
Found in card/spec/card/codename_spec.rb by rubocop

Prefer have_received for setting message expectations. Setup format as a spy using allow or instance_spy.
Open

    expect(format).to receive(:render!).with("viewname", { skip_perms: true })

Prefer have_received for setting message expectations. Setup format as a spy using allow or instance_spy.
Open

    expect(format).to receive(:render!).with("viewname", { optional: :show,

Prefer have_received for setting message expectations. Setup store as a spy using allow or instance_spy.
Open

      expect(store).not_to receive(:write)
Severity: Minor
Found in card/spec/card/cache_spec.rb by rubocop

Missing top-level module documentation comment.
Open

    module Transformers

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

Name your test subject if you need to reference it explicitly.
Open

        expect(subject.s).to eq "Decko Bot"

Missing top-level module documentation comment.
Open

  module Object

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
Severity
Category
Status
Source
Language