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

  def exp_conditions_search_fields
    flds = experimental_conditions.collect do |ec|
      [ec.measured_item.title,
       ec.substances.collect do |sub|
         #FIXME: this makes the assumption that the synonym.substance appears like a Compound
Severity: Major
Found in app/models/sop.rb and 1 other location - About 1 hr to fix
app/models/data_file.rb on lines 129..141

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

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 @strain.save
      if @strain.from_biosamples=='true'
        #reload to get updated nested attributes,e.g. genotypes/phenotypes
        @strain.reload
        render :partial => "biosamples/back_to_biosamples", :locals => {:action => 'create', :object => @strain}
Severity: Major
Found in app/controllers/strains_controller.rb and 1 other location - About 1 hr to fix
app/controllers/strains_controller.rb on lines 74..89

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

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

Function updateAssays has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function updateAssays() {
    assay_text = '<ul class="related_asset_list">'
    for (var i=0;i<assays_array.length;i++) {
        assay=assays_array[i];
        title=assay[0];
Severity: Minor
Found in app/assets/javascripts/assays.js - About 1 hr to fix

    Method tag_with has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def tag_with tags, attr="tag", owner=User.current_user,owned_tags_only=false
          tags = Array(tags)
          #FIXME: yuck! - this is required so that self has an id and can be assigned to an Annotation.annotatable
          return if self.new_record? && !self.save
    
    
    Severity: Minor
    Found in lib/seek/taggable.rb - About 1 hr to fix

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

      function from_url_selected(){
          Effect.Fade("upload_from_file", {
              duration: 0.0
          });
          Effect.Appear("upload_from_url");
      Severity: Major
      Found in app/assets/javascripts/upload_selection.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/upload_selection.js on lines 37..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 67.

      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

      function from_file_selected(){
          Effect.Fade("upload_from_url", {
              duration: 0.0
          });
          Effect.Appear("upload_from_file");
      Severity: Major
      Found in app/assets/javascripts/upload_selection.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/upload_selection.js on lines 28..35

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

      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

      Function displayNormal has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      function displayNormal() {
          var xmlHttp;
          try {  // Firefox, Opera 8.0+, Safari  
              xmlHttp = new XMLHttpRequest(); 
              if (xmlHttp.overrideMimeType) {
      Severity: Minor
      Found in app/assets/javascripts/jws/webMathematica.js - 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 dump_tmp_io_object_to_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def dump_tmp_io_object_to_file
          raise Exception.new("You cannot define both :data content and a :tmp_io_object") unless @data.nil? || @tmp_io_object.nil?
          t1 = Time.now
          unless @tmp_io_object.nil?
            begin
      Severity: Minor
      Found in app/models/content_blob.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 associate_organism has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def associate_organism(organism,strain_id=nil,culture_growth_type=nil,tissue_and_cell_type_id="0",tissue_and_cell_type_title=nil)
          organism = Organism.find(organism) if organism.kind_of?(Numeric) || organism.kind_of?(String)
          strain=organism.strains.find_by_id(strain_id)
          assay_organism=AssayOrganism.new(:assay=>self,:organism=>organism,:culture_growth_type=>culture_growth_type,:strain=>strain)
      
      
      Severity: Minor
      Found in app/models/assay.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 resource_title_draggable_avatar has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def resource_title_draggable_avatar resource, version=nil
      
          icon=""
          image=nil
          if resource.avatar_key
      Severity: Minor
      Found in app/helpers/assets_helper.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 policy_to_people_group has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def policy_to_people_group people_in_group, contributor=User.current_user.person
            if sharing_scope == Policy::ALL_SYSMO_USERS
               people_in_network = get_people_in_network access_type
               people_in_group['Network'] |= people_in_network unless people_in_network.blank?
            elsif sharing_scope == Policy::EVERYONE
      Severity: Minor
      Found in app/models/policy.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 date_as_string has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def date_as_string date,show_time_of_day=false,year_only_1st_jan=false
          #for publications, if it is the first of jan, then it can be assumed it is just the year (unlikely have a publication on New Years Day)
          if (year_only_1st_jan && !date.blank? && date.month==1 && date.day==1)
            str=date.year.to_s
          else
      Severity: Minor
      Found in app/helpers/application_helper.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 set_parameters_for_sharing_form has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_parameters_for_sharing_form object=nil
          object ||= eval "@#{controller_name.singularize}"
          policy = nil
          policy_type = ""
      
      
      Severity: Minor
      Found in app/helpers/application_helper.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 people_by_project_options has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def people_by_project_options(projects)
          options = ""
          projects.each do |project|
            project_options = "<optgroup id=#{project.id} title=\"#{h project.title}\" label=\"#{h truncate(project.title)}\">"
            project.people.sort{|a,b| (a.last_name.nil? ? nil : a.last_name.capitalize) <=> (b.last_name.nil? ? nil : b.last_name.capitalize)}.each do |person|
      Severity: Minor
      Found in app/helpers/publications_helper.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 find_and_filter_workflows has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_and_filter_workflows
          find_assets
      
          # Has the user cleared the search box? - return all items.
          uploader = params[:uploader_id]
      Severity: Minor
      Found in app/controllers/workflows_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 update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          @person.disciplines.clear if params[:discipline_ids].nil?
      
          # extra check required to see if any avatar was actually selected (or it remains to be the default one)
          
      Severity: Minor
      Found in app/controllers/people_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 a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          respond_to do |format|
            format.html do
              # see notes in application.rb on how this works
              update_last_seen_at
      Severity: Minor
      Found in app/controllers/topics_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 check_for_override has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_for_override context, options
            unless options[:seek_template].nil?
              value = @@alternative_map[{:controller => context.controller_name, :seek_template => options[:seek_template].to_s}]
              unless value.nil?
                options[:template]=value
      Severity: Minor
      Found in lib/seek/seek_render_override.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 update_others has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_others
          update_flag = true
          if Seek::Config.tag_threshold.to_s != params[:tag_threshold] || Seek::Config.max_visible_tags.to_s!=params[:max_visible_tags]
            expire_annotation_fragments
          end
      Severity: Minor
      Found in app/controllers/admins_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 fetch_preview has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def fetch_preview
          #trim the PubMed or Doi Id
          params[:key] = params[:key].strip() unless params[:key].blank?
          params[:publication][:project_ids].reject!(&:blank?).map! { |id| id.split(',') }.flatten!
          @publication = Publication.new(params[:publication])
      Severity: Minor
      Found in app/controllers/publications_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

      Severity
      Category
      Status
      Source
      Language