yannickwurm/sequenceserver

View on GitHub
lib/sequenceserver/blast/job.rb

Summary

Maintainability
A
25 mins
Test Coverage

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

      def initialize(params)
        if params.key?(:xml)
          super do
            @imported_xml_file = File.basename params[:xml]
            # Copy over the XML file to job directory so that a job dir in
Severity: Minor
Found in lib/sequenceserver/blast/job.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 validate_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def validate_options(options)
        return true if !options || (options.is_a?(String) &&
                                    options.strip.empty?)

        fail InputError, 'Invalid characters detected in options.' unless allowed_chars.match(options)
Severity: Minor
Found in lib/sequenceserver/blast/job.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 initialize is too high. [<12, 24, 2> 26.91/17]
Open

      def initialize(params)
        if params.key?(:xml)
          super do
            @imported_xml_file = File.basename params[:xml]
            # Copy over the XML file to job directory so that a job dir in
Severity: Minor
Found in lib/sequenceserver/blast/job.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 [])

There are no issues that match your filters.

Category
Status