openSNP/snpr

View on GitHub

Showing 71 of 71 total issues

Method update has a Cognitive Complexity of 12 (exceeds 5 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

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 show has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    # showing a single user's page
    @user = User.find_by_id(params[:id]) || not_found
    @title = @user.name + '\'s page'
    @first_name = @user.name.split.first
Severity: Minor
Found in app/controllers/users_controller.rb - About 1 hr to fix

    Method create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        unless @phenotype = PicturePhenotype.find_by_characteristic(params[:picture_phenotype][:characteristic])
          puts params[:picture_phenotype]
          @phenotype = PicturePhenotype.create(picture_phenotype_params)
    
    
    Severity: Minor
    Found in app/controllers/picture_phenotypes_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 a Cognitive Complexity of 11 (exceeds 5 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

    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 perform has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform()
        puts "Running PgpAnnotationJob\n"
        known_snps = {}
        Snp.find_each do |s| known_snps[s.name] = true end
    
    
    Severity: Minor
    Found in app/workers/pgpannotation.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 a Cognitive Complexity of 11 (exceeds 5 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

    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_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 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 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 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 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 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
                              @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 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
                              Severity
                              Category
                              Status
                              Source
                              Language