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

            var last_col = $(this).parent().parent().parent().find("div.col_heading").size();
Severity: Minor
Found in app/assets/javascripts/spreadsheet_explorer.js and 1 other location - About 35 mins to fix
app/assets/javascripts/spreadsheet_explorer.js on lines 213..213

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

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

function validateUploadFormFields(respond_to_content_blobs, resource_name) {
    if (respond_to_content_blobs) {
        if ($('pending_files').children.length == 0 && $(resource_name + "_image_image_file") == null) {
            alert("Please specify at least a file to upload or provide a URL.");
            return (false);
Severity: Minor
Found in app/assets/javascripts/resource.js - About 35 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

Function updateDisciplines has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function updateDisciplines() {
    discipline_text=''
    type="Discipline"
    discipline_ids=new Array();

Severity: Minor
Found in app/assets/javascripts/people.js - About 35 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

Function updateOrganisms has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function updateOrganisms() {
    organism_text=''
    type="Organism"
    organism_ids=new Array();

Severity: Minor
Found in app/assets/javascripts/projects.js - About 35 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

Method clean_up_and_assign_permissions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def clean_up_and_assign_permissions
    #remove the permissions which are set on this person
    remove_permissions

    #retrieve the items that this person is contributor (owner for assay)
Severity: Minor
Found in app/models/person.rb - About 35 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

Method data_io_object has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def data_io_object
    return @tmp_io_object unless @tmp_io_object.nil?
    return StringIO.new(@data) unless @data.nil? 
    return File.open(filepath,"rb") if file_exists?
    return StringIO.new(data_old) unless data_old.nil?
Severity: Minor
Found in app/models/content_blob.rb - About 35 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

Function bindAnnotations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function bindAnnotations(annotation_sources) {
    var annotationIndexTable = $j("div#annotation_overview table");
    for(var s = 0; s < annotation_sources.size(); s++)
    {
        var source = annotation_sources[s];
Severity: Minor
Found in app/assets/javascripts/spreadsheet_explorer.js - About 35 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

Function check_show_existing_items has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function check_show_existing_items(organism_element_id, existing_items_element_id, url) {
    var selected_ids = $F(organism_element_id).join();
    if (selected_ids == '0') {
        if ($(existing_items_element_id + "_spinner") != null)
            Effect.Fade(existing_items_element_id + "_spinner");
Severity: Minor
Found in app/assets/javascripts/biosample.js - About 35 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

Method public_asset_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def public_asset_url(size = nil)
    size ||= 200

    if size == 'large'
      size = LARGE_SIZE
Severity: Minor
Found in app/models/avatar.rb - About 35 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

Method child_type_links has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def child_type_links children,type
      unless children.empty?
        children.collect do |child|
          if child.is_a?(SuggestedAssayType) || child.is_a?(SuggestedTechnologyType)
            uris = ([child] +child.children).map(&:uri)
Severity: Minor
Found in app/helpers/assay_types_helper.rb - About 35 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

Method delayed_job_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def delayed_job_status
    status = ""
    begin
      pids = [0,1].collect do |n|
        Daemons::PidFile.new("#{Rails.root}/tmp/pids","delayed_job.#{n.to_s}")
Severity: Minor
Found in app/helpers/admin_helper.rb - About 35 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

Method top_level_menu_tabs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def top_level_menu_tabs definitions
    selected_tab = current_top_level_tab(definitions)
    definitions.select{|d| !d[:hide]}.collect do |menu|
      attributes = ""
      attributes << "id = 'selected_tabnav'" if selected_tab == menu
Severity: Minor
Found in app/helpers/menu_helper.rb - About 35 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

Method author_display_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def author_display_list publication
    if publication.publication_author_orders.empty?
       "<span class='none_text'>Not specified</span>".html_safe
    else
      author_list = []
Severity: Minor
Found in app/helpers/publications_helper.rb - About 35 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

Method tagged_substances has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

   def tagged_substances resource
      tagged_substances = []
      link_table_name = (resource.class.name == 'StudiedFactor') ? 'studied_factor_links' : 'experimental_condition_links'
      if !resource.nil?
        (resource.send link_table_name).each do |ltn|
Severity: Minor
Found in app/helpers/studied_factors_helper.rb - About 35 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

Method process_privileged_people has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def process_privileged_people privileged_people, resource_name
    html = ''
    if !privileged_people.blank?
      html << "<h3> Privileged people:</h3>"
      privileged_people.each do |key, value|
Severity: Minor
Found in app/helpers/policy_helper.rb - About 35 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

Method child_single_select_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def child_single_select_options parent, depth=0
    result = []

    unless parent.children.empty?
      parent.children.sort { |a, b| a.title.downcase <=> b.title.downcase }.each do |child|
Severity: Minor
Found in app/helpers/projects_helper.rb - About 35 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

Method fancy_multiselect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def fancy_multiselect object, association, options = {}

      if reflection = options[:object_class].reflect_on_association(association)
        required_access = reflection.options[:required_access] || :can_view?
        #get 'view' from :can_view?
Severity: Minor
Found in app/helpers/fancy_multiselect_helper.rb - About 35 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

Method is_entirely_private? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def is_entirely_private? grouped_people_by_access_type, contributor
    entirely_private = true
    if access_type > Policy::NO_ACCESS
        entirely_private = false
    else
Severity: Minor
Found in app/models/policy.rb - About 35 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

Method describe_visibility has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def describe_visibility(model)
    text = '<strong>Visibility:</strong> '

    if model.policy.sharing_scope == 0
      css_class = 'private'
Severity: Minor
Found in app/helpers/application_helper.rb - About 35 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

Method classify_for_tabs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def classify_for_tabs result_collection
    results={}

    result_collection.each do |res|
      tab = res.respond_to?(:tab) ? res.tab : res.class.name
Severity: Minor
Found in app/helpers/application_helper.rb - About 35 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

Severity
Category
Status
Source
Language