SysMO-DB/seek

View on GitHub

Showing 1,025 of 1,025 total issues

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

  def perform_search
    @search_query = params[:search_query]
    @search=@search_query # used for logging, and logs the origin search query - see ApplicationController#log_event
    @search_query||=""
    @search_type = params[:search_type]
Severity: Minor
Found in app/controllers/search_controller.rb - About 4 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 3 locations. Consider refactoring.
Open

        {
            var topRightCenterX = nodeX + halfWidth - cornerRadius;
            var topRightCenterY = nodeY - halfHeight + cornerRadius
            arcIntersections = this.intersectLineCircle(
                x, y, nodeX, nodeY,
Severity: Major
Found in app/assets/javascripts/modified_cytoscape.js and 2 other locations - About 4 hrs to fix
app/assets/javascripts/modified_cytoscape.js on lines 387..400
app/assets/javascripts/modified_cytoscape.js on lines 419..432

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

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 3 locations. Consider refactoring.
Open

        {
            var topLeftCenterX = nodeX - halfWidth + cornerRadius;
            var topLeftCenterY = nodeY - halfHeight + cornerRadius
            arcIntersections = this.intersectLineCircle(
                x, y, nodeX, nodeY,
Severity: Major
Found in app/assets/javascripts/modified_cytoscape.js and 2 other locations - About 4 hrs to fix
app/assets/javascripts/modified_cytoscape.js on lines 403..416
app/assets/javascripts/modified_cytoscape.js on lines 419..432

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

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 3 locations. Consider refactoring.
Open

        {
            var bottomRightCenterX = nodeX + halfWidth - cornerRadius;
            var bottomRightCenterY = nodeY + halfHeight - cornerRadius
            arcIntersections = this.intersectLineCircle(
                x, y, nodeX, nodeY,
Severity: Major
Found in app/assets/javascripts/modified_cytoscape.js and 2 other locations - About 4 hrs to fix
app/assets/javascripts/modified_cytoscape.js on lines 387..400
app/assets/javascripts/modified_cytoscape.js on lines 403..416

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

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

Class ApplicationController has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

class ApplicationController < ActionController::Base

  include Seek::Errors::ControllerErrorHandling
  include Seek::EnabledFeaturesFilter
  include Recaptcha::Verify
Severity: Minor
Found in app/controllers/application_controller.rb - About 4 hrs to fix

    Class BioSamples has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class BioSamples
    
        attr_reader :investigation, :study, :assay, :assay_class, :assay_type,
                    :units, :treatments, :organisms, :strains, :culture_growth_type, :tissue_and_cell_types,
                    :specimens, :samples,  :specimen_names, :sample_names, :treatments,:treatments_text,
    Severity: Minor
    Found in lib/seek/data/bio_samples.rb - About 4 hrs to fix

      Method create_or_update_attributions has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.create_or_update_attributions(resource, attributions_from_params, predicate = Relationship::ATTRIBUTED_TO)
      
          # added this branching on .nil? because of the danger of loosing all attributions for a model (for example) if due to an incomplete post request attributions is nil
          # the former code interpreted a nil parameter as an empty list => remove all attributions from an asset
          unless attributions_from_params.nil?
      Severity: Minor
      Found in app/models/relationship.rb - About 4 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 dortmund_bcat_ko_mapping has 102 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def dortmund_bcat_ko_mapping
      
            age_regex = /(\d+-?\d*)\s*(day|week|month|year)s?/i
            treatment_substance_regex = /.*\((control|treated)\s?=\s?(.*)\)/i
            treatment_concentration_unit_regex = /(\d*[,\.]?\d*)\s*([\w\s\/]*).*$/
      Severity: Major
      Found in lib/seek/parser_mapper.rb - About 4 hrs to fix

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

                        if( !elesInDragLayer || !elesNotInDragLayer ){
                            elesInDragLayer = [];
                            elesNotInDragLayer = [];
        
                            for (var index = 0; index < elements.length; index++) {
        Severity: Major
        Found in app/assets/javascripts/modified_cytoscape.js and 1 other location - About 4 hrs to fix
        app/assets/javascripts/modified_cytoscape.js on lines 634..647

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

        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( !elesInDragLayer || !elesNotInDragLayer ){
                            elesInDragLayer = [];
                            elesNotInDragLayer = [];
        
                            for (var index = 0; index < elements.length; index++) {
        Severity: Major
        Found in app/assets/javascripts/modified_cytoscape.js and 1 other location - About 4 hrs to fix
        app/assets/javascripts/modified_cytoscape.js on lines 567..580

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

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

        function dragObject(element, attachElement, lowerBound, upperBound, startCallback, moveCallback, endCallback, attachLater)
        {
          if(typeof(element) == "string")
            element = document.getElementById(element);
          if(element == null)
        Severity: Minor
        Found in app/assets/javascripts/jws/Resizeable_Container/javascript.js - About 3 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 dragObject has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        function dragObject(element, attachElement, lowerBound, upperBound, startCallback, moveCallback, endCallback, attachLater)
        {
          if(typeof(element) == "string")
            element = document.getElementById(element);
          if(element == null)
        Severity: Minor
        Found in app/assets/javascripts/jws/Resizeable_Textbox/javascript.js - About 3 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 update has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

          def update
            group_name = white_list(params[:favourite_group_name])
            found = FavouriteGroup.where(:name => group_name, :user_id => current_user.id).first
            
            # if the found group with the same is the current one - that's fine; otherwise - can't rename a group with such new name 
        Severity: Minor
        Found in app/controllers/favourite_groups_controller.rb - About 3 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 included has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.included klass
                klass.class_eval do
                  searchable do
                    text :title do
                      if self.respond_to?(:title)
        Severity: Minor
        Found in lib/seek/search/search_sunspot.rb - About 3 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 4 locations. Consider refactoring.
        Open

                for (var key in targetMap[resource_type]) {
                    if (targetMap[resource_type][key] == true) {
                        var hidden_input = new Element('input',{'id':resource_type+'[]','name': resource_type+'[]','type':'hidden'});
                        hidden_input.value = key;
                        hidden_input.text = key;
        Severity: Major
        Found in app/assets/javascripts/link_adder.js and 3 other locations - About 3 hrs to fix
        app/assets/javascripts/link_adder.js on lines 56..63
        app/assets/javascripts/link_adder.js on lines 84..91
        app/assets/javascripts/link_adder.js on lines 108..115

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

        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 4 locations. Consider refactoring.
        Open

                for (var key in targetMap[resource_type]) {
                    if (targetMap[resource_type][key] == true) {
                        var hidden_input = new Element('input',{'id':resource_type +'[]','name': resource_type +'[]','type':'hidden'});
                        hidden_input.value = key;
                        hidden_input.text = key;
        Severity: Major
        Found in app/assets/javascripts/link_adder.js and 3 other locations - About 3 hrs to fix
        app/assets/javascripts/link_adder.js on lines 33..40
        app/assets/javascripts/link_adder.js on lines 56..63
        app/assets/javascripts/link_adder.js on lines 108..115

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

        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 4 locations. Consider refactoring.
        Open

                    for (var key in targetMap[resource_type]) {
                        if (targetMap[resource_type][key] == true) {
                            var hidden_input = new Element('input',{'id':resource_type+'[]','name': resource_type+'[]','type':'hidden'});
                            hidden_input.value = key;
                            hidden_input.text = key;
        Severity: Major
        Found in app/assets/javascripts/link_adder.js and 3 other locations - About 3 hrs to fix
        app/assets/javascripts/link_adder.js on lines 33..40
        app/assets/javascripts/link_adder.js on lines 84..91
        app/assets/javascripts/link_adder.js on lines 108..115

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

        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 4 locations. Consider refactoring.
        Open

                for (var key in targetMap[resource_type]) {
                    if (targetMap[resource_type][key] == true) {
                        var hidden_input = new Element('input',{'id':resource_type+'[]','name': resource_type+'[]','type':'hidden'});
                        hidden_input.value = key;
                        hidden_input.text = key;
        Severity: Major
        Found in app/assets/javascripts/link_adder.js and 3 other locations - About 3 hrs to fix
        app/assets/javascripts/link_adder.js on lines 33..40
        app/assets/javascripts/link_adder.js on lines 56..63
        app/assets/javascripts/link_adder.js on lines 84..91

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

        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 updateInstitutionIds(){
            var institution_ids_element = $('project_institution_ids');
            var institution_ids = [];
            var checkbox_elements = document.getElementsByClassName('institution_checkbox');
            for(var i = 0; i < checkbox_elements.length ; i++){
        Severity: Major
        Found in app/assets/javascripts/projects.js and 1 other location - About 3 hrs to fix
        app/assets/javascripts/people.js on lines 217..229

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

        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 updateWorkGroupIds(){
            var wg_ids_element = $('person_work_group_ids');
            var wg_ids = [];
            var checkbox_elements = document.getElementsByClassName('work_group_checkbox');
            for(var i = 0; i < checkbox_elements.length ; i++){
        Severity: Major
        Found in app/assets/javascripts/people.js and 1 other location - About 3 hrs to fix
        app/assets/javascripts/projects.js on lines 84..96

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

        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