openSNP/snpr

View on GitHub

Showing 66 of 66 total issues

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

  def perform(genotype_id)
    genotype = Genotype.find(genotype_id)

    logger.info "Starting preparse"
    biggest = ''
Severity: Minor
Found in app/workers/preparsing.rb - About 5 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 show has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def show
        @user = User.find_by_id(params[:id])
        @genotype = @user.genotypes.first

        # make arrays of positions and ids in case we have several
Severity: Minor
Found in app/controllers/das_controller.rb - About 5 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 perform has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perform(genotype_id)
    genotype = Genotype.find(genotype_id)

    logger.info "Starting preparse"
    biggest = ''
Severity: Major
Found in app/workers/preparsing.rb - About 4 hrs to fix

    Similar blocks of code found in 2 locations. 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: Major
    Found in app/controllers/picture_phenotype_comments_controller.rb and 1 other location - About 2 hrs to fix
    app/controllers/phenotype_comments_controller.rb on lines 15..44

    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 104.

    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

      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: Major
    Found in app/controllers/phenotype_comments_controller.rb and 1 other location - About 2 hrs to fix
    app/controllers/picture_phenotype_comments_controller.rb on lines 15..44

    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 104.

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

        def show
            @user = User.find_by_id(params[:id])
            @genotype = @user.genotypes.first
    
            # make arrays of positions and ids in case we have several
    Severity: Major
    Found in app/controllers/das_controller.rb - About 2 hrs to fix

      Method make_annotation has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def make_annotation(result, snp, name)
          # TODO: Refactor this. - Helge
          result[name] = {}
          result[name]['name'] = snp.name
          result[name]['chromosome'] = snp.chromosome
      Severity: Major
      Found in app/controllers/snps_controller.rb - About 2 hrs to fix

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

            $('#remove_help_two').click(function() {
                if( $('#help_one').is(":hidden") && $('#help_three').is(":hidden") ){
                    $("#help_block").hide("slow");
                }
                else {
        Severity: Major
        Found in app/assets/javascripts/application.js and 1 other location - About 2 hrs to fix
        app/assets/javascripts/application.js on lines 25..32

        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 88.

        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

            $('#remove_help_one').click(function() {
                if( $('#help_three').is(":hidden") && $('#help_two').is(":hidden") ){
                    $("#help_block").hide("slow");
                }
                else {
        Severity: Major
        Found in app/assets/javascripts/application.js and 1 other location - About 2 hrs to fix
        app/assets/javascripts/application.js on lines 33..40

        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 88.

        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 perform has a Cognitive Complexity of 19 (exceeds 5 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 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

        Function snpApp has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var snpApp = function () {
              var $searchButton = $('[data-js="search-button"]');
              var $searchForm = $('[data-js="search-form"]');
              var $panelHeader = $('[data-js="panel-header"]');
              var $extendButton = $('[data-js="extend-button"]');
        Severity: Major
        Found in app/assets/javascripts/script.js - About 2 hrs to fix

          Method perform_search has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def perform_search
              # return an array of page-titles
              pages = client.list("#{snp.name}(")
              snpedia_updated = false
              (pages || []).each do |page|
          Severity: Minor
          Found in app/workers/snpedia.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 create has a Cognitive Complexity of 16 (exceeds 5 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 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 create has a Cognitive Complexity of 16 (exceeds 5 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 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 create has a Cognitive Complexity of 16 (exceeds 5 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 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

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

              if UserPhenotype.find_by_phenotype_id_and_user_id(@user_phenotype.phenotype_id,@user_phenotype.user_id) == nil
          
                @phenotype = Phenotype.find_by_id(params[:user_phenotype][:phenotype_id])
          
                if @user_phenotype.save
          Severity: Major
          Found in app/controllers/user_phenotypes_controller.rb and 1 other location - About 2 hrs to fix
          app/controllers/user_picture_phenotypes_controller.rb on lines 56..80

          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 79.

          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

              if UserPicturePhenotype.find_by_picture_phenotype_id_and_user_id(@user_phenotype.picture_phenotype_id,@user_phenotype.user_id) == nil
          
                @phenotype = PicturePhenotype.find_by_id(params[:user_picture_phenotype][:picture_phenotype_id])
          
                if @user_phenotype.save
          Severity: Major
          Found in app/controllers/user_picture_phenotypes_controller.rb and 1 other location - About 2 hrs to fix
          app/controllers/user_phenotypes_controller.rb on lines 34..60

          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 79.

          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 process_documents has a Cognitive Complexity of 13 (exceeds 5 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

          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 38 lines of code (exceeds 25 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

            Method create has 36 lines of code (exceeds 25 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
              Severity
              Category
              Status
              Source
              Language