bio-miga/miga

View on GitHub

Showing 1,637 of 1,651 total issues

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

      if retrials <= 0
Severity: Minor
Found in lib/miga/remote_dataset.rb 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

Indent ) the same as the start of the line where ( is.
Open

              ),
Severity: Minor
Found in lib/miga/daemon.rb by rubocop

This cops checks the indentation of hanging closing parentheses in method calls, method definitions, and grouped expressions. A hanging closing parenthesis means ) preceded by a line break.

Example:

# good: when x is on its own line, indent this way
func(
  x,
  y
)

# good: when x follows opening parenthesis, align parentheses
a = b * (x +
         y
        )

# bad
def func(
  x,
  y
  )
end

Reverse the order of the operands "data/#{v}" == relative_dir.
Open

          "data/#{v}" == relative_dir
Severity: Minor
Found in lib/miga/result/source.rb by rubocop

This cop checks for Yoda conditions, i.e. comparison operations where readability is reduced because the operands are not ordered the same way as they would be ordered in spoken English.

Example: EnforcedStyle: allcomparisonoperators (default)

# bad
99 == foo
"bar" != foo
42 >= foo
10 < bar

# good
foo == 99
foo == "bar"
foo <= 42
bar > 10

Example: EnforcedStyle: equalityoperatorsonly

# bad
99 == foo
"bar" != foo

# good
99 >= foo
3 < a && a < 5

Missing magic comment # frozen_string_literal: true.
Open

require 'miga/result/base'
Severity: Minor
Found in lib/miga/result/stats.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

Prefer annotated tokens (like %<foo>s</foo>) over unannotated tokens (like %s).
Open

    $stderr.print("[%s] %s %s %-12s   \r" % [Time.now, step, adv, left])
Severity: Minor
Found in lib/miga/common.rb by rubocop

Use a consistent style for named format string tokens.

Note: unannotated style cop only works for strings which are passed as arguments to those methods: sprintf, format, %. The reason is that unannotated format is very similar to encoded URLs or Date/Time formatting strings.

Example: EnforcedStyle: annotated (default)

# bad
format('%{greeting}', greeting: 'Hello')
format('%s', 'Hello')

# good
format('%<greeting>s', greeting: 'Hello')</greeting>

Example: EnforcedStyle: template

# bad
format('%<greeting>s', greeting: 'Hello')
format('%s', 'Hello')

# good
format('%{greeting}', greeting: 'Hello')</greeting>

Example: EnforcedStyle: unannotated

# bad
format('%<greeting>s', greeting: 'Hello')
format('%{greeting}', 'Hello')

# good
format('%s', 'Hello')</greeting>

Ternary operators must not be nested. Prefer if or else constructs instead.
Open

          left_time < 1    ? ('%.0fs left' % (left_time * 60))   :
          left_time > 1440 ? ('%.1fd left' % (left_time / 1440)) :
          left_time > 60   ? ('%.1fh left' % (left_time / 60))   :
          ('%.1fm left' % left_time)
Severity: Minor
Found in lib/miga/common.rb by rubocop

Add parentheses to nested method call spawn hook_args.first.miga_variables( project: path, project_name: name, miga: MiGA::MiGA.root_path, object: event_args.first ).
Open

      spawn hook_args.first.miga_variables(
        project: path, project_name: name,
        miga: MiGA::MiGA.root_path, object: event_args.first
      )
Severity: Minor
Found in lib/miga/project/hooks.rb by rubocop

This cop checks for unparenthesized method calls in the argument list of a parenthesized method call.

Example:

# good
method1(method2(arg), method3(arg))

# bad
method1(method2 arg, method3, arg)

Use snake_case for variable names.
Open

  @@RESULT_DIRS = {
Severity: Minor
Found in lib/miga/project/base.rb by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

Use snake_case for variable names.
Open

  @@DISTANCE_TASKS = %i[
Severity: Minor
Found in lib/miga/project/base.rb by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

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

  @@DATA_FOLDERS = %w[
Severity: Minor
Found in lib/miga/project/base.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 || instead of or.
Open

        datasets << m[1] unless m.nil? or m[1] == "miga-project"
Severity: Minor
Found in lib/miga/project/dataset.rb by rubocop

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Trailing whitespace detected.
Open

    # 
Severity: Minor
Found in lib/miga/parallel.rb by rubocop

Missing magic comment # frozen_string_literal: true.
Open

require 'shellwords'
Severity: Minor
Found in lib/miga/daemon/base.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

Avoid the use of Perl-style backrefs.
Open

            fragment = $1.to_f
Severity: Minor
Found in lib/miga/result/stats.rb by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Unnecessary spacing detected.
Open

      @_advance_time[:avg]  = nil
Severity: Minor
Found in lib/miga/common.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

Avoid multi-line ternary operators, use if or unless instead.
Open

          left_time > 1440 ? ('%.1fd left' % (left_time / 1440)) :
          left_time > 60   ? ('%.1fh left' % (left_time / 60))   :
          ('%.1fm left' % left_time)
Severity: Minor
Found in lib/miga/common.rb by rubocop

This cop checks for multi-line ternary op expressions.

Example:

# bad
a = cond ?
  b : c
a = cond ? b :
    c
a = cond ?
    b :
    c

# good
a = cond ? b : c
a =
  if cond
    b
  else
    c
  end

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

  @@KNOWN_TYPES = {
Severity: Minor
Found in lib/miga/project/base.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 each_value instead of values.each.
Open

    MiGA::Dataset.RESULT_DIRS.values.each do |dir|
Severity: Minor
Found in lib/miga/project/dataset.rb by rubocop

This cop checks for uses of each_key and each_value Hash methods.

Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

Example:

# bad
hash.keys.each { |k| p k }
hash.values.each { |v| p v }
hash.each { |k, _v| p k }
hash.each { |_k, v| p v }

# good
hash.each_key { |k| p k }
hash.each_value { |v| p v }

Use yield instead of blk.call.
Open

    each_dataset { |ds| blk.call(ds.profile_advance) }
Severity: Minor
Found in lib/miga/project/dataset.rb by rubocop

This cop identifies the use of a &block parameter and block.call where yield would do just as well.

Example:

# bad
def method(&block)
  block.call
end
def another(&func)
  func.call 1, 2, 3
end

# good
def method
  yield
end
def another
  yield 1, 2, 3
end

Use alias fetch [] instead of alias :fetch :[].
Open

  alias :fetch :[]
Severity: Minor
Found in lib/miga/taxonomy.rb by rubocop

This cop enforces the use of either #alias or #alias_method depending on configuration. It also flags uses of alias :symbol rather than alias bareword.

Example: EnforcedStyle: prefer_alias (default)

# bad
alias_method :bar, :foo
alias :bar :foo

# good
alias bar foo

Example: EnforcedStyle: preferaliasmethod

# bad
alias :bar :foo
alias bar foo

# good
alias_method :bar, :foo
Severity
Category
Status
Source
Language