yannickwurm/sequenceserver

View on GitHub
lib/sequenceserver/makeblastdb.rb

Summary

Maintainability
A
1 hr
Test Coverage

Class has too many lines. [214/150]
Open

  class MAKEBLASTDB
    extend Forwardable
    GUESS_SAMPLE_SIZE = 1_048_576

    def_delegators SequenceServer, :config, :sys
Severity: Minor
Found in lib/sequenceserver/makeblastdb.rb by rubocop

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

You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

Example: CountAsOne: ['array', 'heredoc']

class Foo
  ARRAY = [         # +1
    1,
    2
  ]

  HASH = {          # +3
    key: 'value'
  }

  MSG = <<~HEREDOC  # +1
    Heredoc
    content.
  HEREDOC
end                 # 5 points

NOTE: This cop also applies for Struct definitions.

Method has too many lines. [25/15]
Open

    def _make_blast_database(file, type, title, taxonomy)
      cmd = "makeblastdb -parse_seqids -hash_index -in '#{file}'" \
            " -dbtype #{type.to_s.slice(0, 4)} -title '#{title}'" \
            " #{taxonomy}"

Severity: Minor
Found in lib/sequenceserver/makeblastdb.rb by rubocop

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

You can set literals you want to fold with CountAsOne. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.

NOTE: The ExcludedMethods configuration is deprecated and only kept for backwards compatibility. Please use IgnoredMethods instead.

Example: CountAsOne: ['array', 'heredoc']

def m
  array = [       # +1
    1,
    2
  ]

  hash = {        # +3
    key: 'value'
  }

  <<~HEREDOC      # +1
    Heredoc
    content.
  HEREDOC
end               # 5 points

