SysMO-DB/seek

View on GitHub

Showing 1,025 of 1,025 total issues

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

  if (contentId.style.display == 'block') {contentId.style.display = 'none';contentId2.style.display='none'; contentId3.style.display='none';contentId4.style.display='none'; contentId5.style.display='none'; contentId6.style.display='none'; contentId7.style.display='none'; contentId8.style.display='none'; contentId9.style.display='none'; contentId10.style.display='none'}
Severity: Major
Found in app/assets/javascripts/jws/JWSconstructor_panels.js and 1 other location - About 5 hrs to fix
app/assets/javascripts/jws/JWSconstructor_panels.js on lines 29..29

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

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

  else { contentId.style.display = 'block';contentId2.style.display='block'; contentId3.style.display='block';contentId4.style.display='block'; contentId5.style.display='block'; contentId6.style.display='block'; contentId7.style.display='block'; contentId8.style.display='block'; contentId9.style.display='block'; contentId10.style.display='block'}
Severity: Major
Found in app/assets/javascripts/jws/JWSconstructor_panels.js and 1 other location - About 5 hrs to fix
app/assets/javascripts/jws/JWSconstructor_panels.js on lines 28..28

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

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

    for (i=0;i<publication_array.length;i++) {
        id=publication_array[i][1];
        relationshipType=publication_array[i][2];
        o=document.createElement('option');
        o.value=id + "," + relationshipType;
Severity: Major
Found in app/assets/javascripts/publication.js and 1 other location - About 5 hrs to fix
app/assets/javascripts/assays.js on lines 193..206

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

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

    for (i=0;i<data_files_assets.length;i++) {
        id=data_files_assets[i][1];
        relationshipType=data_files_assets[i][2];
        o=document.createElement('option');
        o.value=id + "," + relationshipType;
Severity: Major
Found in app/assets/javascripts/assays.js and 1 other location - About 5 hrs to fix
app/assets/javascripts/publication.js on lines 67..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 150.

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

File policy.rb has 400 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Policy < ActiveRecord::Base
  
  has_many :permissions,
           :dependent => :destroy,
           :order => "created_at ASC",
Severity: Minor
Found in app/models/policy.rb - About 5 hrs to fix

    Function ResizeableTextbox has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    function ResizeableTextbox(id, parent)
    {
      var MINWIDTH = 125;
      var MINHEIGHT = 80;
      var MINSIZE = 38;
    Severity: Minor
    Found in app/assets/javascripts/jws/Resizeable_Textbox/javascript.js - 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 create has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        if handle_upload_data
    
          @data_file = DataFile.new params[:data_file]
    
    
    Severity: Minor
    Found in app/controllers/data_files_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 indented_child_options has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

            def indented_child_options type, parent, depth=0, selected_id
    
              result = []
              unless parent.children.empty?
                parent.children.sort { |a, b| a.title.downcase <=> b.title.downcase }.each do |child|
    Severity: Minor
    Found in lib/acts_as_ontology_view_helper.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

    File admins_controller.rb has 399 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'delayed/command'
    
    class AdminsController < ApplicationController
      include CommonSweepers
    
    
    Severity: Minor
    Found in app/controllers/admins_controller.rb - About 5 hrs to fix

      Class User has 41 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class User < ActiveRecord::Base
        acts_as_annotation_source
        include SavageBeast::UserInit
      
        acts_as_tagger
      Severity: Minor
      Found in app/models/user.rb - About 5 hrs to fix

        Function ResizeableContainer has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        function ResizeableContainer(contentID, parent)
        {
          var MINSIZE = 38;
          var EDGE_THICKNESS = 7;
          var EDGEDIFFSIZE = 2*EDGE_THICKNESS + 3;
        Severity: Minor
        Found in app/assets/javascripts/jws/Resizeable_Container/javascript.js - 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 append_list_assay_organisms has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

          def append_list_assay_organisms assay_organisms
            result=""
        
            organism=nil
            strain = nil
        Severity: Minor
        Found in app/helpers/assays_helper.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

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

                    for(var key in allLinks[resource_type]) {
                        hide_row = resource_type +"_" + key + "_source_row";
                        $(hide_row).hide();
                        targetMap[resource_type][key] = true;
                        sourceMap[resource_type][key] = false;
        Severity: Major
        Found in app/assets/javascripts/link_adder.js and 1 other location - About 5 hrs to fix
        app/assets/javascripts/link_adder.js on lines 94..105

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

        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

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

                     if (allLinks[resource_type][key] == true) {
                        hide_row = resource_type + "_" + key + "_source_row";
                        $(hide_row).hide();
                        targetMap[resource_type][key] = true;
                        sourceMap[resource_type][key] = false;
        Severity: Major
        Found in app/assets/javascripts/link_adder.js and 1 other location - About 5 hrs to fix
        app/assets/javascripts/link_adder.js on lines 42..54

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

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

          def get_resource_hash scale, external_resource_hash
            internal_resource_hash = {}
            if external_resource_hash.blank?
              @results_scaled[scale].each do |item|
                tab = item.respond_to?(:tab) ? item.tab : item.class.name
        Severity: Minor
        Found in app/helpers/search_helper.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 set_attributes_with_sharing has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

          def set_attributes_with_sharing sharing, projects
            # if no data about sharing is given, it should be some user (not the owner!)
            # who is editing the asset - no need to do anything with policy / permissions: return success
            self.tap do |policy|
              if sharing
        Severity: Minor
        Found in app/models/policy.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 create has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @sample = Sample.new(params[:sample])
            # create new specimen only for combined form
            is_new_spec = params[:sample][:specimen_id].nil? ? true : false
        
        
        Severity: Minor
        Found in app/controllers/samples_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 is_authorized? has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.is_authorized?(action, thing_type, thing, user=nil)
        
                # initially not authorized, so if all tests fail -
                # safe result of being not authorized will get returned
                is_authorized = false
        Severity: Minor
        Found in lib/seek/permissions/authorization.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 populate_sample has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

            def populate_sample sample_json, specimen, assay=nil
        
        
                sample_title = sample_json["title"]
                sample_type = sample_json["type"]
        Severity: Minor
        Found in lib/seek/data/bio_samples.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

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

        function absoluteCursorPostion(eventObj)
        {
          eventObj = eventObj ? eventObj : window.event;
          
          if(isNaN(window.scrollX))
        Severity: Major
        Found in app/assets/javascripts/jws/Resizeable_Textbox/javascript.js and 1 other location - About 5 hrs to fix
        app/assets/javascripts/jws/Resizeable_Container/javascript.js on lines 145..154

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

        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

        Severity
        Category
        Status
        Source
        Language