bio-miga/miga

View on GitHub
lib/miga/remote_dataset/base.rb

Summary

Maintainability
A
25 mins
Test Coverage
A
98%

Module has too many lines. [166/100]
Open

module MiGA::RemoteDataset::Base
  @@_NCBI_DATASETS = 'https://api.ncbi.nlm.nih.gov/datasets/v2alpha/'
  @@_EUTILS        = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/'
  @@_EBI_API       = 'https://www.ebi.ac.uk/Tools/'
  @@_GTDB_API      = 'https://gtdb-api.ecogenomic.org/'
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method uri_safe_join has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def uri_safe_join(*parts)
  safe = parts.map { |i| i.is_a?(Array) ? i.join(',') : i.to_s }
  last = safe.pop
  safe.map! { |i| i[-1] == '/' ? i : "#{i}/" }
  safe << last
Severity: Minor
Found in lib/miga/remote_dataset/base.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

  @@_EBI_API       = 'https://www.ebi.ac.uk/Tools/'
Severity: Minor
Found in lib/miga/remote_dataset/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.

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

  @@UNIVERSE = {
Severity: Minor
Found in lib/miga/remote_dataset/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.

Align the parameters of a method call if they span more than one line.
Open

          db: opts[:db], id: opts[:ids], rettype: opts[:format], retmode: :text
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

Here we check if the parameters on a multi-line method call or definition are aligned.

Example: EnforcedStyle: withfirstparameter (default)

# good

foo :bar,
    :baz

# bad

foo :bar,
  :baz

Example: EnforcedStyle: withfixedindentation

# good

foo :bar,
  :baz

# bad

foo :bar,
    :baz

Use snake_case for variable names.
Open

  @@_SEQCODE_API   = 'https://disc-genomics.uibk.ac.at/seqcode/'
Severity: Minor
Found in lib/miga/remote_dataset/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 @@_GTDB_API with a class instance var.
Open

  @@_GTDB_API      = 'https://gtdb-api.ecogenomic.org/'
Severity: Minor
Found in lib/miga/remote_dataset/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 %i or %I for an array of symbols.
Open

          stage: :metadata, map_to: [:biosample, :assembly], format: :json
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Use snake_case for variable names.
Open

  @@_EUTILS_BUILD  = lambda { |service, q|
Severity: Minor
Found in lib/miga/remote_dataset/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 method names.
Open

    def UNIVERSE
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

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

Example: EnforcedStyle: snake_case (default)

# bad
def fooBar; end

# good
def foo_bar; end

Example: EnforcedStyle: camelCase

# bad
def foo_bar; end

# good
def fooBar; end

Use snake_case for variable names.
Open

  @@_EBI_API       = 'https://www.ebi.ac.uk/Tools/'
Severity: Minor
Found in lib/miga/remote_dataset/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

Align the parameters of a method call if they span more than one line.
Open

          db: opts[:db], term: opts[:ids], retmode: opts[:format]
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

Here we check if the parameters on a multi-line method call or definition are aligned.

Example: EnforcedStyle: withfirstparameter (default)

# good

foo :bar,
    :baz

# bad

foo :bar,
  :baz

Example: EnforcedStyle: withfixedindentation

# good

foo :bar,
  :baz

# bad

foo :bar,
    :baz

Use snake_case for variable names.
Open

  @@_EUTILS        = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/'
Severity: Minor
Found in lib/miga/remote_dataset/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

  @@UNIVERSE = {
Severity: Minor
Found in lib/miga/remote_dataset/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

Missing magic comment # frozen_string_literal: true.
Open

require 'cgi'
Severity: Minor
Found in lib/miga/remote_dataset/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

Use the -> { ... } lambda literal syntax for single line lambdas.
Open

      uri: lambda { |opts| URI.parse(opts[:ids][0]) },
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

This cop (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multiline lambdas. It is configurable to enforce one of the styles for both single line and multiline lambdas as well.

Example: EnforcedStyle: linecountdependent (default)

# bad
f = lambda { |x| x }
f = ->(x) do
      x
    end

# good
f = ->(x) { x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: lambda

# bad
f = ->(x) { x }
f = ->(x) do
      x
    end

# good
f = lambda { |x| x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: literal

# bad
f = lambda { |x| x }
f = lambda do |x|
      x
    end

# good
f = ->(x) { x }
f = ->(x) do
      x
    end

Use the -> { ... } lambda literal syntax for single line lambdas.
Open

      scheme: lambda { |opts| opts[:ids][0].split(':', 2)[0] },
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

This cop (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multiline lambdas. It is configurable to enforce one of the styles for both single line and multiline lambdas as well.

Example: EnforcedStyle: linecountdependent (default)

# bad
f = lambda { |x| x }
f = ->(x) do
      x
    end

# good
f = ->(x) { x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: lambda

# bad
f = ->(x) { x }
f = ->(x) do
      x
    end

# good
f = lambda { |x| x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: literal

# bad
f = lambda { |x| x }
f = lambda do |x|
      x
    end

# good
f = ->(x) { x }
f = ->(x) do
      x
    end

Align the parameters of a method call if they span more than one line.
Open

          db: opts[:db], id: opts[:ids], retmode: opts[:format]
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

Here we check if the parameters on a multi-line method call or definition are aligned.

Example: EnforcedStyle: withfirstparameter (default)

# good

foo :bar,
    :baz

# bad

foo :bar,
  :baz

Example: EnforcedStyle: withfixedindentation

# good

foo :bar,
  :baz

# bad

foo :bar,
    :baz

Missing top-level module documentation comment.
Open

module MiGA::RemoteDataset::Base
Severity: Minor
Found in lib/miga/remote_dataset/base.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

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

  @@_NCBI_DATASETS = 'https://api.ncbi.nlm.nih.gov/datasets/v2alpha/'
Severity: Minor
Found in lib/miga/remote_dataset/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.

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

  @@_SEQCODE_API   = 'https://disc-genomics.uibk.ac.at/seqcode/'
Severity: Minor
Found in lib/miga/remote_dataset/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.

Missing top-level class documentation comment.
Open

class MiGA::RemoteDataset < MiGA::MiGA
Severity: Minor
Found in lib/miga/remote_dataset/base.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

Use the -> { ... } lambda literal syntax for single line lambdas.
Open

      headers: lambda { |_opts| { 'Accept' => 'application/json' } }
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

This cop (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multiline lambdas. It is configurable to enforce one of the styles for both single line and multiline lambdas as well.

Example: EnforcedStyle: linecountdependent (default)

# bad
f = lambda { |x| x }
f = ->(x) do
      x
    end

# good
f = ->(x) { x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: lambda

# bad
f = ->(x) { x }
f = ->(x) do
      x
    end

# good
f = lambda { |x| x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: literal

# bad
f = lambda { |x| x }
f = lambda do |x|
      x
    end

# good
f = ->(x) { x }
f = ->(x) do
      x
    end

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

  @@_EUTILS        = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/'
Severity: Minor
Found in lib/miga/remote_dataset/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 the new Ruby 1.9 hash syntax.
Open

        :'type-genomes' => { stage: :metadata, format: :json }
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

This cop checks hash literal syntax.

It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).

A separate offense is registered for each problematic pair.

The supported styles are:

  • ruby19 - forces use of the 1.9 syntax (e.g. {a: 1}) when hashes have all symbols for keys
  • hash_rockets - forces use of hash rockets for all hashes
  • nomixedkeys - simply checks for hashes with mixed syntaxes
  • ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes

Example: EnforcedStyle: ruby19 (default)

# bad
{:a => 2}
{b: 1, :c => 2}

# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden

Example: EnforcedStyle: hash_rockets

# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}

# good
{:a => 1, :b => 2}

Example: EnforcedStyle: nomixedkeys

# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}

# good
{:a => 1, :b => 2}
{c: 1, d: 2}

Example: EnforcedStyle: ruby19nomixed_keys

# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets

# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}

Use snake_case for variable names.
Open

  @@_GTDB_API      = 'https://gtdb-api.ecogenomic.org/'
Severity: Minor
Found in lib/miga/remote_dataset/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 @@_EUTILS_BUILD with a class instance var.
Open

  @@_EUTILS_BUILD  = lambda { |service, q|
Severity: Minor
Found in lib/miga/remote_dataset/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.

Align the parameters of a method call if they span more than one line.
Open

          db: opts[:db], id: opts[:ids], rettype: opts[:format], retmode: :text
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

Here we check if the parameters on a multi-line method call or definition are aligned.

Example: EnforcedStyle: withfirstparameter (default)

# good

foo :bar,
    :baz

# bad

foo :bar,
  :baz

Example: EnforcedStyle: withfixedindentation

# good

foo :bar,
  :baz

# bad

foo :bar,
    :baz

Use snake_case for variable names.
Open

  @@_NCBI_DATASETS = 'https://api.ncbi.nlm.nih.gov/datasets/v2alpha/'
Severity: Minor
Found in lib/miga/remote_dataset/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

Do not use :: for method calls.
Open

  URI::join(*safe)
Severity: Minor
Found in lib/miga/remote_dataset/base.rb by rubocop

This cop checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).

Example:

# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)

# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)

There are no issues that match your filters.

Category
Status