wurmlab/sequenceserver

View on GitHub

Showing 16,957 of 16,957 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def rfam
      return nil unless id.match(RFAM_ID_PATTERN) or title.match(RFAM_ID_PATTERN)
      rfam_id = Regexp.last_match[1]
      rfam_id = encode rfam_id
      url = "https://rfam.xfam.org/family/#{rfam_id}"
Severity: Minor
Found in lib/sequenceserver/links.rb and 2 other locations - About 30 mins to fix
lib/sequenceserver/links.rb on lines 81..91
lib/sequenceserver/links.rb on lines 94..104

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid too many return statements within this function.
Open

            return v / conf.ticks.labelDenominator + conf.ticks.labelSuffix;
Severity: Major
Found in public/js/circosjs.js - About 30 mins to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          let lsend =
            nsseq +
            (lsseq.length - lsseq.split("-").length) *
              sframe_unit() *
              sframe_sign();
    Severity: Minor
    Found in public/js/hsp.js and 1 other location - About 30 mins to fix
    public/js/hsp.js on lines 169..173

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          let lqend =
            nqseq +
            (lqseq.length - lqseq.split("-").length) *
              qframe_unit() *
              qframe_sign();
    Severity: Minor
    Found in public/js/hsp.js and 1 other location - About 30 mins to fix
    public/js/hsp.js on lines 180..184

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

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

        def check_num_threads
          num_threads = Integer(config[:num_threads])
          fail NUM_THREADS_INCORRECT unless num_threads.positive?
          logger.debug "Will use #{num_threads} threads to run BLAST."
          if num_threads > 256
    Severity: Minor
    Found in lib/sequenceserver.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

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

      def write_entries(entries, path, zipfile)
        entries.each do |e|
          zipfile_path = path == '' ? e : File.join(path, e)
          disk_file_path = File.join(@input_dir, zipfile_path)
    
    
    Severity: Minor
    Found in lib/sequenceserver/zip_file_generator.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

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

        def update_searchdata_from_job(searchdata)
          job = fetch_job(params[:job_id])
          return { error: 'Job not found' }.to_json if job.nil?
          return if job.imported_xml_file
    
    
    Severity: Minor
    Found in lib/sequenceserver/routes.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

    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

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

        def init_binaries
          if config[:bin]
            config[:bin] = File.expand_path config[:bin]
            unless File.exist?(config[:bin]) && File.directory?(config[:bin])
              fail ENOENT.new('bin dir', config[:bin])
    Severity: Minor
    Found in lib/sequenceserver.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

    Function determineBlastMethods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        determineBlastMethods() {
            var database_type = this.databaseType;
            var sequence_type = this.sequenceType;
    
            if (this.query.current.isEmpty()) {
    Severity: Minor
    Found in public/js/form.js - 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

    Function selectHit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        selectHit(id) {
            var checkbox = $('#' + id);
            var num_checked = $('.hit-links :checkbox:checked').length;
    
            if (!checkbox || !checkbox.val()) return;
    Severity: Minor
    Found in public/js/hits.js - 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

    Incorrect indentation detected (column 7 instead of 4).
    Open

           # 'Run SequenceServer doctor'
    Severity: Minor
    Found in bin/sequenceserver by rubocop

    This cop checks the indentation of comments.

    Example:

    # bad
      # comment here
    def method_name
    end
    
      # comment here
    a = 'hello'
    
    # yet another comment
      if true
        true
      end
    
    # good
    # comment here
    def method_name
    end
    
    # comment here
    a = 'hello'
    
    # yet another comment
    if true
      true
    end

    Final newline missing.
    Open

    end
    Severity: Minor
    Found in bin/sequenceserver by rubocop

    This cop looks for trailing blank lines and a final newline in the source code.

    Example: EnforcedStyle: finalblankline

    # `final_blank_line` looks for one blank line followed by a new line
    # at the end of files.
    
    # bad
    class Foo; end
    # EOF
    
    # bad
    class Foo; end # EOF
    
    # good
    class Foo; end
    
    # EOF

    Example: EnforcedStyle: final_newline (default)

    # `final_newline` looks for one newline at the end of files.
    
    # bad
    class Foo; end
    
    # EOF
    
    # bad
    class Foo; end # EOF
    
    # good
    class Foo; end
    # EOF

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

          post_email_cmd = "curl -m 5 https://docs.google.com/forms/u/0/d/e/" \
    Severity: Minor
    Found in bin/sequenceserver 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"

    Favor modifier unless usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

          unless environment == 'test'
    Severity: Minor
    Found in lib/sequenceserver.rb by rubocop

    Checks for if and unless statements that would fit on one line if written as modifier if/unless. The cop also checks for modifier if/unless lines that exceed the maximum line length.

    The maximum line length is configured in the Layout/LineLength cop. The tab size is configured in the IndentationWidth of the Layout/IndentationStyle cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    do_something_with_a_long_name(arg) if long_condition_that_prevents_code_fit_on_single_line
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?
    
    if long_condition_that_prevents_code_fit_on_single_line
      do_something_with_a_long_name(arg)
    end
    
    if short_condition # a long comment that makes it too long if it were just a single line
      do_something
    end

    Use raise instead of fail to rethrow exceptions.
    Open

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

    This cop checks for uses of fail and raise.

    Example: EnforcedStyle: only_raise (default)

    # The `only_raise` style enforces the sole use of `raise`.
    # bad
    begin
      fail
    rescue Exception
      # handle it
    end
    
    def watch_out
      fail
    rescue Exception
      # handle it
    end
    
    Kernel.fail
    
    # good
    begin
      raise
    rescue Exception
      # handle it
    end
    
    def watch_out
      raise
    rescue Exception
      # handle it
    end
    
    Kernel.raise

    Example: EnforcedStyle: only_fail

    # The `only_fail` style enforces the sole use of `fail`.
    # bad
    begin
      raise
    rescue Exception
      # handle it
    end
    
    def watch_out
      raise
    rescue Exception
      # handle it
    end
    
    Kernel.raise
    
    # good
    begin
      fail
    rescue Exception
      # handle it
    end
    
    def watch_out
      fail
    rescue Exception
      # handle it
    end
    
    Kernel.fail

    Example: EnforcedStyle: semantic

    # The `semantic` style enforces the use of `fail` to signal an
    # exception, then will use `raise` to trigger an offense after
    # it has been rescued.
    # bad
    begin
      raise
    rescue Exception
      # handle it
    end
    
    def watch_out
      # Error thrown
    rescue Exception
      fail
    end
    
    Kernel.fail
    Kernel.raise
    
    # good
    begin
      fail
    rescue Exception
      # handle it
    end
    
    def watch_out
      fail
    rescue Exception
      raise 'Preferably with descriptive message'
    end
    
    explicit_receiver.fail
    explicit_receiver.raise

    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 [])

    Assignment Branch Condition size for query_hits is too high. [<7, 29, 4> 30.1/17]
    Open

          def query_hits(xml_ir, tsv_ir, query)
            return [] if xml_ir == ["\n"] # => No hits.
    
            xml_ir.map do |n|
              # If hit comes from a non -parse_seqids database, then id (n[1]) is a
    Severity: Minor
    Found in lib/sequenceserver/blast/report.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 [])

    Add empty line after guard clause.
    Open

          return if alias?
    Severity: Minor
    Found in lib/sequenceserver/database.rb by rubocop

    This cop enforces empty line after guard clause

    Example:

    # bad
    def foo
      return if need_return?
      bar
    end
    
    # good
    def foo
      return if need_return?
    
      bar
    end
    
    # good
    def foo
      return if something?
      return if something_different?
    
      bar
    end
    
    # also good
    def foo
      if something?
        do_something
        return if need_return?
      end
    end
    Severity
    Category
    Status
    Source
    Language