Blahah/transrate

View on GitHub

Showing 34 of 34 total issues

File cmdline.rb has 478 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Transrate

class Cmdline

  require 'trollop'
Severity: Minor
Found in lib/transrate/cmdline.rb - About 7 hrs to fix

    Class Cmdline has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Cmdline
    
      require 'trollop'
      require 'csv'
      require 'bindeps'
    Severity: Minor
    Found in lib/transrate/cmdline.rb - About 4 hrs to fix

      Method per_target_contig_reference_coverage has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def per_target_contig_reference_coverage crbblast
            # each target sequence in the reference can have multiple query contigs
            # hit it. to calculate the reference coverage you can't just add up the
            # alignment lengths. you have to make sure that overlaps are taken into
            # account
      Severity: Minor
      Found in lib/transrate/comparative_metrics.rb - About 3 hrs 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

      Class Contig has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Contig
      
          include Enumerable
          extend Forwardable
          def_delegators :@seq, :size, :length
      Severity: Minor
      Found in lib/transrate/contig.rb - About 3 hrs to fix

        Method build_index has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def build_index file, threads
              @index_name = File.basename(file, File.extname(file))
              n = 4
              err = ""
              loop do
        Severity: Minor
        Found in lib/transrate/snap.rb - About 2 hrs 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 basic_bin_stats has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def basic_bin_stats bin
        
              # cumulative length is a float so we can divide it
              # accurately later to get the mean length
              cumulative_length = 0.0
        Severity: Minor
        Found in lib/transrate/assembly.rb - About 2 hrs 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 per_target_contig_reference_coverage has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def per_target_contig_reference_coverage crbblast
              # each target sequence in the reference can have multiple query contigs
              # hit it. to calculate the reference coverage you can't just add up the
              # alignment lengths. you have to make sure that overlaps are taken into
              # account
        Severity: Major
        Found in lib/transrate/comparative_metrics.rb - About 2 hrs to fix

          Method basic_bin_stats has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def basic_bin_stats bin
          
                # cumulative length is a float so we can divide it
                # accurately later to get the mean length
                cumulative_length = 0.0
          Severity: Minor
          Found in lib/transrate/assembly.rb - About 1 hr to fix

            Method write_contig_csv has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def write_contig_csv a
                # write contig metrics to file for each contig
                outfile = File.expand_path "contigs.csv"
                logger.info "Writing contig metrics for each contig to #{outfile}"
                # have option to turn off, default on
            Severity: Minor
            Found in lib/transrate/cmdline.rb - About 1 hr 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 per_query_contig_reference_coverage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def per_query_contig_reference_coverage
                  # for each query contig in the @assembly find out how much it covers
                  # the reference
                  n_refs_with_recip = 0
                  total_crbb_hits = 0
            Severity: Minor
            Found in lib/transrate/comparative_metrics.rb - About 1 hr 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 run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def run left, right, threads:8
                  # check all read files exist
                  [left, right].each do |readfile|
                    raise TransrateIOError.new "Read file is nil" if readfile.nil?
                    readfile.split(",").each do |file|
            Severity: Minor
            Found in lib/transrate/read_metrics.rb - About 1 hr 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 initialize has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def initialize file
                  @file = File.expand_path file
                  unless File.exist? @file
                    raise TransrateIOError.new "Assembly file doesn't exist: #{@file}"
                  end
            Severity: Minor
            Found in lib/transrate/assembly.rb - About 1 hr to fix

              Method map_reads has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def map_reads(file, left, right, outputname: nil, threads: 8)
                    raise SnapError.new("Index not built") if !@index_built
              
                    lbase = File.basename(left.split(",").first)
                    rbase = File.basename(right.split(",").first)
              Severity: Minor
              Found in lib/transrate/snap.rb - About 1 hr to fix

                Method optimal_score has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def optimal_score(prefix='assembly')
                      return [@optimal, @cutoff] unless @optimal.nil?
                      product = 0
                      good = 0
                      @assembly.assembly.each do |key, contig|
                Severity: Minor
                Found in lib/transrate/score_optimiser.rb - About 1 hr to fix

                  Method build_index has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def build_index file, threads
                        @index_name = File.basename(file, File.extname(file))
                        n = 4
                        err = ""
                        loop do
                  Severity: Minor
                  Found in lib/transrate/snap.rb - About 1 hr to fix

                    Method argument_parser has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def argument_parser
                        cmdline = self
                        Trollop::Parser.new do
                          version Transrate::VERSION::STRING.dup
                          banner cmdline.help_message
                    Severity: Minor
                    Found in lib/transrate/cmdline.rb - About 1 hr to fix

                      Method classify_contigs has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def classify_contigs cutoff
                            # create hash of file handles for each output
                            base = File.basename @file
                            files = {}
                            %w(good bad).each do |type|
                      Severity: Minor
                      Found in lib/transrate/assembly.rb - About 1 hr to fix

                        Method run has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def run left, right, threads:8
                              # check all read files exist
                              [left, right].each do |readfile|
                                raise TransrateIOError.new "Read file is nil" if readfile.nil?
                                readfile.split(",").each do |file|
                        Severity: Minor
                        Found in lib/transrate/read_metrics.rb - About 1 hr to fix

                          Method per_query_contig_reference_coverage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def per_query_contig_reference_coverage
                                # for each query contig in the @assembly find out how much it covers
                                # the reference
                                n_refs_with_recip = 0
                                total_crbb_hits = 0
                          Severity: Minor
                          Found in lib/transrate/comparative_metrics.rb - About 1 hr to fix

                            Method get_read_length has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def get_read_length(left, right)
                                  count=0
                                  file = File.open(left.split(",").first)
                                  name = file.readline.chomp
                                  seq = file.readline.chomp
                            Severity: Minor
                            Found in lib/transrate/read_metrics.rb - About 1 hr 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

                            Severity
                            Category
                            Status
                            Source
                            Language