skcc321/dumpman

View on GitHub
lib/dumpman/executor.rb

Summary

Maintainability
A
0 mins
Test Coverage
C
72%

Dumpman::Executor#rake calls 'Rake::Task["db:#{command}"]' 2 times
Open

        Rake::Task["db:#{command}"].reenable
        Rake::Task["db:#{command}"].invoke
Severity: Minor
Found in lib/dumpman/executor.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.

Dumpman::Executor has no descriptive comment
Open

  module Executor
Severity: Minor
Found in lib/dumpman/executor.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

Dumpman::Executor#rake doesn't depend on instance state (maybe move it to another class?)
Open

    def rake(*commands)
Severity: Minor
Found in lib/dumpman/executor.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

Dumpman::Executor#info has the variable name 'x'
Open

          .map { |x| x.squeeze(' ') }
Severity: Minor
Found in lib/dumpman/executor.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.

Align .map with .gsub on line 30.
Open

          .map { |x| x.squeeze(' ') }
Severity: Minor
Found in lib/dumpman/executor.rb by rubocop

This cop checks the indentation of the method name part in method calls that span more than one line.

Example: EnforcedStyle: aligned

# bad
while myvariable
.b
  # do something
end

# good
while myvariable
      .b
  # do something
end

# good
Thing.a
     .b
     .c

Example: EnforcedStyle: indented

# good
while myvariable
  .b

  # do something
end

Example: EnforcedStyle: indentedrelativeto_receiver

# good
while myvariable
        .a
        .b

  # do something
end

# good
myvariable = Thing
               .a
               .b
               .c

Align .split with .gsub on line 30.
Open

          .split(/\n/)
Severity: Minor
Found in lib/dumpman/executor.rb by rubocop

This cop checks the indentation of the method name part in method calls that span more than one line.

Example: EnforcedStyle: aligned

# bad
while myvariable
.b
  # do something
end

# good
while myvariable
      .b
  # do something
end

# good
Thing.a
     .b
     .c

Example: EnforcedStyle: indented

# good
while myvariable
  .b

  # do something
end

Example: EnforcedStyle: indentedrelativeto_receiver

# good
while myvariable
        .a
        .b

  # do something
end

# good
myvariable = Thing
               .a
               .b
               .c

Align .reject with .gsub on line 30.
Open

          .reject(&:blank?)
Severity: Minor
Found in lib/dumpman/executor.rb by rubocop

This cop checks the indentation of the method name part in method calls that span more than one line.

Example: EnforcedStyle: aligned

# bad
while myvariable
.b
  # do something
end

# good
while myvariable
      .b
  # do something
end

# good
Thing.a
     .b
     .c

Example: EnforcedStyle: indented

# good
while myvariable
  .b

  # do something
end

Example: EnforcedStyle: indentedrelativeto_receiver

# good
while myvariable
        .a
        .b

  # do something
end

# good
myvariable = Thing
               .a
               .b
               .c

Useless assignment to variable - result.
Open

        result = Kernel.system(cmd)
Severity: Minor
Found in lib/dumpman/executor.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Use backticks around command string.
Open

        result = %x[#{cmd}].strip
Severity: Minor
Found in lib/dumpman/executor.rb by rubocop

This cop enforces using `` or %x around command literals.

Example: EnforcedStyle: backticks (default)

# bad
folders = %x(find . -type d).split

# bad
%x(
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
)

# good
folders = `find . -type d`.split

# good
`
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
`

Example: EnforcedStyle: mixed

# bad
folders = %x(find . -type d).split

# bad
`
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
`

# good
folders = `find . -type d`.split

# good
%x(
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
)

Example: EnforcedStyle: percent_x

# bad
folders = `find . -type d`.split

# bad
`
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
`

# good
folders = %x(find . -type d).split

# good
%x(
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
)

Example: AllowInnerBackticks: false (default)

# If `false`, the cop will always recommend using `%x` if one or more
# backticks are found in the command string.

# bad
`echo \`ls\``

# good
%x(echo `ls`)

Example: AllowInnerBackticks: true

# good
`echo \`ls\``

%x-literals should be delimited by ( and ).
Open

        result = %x[#{cmd}].strip
Severity: Minor
Found in lib/dumpman/executor.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Use module_function instead of extend self.
Open

    extend self
Severity: Minor
Found in lib/dumpman/executor.rb by rubocop

This cops checks for use of extend self or module_function in a module.

Supported styles are: modulefunction, extendself.

Example: EnforcedStyle: module_function (default)

# bad
module Test
  extend self
  # ...
end

# good
module Test
  module_function
  # ...
end

Example: EnforcedStyle: extend_self

# bad
module Test
  module_function
  # ...
end

# good
module Test
  extend self
  # ...
end

These offenses are not auto-corrected since there are different implications to each approach.

Missing top-level module documentation comment.
Open

  module Executor
Severity: Minor
Found in lib/dumpman/executor.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

Prefer $CHILD_STATUS from the stdlib 'English' module (don't forget to require it) over $?.
Open

        yield result if $?.success?
Severity: Minor
Found in lib/dumpman/executor.rb by rubocop

There are no issues that match your filters.

Category
Status