autotelik/datashift_journey

View on GitHub
lib/tasks/state_machine.thor

Summary

Maintainability
Test Coverage

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

      if File.exist?(File.expand_path('config/environment.rb'))
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Extra empty line detected at block body end.
Open


  end
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

This cops checks if empty lines around the bodies of blocks match the configuration.

Example: EnforcedStyle: empty_lines

# good

foo do |bar|

  # ...

end

Example: EnforcedStyle: noemptylines (default)

# good

foo do |bar|
  # ...
end

Use 2 (not 1) spaces for indentation.
Open

         puts ("Failed to initialise ActiveRecord : #{e.message}")
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

(...) interpreted as grouped expression.
Open

         puts ("Failed to initialise ActiveRecord : #{e.message}")
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

Checks for space between the name of a called method and a left parenthesis.

Example:

# bad

puts (x + y)

Example:

# good

puts(x + y)

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

  desc "report", "Report on the states and transitions availblke for current DSJ Journey Plan"
Severity: Minor
Found in lib/tasks/state_machine.thor 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"

Extra empty line detected at block body beginning.
Open


    def environment
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

This cops checks if empty lines around the bodies of blocks match the configuration.

Example: EnforcedStyle: empty_lines

# good

foo do |bar|

  # ...

end

Example: EnforcedStyle: noemptylines (default)

# good

foo do |bar|
  # ...
end

Space missing after comma.
Open

    puts "\nEVENTS",journey_plan.state_events.inspect
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

Checks for comma (,) not followed by some kind of space.

Example:

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

Extra empty line detected at method body beginning.
Open


      if File.exist?(File.expand_path('config/environment.rb'))
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

This cops checks if empty lines exist around the bodies of methods.

Example:

# good

def foo
  # ...
end

# bad

def bar

  # ...

end

Put one space between the method name and the first argument.
Open

require'datashift_journey'
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

Checks that exactly one space is used between a method name and the first argument for method calls without parentheses.

Alternatively, extra spaces can be added to align the argument with something on a preceding or following line, if the AllowForAlignment config parameter is true.

Example:

# bad
something  x
something   y, z
something'hello'

# good
something x
something y, z
something 'hello'

Avoid rescuing without specifying an error class.
Open

        rescue => e
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

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

Space missing after comma.
Open

    puts "\nSTATE PATHS",journey_plan.state_paths.inspect
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

Checks for comma (,) not followed by some kind of space.

Example:

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

Ambiguous negative number operator. Parenthesize the method arguments if it's surely a negative number operator, or add a whitespace to the right of the - if it should be a subtraction.
Open

            exit -1
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

This cop checks for ambiguous operators in the first argument of a method invocation without parentheses.

Example:

# bad

# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array

Example:

# good

# With parentheses, there's no ambiguity.
do_something(*some_array)

Provide an exception class and message as arguments to raise.
Open

        raise PathError.new('No config/environment.rb found - cannot initialise ActiveRecord')
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

This cop checks the args passed to fail and raise. For exploded style (default), it recommends passing the exception class and message to raise, rather than construct an instance of the error. It will still allow passing just a message, or the construction of an error with more than one argument.

The exploded style works identically, but with the addition that it will also suggest constructing error objects when the exception is passed multiple arguments.

Example: EnforcedStyle: exploded (default)

# bad
raise StandardError.new("message")

# good
raise StandardError, "message"
fail "message"
raise MyCustomError.new(arg1, arg2, arg3)
raise MyKwArgError.new(key1: val1, key2: val2)

Example: EnforcedStyle: compact

# bad
raise StandardError, "message"
raise RuntimeError, arg1, arg2, arg3

# good
raise StandardError.new("message")
raise MyCustomError.new(arg1, arg2, arg3)
fail "message"

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

  desc "report", "Report on the states and transitions availblke for current DSJ Journey Plan"
Severity: Minor
Found in lib/tasks/state_machine.thor 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"

Extra empty line detected at method body beginning.
Open


    environment
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

This cops checks if empty lines exist around the bodies of methods.

Example:

# good

def foo
  # ...
end

# bad

def bar

  # ...

end

Inconsistent indentation detected.
Open

            exit -1
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

This cops checks for inconsistent indentation.

Example:

class A
  def test
    puts 'hello'
     puts 'world'
  end
end

Missing space after #.
Open

          #raise ConnectionError.new("Failed to initialise ActiveRecord : #{e.message}")
Severity: Minor
Found in lib/tasks/state_machine.thor by rubocop

This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

Example:

# bad
#Some comment

# good
# Some comment

There are no issues that match your filters.

Category
Status