openSNP/snpr

View on GitHub

Showing 49 of 71 total issues

Method create_picture_phenotype_csv has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_picture_phenotype_csv(zipfile)
    file_name = "#{tmp_dir}/picture_dump#{time_str}.csv"
    logger.info("Writing picture-CSV to #{file_name}")

    list_of_pics = [] # need this for the zip-file-later
Severity: Minor
Found in app/workers/zipfulldata.rb - About 1 hr to fix

    Method process_row has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def process_row(row)
        snp_name = row[21]
        pvalue   = row[27].to_f
        snp      = Snp.find_by_name(snp_name)
        return unless snp && pvalue < 1e-8 && known_snps.include?(snp_name.downcase)
    Severity: Minor
    Found in app/workers/genome_gov.rb - About 1 hr to fix

      Method create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          @user_phenotype = current_user.user_picture_phenotypes.new(
            phenotype_picture: params[:user_picture_phenotype][:phenotype_picture])
          @user_phenotype.phenotype_picture = params[:user_picture_phenotype][:phenotype_picture]
          @user_phenotype.user_id = current_user.id
      Severity: Minor
      Found in app/controllers/user_picture_phenotypes_controller.rb - About 1 hr to fix

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

          def index
            # showing all users
            # TODO: Refactor this. - Helge
            @users = User.order(sort_column + ' ' + sort_direction)
            @users_paginate = @users.paginate(page: params[:page], per_page: 10)
        Severity: Minor
        Found in app/controllers/users_controller.rb - About 1 hr to fix

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

            def perform(snp_id)
              Snp.reset_counters(snp_id, :user_snps)
              s = Snp.find(snp_id)
              s.allele_frequency ||= { "A" => 0, "T" => 0, "G" => 0, "C" => 0}
              s.genotype_frequency ||= {}
          Severity: Minor
          Found in app/workers/frequency.rb - About 1 hr to fix

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

              def create
                @user_phenotype = UserPhenotype.new(user_phenotype_params)
                @user_phenotype.user_id = current_user.id
            
                if params[:js_modal]
            Severity: Minor
            Found in app/controllers/user_phenotypes_controller.rb - About 1 hr to fix

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

                def process_documents(documents)
                  if documents.blank?
                    logger.info("mendeley: No papers found")
                    return
                  end
              Severity: Minor
              Found in app/workers/mendeley_search.rb - About 1 hr to fix

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

                  def json_element(params)
                    # TODO: Refactor this. - Helge
                    @result = {}
                    begin
                      @snp = params[:snp] || Snp.find_by_name(params[:snp_name].downcase)
                Severity: Minor
                Found in app/controllers/snps_controller.rb - About 1 hr to fix

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

                    def update
                      @user = User.find(params[:id])
                  
                      if params[:user][:user_phenotypes_attributes].present?
                        params[:user][:user_phenotypes_attributes].each do |p|
                  Severity: Minor
                  Found in app/controllers/users_controller.rb - About 1 hr to fix

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

                      def perform(mendeley_paper_id)
                         mendeley_paper = MendeleyPaper.find_by_id(mendeley_paper_id.to_i)
                         return if mendeley_paper.nil?
                    
                         key_handle = File.open(::Rails.root.to_s+"/key_mendeley.txt")
                    Severity: Minor
                    Found in app/workers/mendeley_details.rb - About 1 hr to fix

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

                        def run
                          genotypes = Genotype.includes(user: :user_phenotypes)
                          logger.info("Got #{genotypes.length} genotypes")
                      
                          # only create a new file if in the current minute none has been created yet
                      Severity: Minor
                      Found in app/workers/zipfulldata.rb - About 1 hr to fix

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

                          def json_annotation
                            result = {}
                            if params[:snp_name].index(',')
                              snps = params[:snp_name].split(',')
                              snps.each do |s|
                        Severity: Minor
                        Found in app/controllers/snps_controller.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 create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def create
                            @snp_comment = SnpComment.new(comment_params)
                            if @snp_comment.comment_text.index(/\A(\@\#\d*\:)/) == nil
                              @snp_comment.reply_to_id = -1
                            else
                        Severity: Minor
                        Found in app/controllers/snp_comments_controller.rb - About 1 hr to fix

                          Method create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def create
                              @phenotype_comment = PicturePhenotypeComment.new(picture_phenotype_comment_params)
                              if @phenotype_comment.comment_text.index(/\A(\@\#\d*\:)/) == nil
                                @phenotype_comment.reply_to_id = -1
                              else
                          Severity: Minor
                          Found in app/controllers/picture_phenotype_comments_controller.rb - About 1 hr to fix

                            Method create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def create
                                @phenotype_comment = PhenotypeComment.new(phenotype_comment_params)
                                if @phenotype_comment.comment_text.index(/\A(\@\#\d*\:)/) == nil
                                  @phenotype_comment.reply_to_id = -1
                                else
                            Severity: Minor
                            Found in app/controllers/phenotype_comments_controller.rb - About 1 hr to fix

                              Method parse_iyg has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def parse_iyg(rows)
                                  db_snp_names = {
                                    "MT-T3027C" => "rs199838004", "MT-T4336C" => "rs41456348",
                                    "MT-G4580A" => "rs28357975", "MT-T5004C" => "rs41419549",
                                    "MT-C5178a" => "rs28357984", "MT-A5390G" => "rs41333444",
                              Severity: Minor
                              Found in app/workers/parsing.rb - About 1 hr to fix

                                Method perform has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def perform(phenotype_id, variation, target_address)
                                    @user_phenotypes = UserPhenotype
                                      .where(phenotype_id: phenotype_id)
                                      .search(variation)
                                    @genotyping_files = []
                                Severity: Minor
                                Found in app/workers/zipgenotypingfiles.rb - About 1 hr to fix

                                  Method perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    def perform(mendeley_paper_id)
                                       mendeley_paper = MendeleyPaper.find_by_id(mendeley_paper_id.to_i)
                                       return if mendeley_paper.nil?
                                  
                                       key_handle = File.open(::Rails.root.to_s+"/key_mendeley.txt")
                                  Severity: Minor
                                  Found in app/workers/mendeley_details.rb - About 55 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

                                  Avoid deeply nested control flow statements.
                                  Open

                                      elsif genotype.filetype == "ftdna-illumina"
                                        # first line is of length 4
                                        if l.strip.split(",").length == 4
                                          file_is_ok = true
                                          logger.info "file is ftdna and is ok!"
                                  Severity: Major
                                  Found in app/workers/preparsing.rb - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                          if l.strip.split(",").length == 6
                                            file_is_ok = true
                                            logger.info "file is decodeme and is ok!"
                                          end
                                    Severity: Major
                                    Found in app/workers/preparsing.rb - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language