am-kantox/dry-mutations

View on GitHub

Showing 65 of 65 total issues

Avoid rescuing without specifying an error class.
Open

        rescue => e

This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

Example: EnforcedStyle: implicit

# `implicit` will enforce using `rescue` instead of
# `rescue StandardError`.

# bad
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Example: EnforcedStyle: explicit (default)

# `explicit` will enforce using `rescue StandardError`
# instead of `rescue`.

# bad
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Use warn instead of $stderr.puts to allow such output to be disabled.
Open

  $stderr.puts e.message
Severity: Minor
Found in Rakefile by rubocop

This cop identifies places where $stderr.puts can be replaced by warn. The latter has the advantage of easily being disabled by, e.g. the -W0 interpreter flag, or setting $VERBOSE to nil.

Example:

# bad
$stderr.puts('hello')

# good
warn('hello')

Missing top-level module documentation comment.
Open

      module ErrorHash

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

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency hashie should appear before mutations.
Open

  spec.add_dependency 'hashie', '~> 3'
Severity: Minor
Found in dry-mutations.gemspec by rubocop

Dependencies in the gemspec should be alphabetically sorted.

Example:

# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'

# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'

# good
spec.add_dependency 'rubocop'

spec.add_dependency 'rspec'

# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'

# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'

# good
spec.add_development_dependency 'rubocop'

spec.add_development_dependency 'rspec'

# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'

# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'

# good
spec.add_runtime_dependency 'rubocop'

spec.add_runtime_dependency 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'

Use normalcase for variable numbers.
Open

          (@wrappers = params).each do |name, λ|

This cop makes sure that all numbered variables use the configured style, snakecase, normalcase or noninteger, for their numbering.

Example: EnforcedStyle: snake_case

# bad

variable1 = 1

# good

variable_1 = 1

Example: EnforcedStyle: normalcase (default)

# bad

variable_1 = 1

# good

variable1 = 1

Example: EnforcedStyle: non_integer

# bad

variable1 = 1

variable_1 = 1

# good

variableone = 1

variable_one = 1

Do not place comments on the same line as the end keyword.
Open

          end # [key] = Errors::ErrorAtom.new(key, kind, dry_message, message: message)

This cop checks for comments put on the same line as some keywords. These keywords are: begin, class, def, end, module.

Note that some comments (such as :nodoc: and rubocop:disable) are allowed.

Example:

# bad
if condition
  statement
end # end if

# bad
class X # comment
  statement
end

# bad
def x; end # comment

# good
if condition
  statement
end

# good
class X # :nodoc:
  y
end

Replace class var @@discarded with a class instance var.
Open

      @@discarded = []
Severity: Minor
Found in lib/dry/mutations/schema.rb by rubocop

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Use normalcase for variable numbers.
Open

          failure: ->(value, λ) do

This cop makes sure that all numbered variables use the configured style, snakecase, normalcase or noninteger, for their numbering.

Example: EnforcedStyle: snake_case

# bad

variable1 = 1

# good

variable_1 = 1

Example: EnforcedStyle: normalcase (default)

# bad

variable_1 = 1

# good

variable1 = 1

Example: EnforcedStyle: non_integer

# bad

variable1 = 1

variable_1 = 1

# good

variableone = 1

variable_one = 1

Missing top-level class documentation comment.
Open

    class Schema < ::Dry::Validation::Schema
Severity: Minor
Found in lib/dry/mutations/schema.rb by rubocop

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

Unnecessary utf-8 encoding comment.
Open

# encoding: UTF-8
Severity: Minor
Found in Rakefile by rubocop

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

        else fail ArgumentError, "The executor given can not be executed (forgot to specify :method param?)"
Severity: Minor
Found in lib/dry/mutations/utils/procs.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

FIXME found
Open

      # FIXME: at the moment this is an exact equivalent of :type? => User
Severity: Minor
Found in lib/dry/mutations/predicates.rb by fixme

TODO found
Open

            # TODO: this silently coerces everything to be a string

FIXME found
Open

        # FIXME: array of anonymous objects
Severity: Minor
Found in lib/dry/mutations/dsl/types.rb by fixme

FIXME found
Open

          return enum_for(:chain) unless block_given? # FIXME: Needed? Works? Remove?
Severity: Minor
Found in lib/dry/mutations/transactions/dsl.rb by fixme

FIXME found
Open

        # FIXME: errors in double+ nested hashes are not nested! dry-rb glitch?
Severity: Minor
Found in lib/dry/mutations/dsl/types.rb by fixme

TODO found
Open

      #   TODO: Make it possible to choose friendly hash implementation
Severity: Minor
Found in lib/dry/mutations/utils/procs.rb by fixme

FIXME found
Open

          when name.nil? then schema { each(nested) } # FIXME: CAN IT BE NIL?!
Severity: Minor
Found in lib/dry/mutations/dsl/types.rb by fixme

FIXME found
Open

        # FIXME: try-catch and call super in rescue clause
Severity: Minor
Found in lib/dry/mutations/dsl/weirdo.rb by fixme

FIXME found
Open

          super left.inspect # FIXME
Severity: Minor
Found in lib/dry/mutations/errors.rb by fixme
Severity
Category
Status
Source
Language