Method make_blast_database has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def make_blast_database(action, file, title, type, non_parse_seqids = false)
Severity: Minor
Found in lib/sequenceserver/makeblastdb.rb - About 35 mins to fix

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

        def probably_fastas
          return @probably_fastas if defined?(@probably_fastas)
    
          @probably_fastas = []
    
    
    Severity: Minor
    Found in lib/sequenceserver/makeblastdb.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

    Assignment Branch Condition size for _make_blast_database is too high. [<5, 17, 3> 17.97/17]
    Open

        def _make_blast_database(file, type, title, taxonomy)
          cmd = "makeblastdb -parse_seqids -hash_index -in '#{file}'" \
                " -dbtype #{type.to_s.slice(0, 4)} -title '#{title}'" \
                " #{taxonomy}"
    
    
    Severity: Minor
    Found in lib/sequenceserver/makeblastdb.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric and https://en.wikipedia.org/wiki/ABC_Software_Metric.

    Interpreting ABC size:

    • <= 17 satisfactory
    • 18..30 unsatisfactory
    • > 30 dangerous

    You can have repeated "attributes" calls count as a single "branch". For this purpose, attributes are any method with no argument; no attempt is meant to distinguish actual attr_reader from other methods.

    Example: CountRepeatedAttributes: false (default is true)

    # `model` and `current_user`, refenced 3 times each,
     # are each counted as only 1 branch each if
     # `CountRepeatedAttributes` is set to 'false'
    
     def search
       @posts = model.active.visible_by(current_user)
                 .search(params[:q])
       @posts = model.some_process(@posts, current_user)
       @posts = model.another_process(@posts, current_user)
    
       render 'pages/search/page'
     end

    This cop also takes into account IgnoredMethods (defaults to [])

    Prefer keyword arguments for arguments with a boolean default value; use non_parse_seqids: false instead of non_parse_seqids = false.
    Open

        def make_blast_database(action, file, title, type, non_parse_seqids = false)
    Severity: Minor
    Found in lib/sequenceserver/makeblastdb.rb by rubocop

    This cop checks for places where keyword arguments can be used instead of boolean arguments when defining methods. respond_to_missing? method is allowed by default. These are customizable with AllowedMethods option.

    Safety:

    This cop is unsafe because changing a method signature will implicitly change behaviour.

    Example:

    # bad
    def some_method(bar = false)
      puts bar
    end
    
    # bad - common hack before keyword args were introduced
    def some_method(options = {})
      bar = options.fetch(:bar, false)
      puts bar
    end
    
    # good
    def some_method(bar: false)
      puts bar
    end

    Example: AllowedMethods: ['some_method']

    # good
    def some_method(bar = false)
      puts bar
    end

    Prefer string interpolation to string concatenation.
    Open

          Find.find(database_dir + '/') do |path|
    Severity: Minor
    Found in lib/sequenceserver/makeblastdb.rb by rubocop

    This cop checks for places where string concatenation can be replaced with string interpolation.

    The cop can autocorrect simple cases but will skip autocorrecting more complex cases where the resulting code would be harder to read. In those cases, it might be useful to extract statements to local variables or methods which you can then interpolate in a string.

    NOTE: When concatenation between two strings is broken over multiple lines, this cop does not register an offense; instead, Style/LineEndConcatenation will pick up the offense if enabled.

    Two modes are supported: 1. aggressive style checks and corrects all occurrences of + where either the left or right side of + is a string literal. 2. conservative style on the other hand, checks and corrects only if left side (receiver of + method call) is a string literal. This is useful when the receiver is some expression that returns string like Pathname instead of a string literal.

    Safety:

    This cop is unsafe in aggressive mode, as it cannot be guaranteed that the receiver is actually a string, which can result in a false positive.

    Example: Mode: aggressive (default)

    # bad
    email_with_name = user.name + ' <' + user.email + '>'
    Pathname.new('/') + 'test'
    
    # good
    email_with_name = "#{user.name} <#{user.email}>"
    email_with_name = format('%s <%s>', user.name, user.email)
    "#{Pathname.new('/')}test"
    
    # accepted, line-end concatenation
    name = 'First' +
      'Last'

    Example: Mode: conservative

    # bad
    'Hello' + user.name
    
    # good
    "Hello #{user.name}"
    user.name + '!!'
    Pathname.new('/') + 'test'

    Use $stdin instead of STDIN.
    Open

          response = STDIN.gets.to_s.strip
    Severity: Minor
    Found in lib/sequenceserver/makeblastdb.rb by rubocop

    This cop enforces the use of $stdout/$stderr/$stdin instead of STDOUT/STDERR/STDIN. STDOUT/STDERR/STDIN are constants, and while you can actually reassign (possibly to redirect some stream) constants in Ruby, you'll get an interpreter warning if you do so.

    Safety:

    Autocorrection is unsafe because STDOUT and $stdout may point to different objects, for example.

    Example:

    # bad
    STDOUT.puts('hello')
    
    hash = { out: STDOUT, key: value }
    
    def m(out = STDOUT)
      out.puts('hello')
    end
    
    # good
    $stdout.puts('hello')
    
    hash = { out: $stdout, key: value }
    
    def m(out = $stdout)
      out.puts('hello')
    end

    Use $stdin instead of STDIN.
    Open

          user_response = STDIN.gets.strip
    Severity: Minor
    Found in lib/sequenceserver/makeblastdb.rb by rubocop

    This cop enforces the use of $stdout/$stderr/$stdin instead of STDOUT/STDERR/STDIN. STDOUT/STDERR/STDIN are constants, and while you can actually reassign (possibly to redirect some stream) constants in Ruby, you'll get an interpreter warning if you do so.

    Safety:

    Autocorrection is unsafe because STDOUT and $stdout may point to different objects, for example.

    Example:

    # bad
    STDOUT.puts('hello')
    
    hash = { out: STDOUT, key: value }
    
    def m(out = STDOUT)
      out.puts('hello')
    end
    
    # good
    $stdout.puts('hello')
    
    hash = { out: $stdout, key: value }
    
    def m(out = $stdout)
      out.puts('hello')
    end

    Useless assignment to variable - e.
    Open

        rescue CommandFailed => e
    Severity: Minor
    Found in lib/sequenceserver/makeblastdb.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 $stdin instead of STDIN.
    Open

          from_user = STDIN.gets.to_s.strip
    Severity: Minor
    Found in lib/sequenceserver/makeblastdb.rb by rubocop

    This cop enforces the use of $stdout/$stderr/$stdin instead of STDOUT/STDERR/STDIN. STDOUT/STDERR/STDIN are constants, and while you can actually reassign (possibly to redirect some stream) constants in Ruby, you'll get an interpreter warning if you do so.

    Safety:

    Autocorrection is unsafe because STDOUT and $stdout may point to different objects, for example.

    Example:

    # bad
    STDOUT.puts('hello')
    
    hash = { out: STDOUT, key: value }
    
    def m(out = STDOUT)
      out.puts('hello')
    end
    
    # good
    $stdout.puts('hello')
    
    hash = { out: $stdout, key: value }
    
    def m(out = $stdout)
      out.puts('hello')
    end

    There are no issues that match your filters.

    Category
    Status