SysMO-DB/seek

View on GitHub

Showing 1,025 of 1,025 total issues

Function updateOrganisms has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function updateOrganisms() {
    organism_text='<ul class="related_asset_list">';    

    for (var i=0;i<organisms.length;i++) {
        organism=organisms[i];
Severity: Major
Found in app/assets/javascripts/assays.js - About 2 hrs to fix

    Method submit_to_jws has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def submit_to_jws
        following_action=params.delete("following_action")
        error=nil
    
        #FIXME: currently we have to assume that a model with multiple files only contains 1 model file that would be executed on jws online, and only the first one is chosen
    Severity: Major
    Found in app/controllers/models_controller.rb - About 2 hrs to fix

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

        def delete_model_type params
          id=params[:selected_model_type_id]
          model_type=ModelType.find(id)
          success=false
          if (model_type.models.empty?)
      Severity: Major
      Found in app/controllers/models_controller.rb and 1 other location - About 2 hrs to fix
      app/controllers/models_controller.rb on lines 298..318

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

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

        def delete_model_format params
          id=params[:selected_model_format_id]
          model_format=ModelFormat.find(id)
          success=false
          if (model_format.models.empty?)
      Severity: Major
      Found in app/controllers/models_controller.rb and 1 other location - About 2 hrs to fix
      app/controllers/models_controller.rb on lines 273..293

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

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

      function addSelectedOrganism() {
          selected_option_index=$("possible_organisms").selectedIndex;
          selected_option=$("possible_organisms").options[selected_option_index];
          title=selected_option.text;
          id=selected_option.value;
      Severity: Minor
      Found in app/assets/javascripts/assays.js - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function addAll has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function addAll(resource_type, source) {
      
          if (source == "target") {
              for(var key in allLinks[resource_type]) {
                  $(resource_type +"_" + key + "_target_row").hide();
      Severity: Minor
      Found in app/assets/javascripts/link_adder.js - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method samples_link_list has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def samples_link_list samples
          #FIXME: make more generic and share with other model link list helper methods
          samples=samples.select{|s| !s.nil?} #remove nil items
          return "<span class='none_text'>Not Specified</span>".html_safe if samples.empty?
      
      
      Severity: Minor
      Found in app/helpers/samples_helper.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method get_selected_projects has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_selected_projects project_ids, resource_name
          if (resource_name == 'study') and (!project_ids.blank?)
            investigation = Investigation.find_by_id(project_ids.to_i)
            projects = investigation.nil? ? [] : investigation.projects
      
      
      Severity: Minor
      Found in app/controllers/policies_controller.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method upload_from_email has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def upload_from_email
          if current_user.is_admin? && Seek::Config.admin_impersonation_enabled
            User.with_current_user Person.find(params[:sender_id]).user do
              if handle_upload_data
                @data_file = DataFile.new params[:data_file]
      Severity: Minor
      Found in app/controllers/data_files_controller.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method send_policy_data has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def send_policy_data
          request_type = white_list(params[:policy_type])
          entity_type = white_list(params[:entity_type])
          entity_id = white_list(params[:entity_id])
          
      Severity: Minor
      Found in app/controllers/policies_controller.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          if handle_upload_data
      
            @workflow = Workflow.new params[:workflow]
            @workflow.policy.set_attributes_with_sharing params[:sharing], @workflow.projects
      Severity: Minor
      Found in app/controllers/workflows_controller.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method open_id_authentication has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def open_id_authentication(identity_url)
          # Pass optional :required and :optional keys to specify what sreg fields you want.
          # Be sure to yield registration, a third argument in the #authenticate_with_open_id block.
          authenticate_with_open_id(identity_url,        
              :required => [:email, :fullname,
      Severity: Minor
      Found in app/controllers/users_controller.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method handle_download has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_download disposition='attachment', image_size=nil
            if @content_blob.url.blank?
              if @content_blob.file_exists?
                if image_size && @content_blob.is_image?
                  @content_blob.copy_image
      Severity: Minor
      Found in lib/seek/content_blob_common.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method managers has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def managers
              #FIXME: how to handle projects as contributors - return all people or just specific people (pals or other role)?
              people=[]
              unless self.contributor.nil?
                people << self.contributor.person if self.contributor.kind_of?(User)
      Severity: Minor
      Found in lib/seek/permissions/policy_based_authorization.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method tag_with has a Cognitive Complexity of 16 (exceeds 5 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 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method add_breadcrumbs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_breadcrumbs
            #Home
            add_breadcrumb "Home", :root_path
            #process for nested attributes
            if controller_name == 'studied_factors'
      Severity: Minor
      Found in lib/seek/breadcrumbs.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method duesseldorf_bode_mapping has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def duesseldorf_bode_mapping
      
            concentration_regex = /(\d*,?\.?\d*).*/
            gene_modification_regex = /([\w\d]+)([\/+-]+)/
      
      
      Severity: Minor
      Found in lib/seek/parser_mapper.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method parse_xml_with_extension has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_xml_with_extension(article)
                doi_record = parse_xml_without_extension(article)
                begin
                  #bug fix for empty/missing book title
                  doi_record.journal ||= article.find_first("//book_metadata/titles/title").try(&:content)
      Severity: Minor
      Found in lib/doi_query_tool_extension.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method new_or_update_mapping_links has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def new_or_update_mapping_links compound, compound_annotation
          #create the mappings and mapping_links
           sabiork_id = compound_annotation["sabiork_id"]
           chebi_ids = compound_annotation["chebi_ids"]
           kegg_ids = compound_annotation["kegg_ids"]
      Severity: Minor
      Found in lib/seek/factor_studied.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          respond_to do |format|
            if @model.save
      
              # update attributions
              Relationship.create_or_update_attributions(@model, params[:attributions])
      Severity: Major
      Found in app/controllers/models_controller.rb and 1 other location - About 2 hrs to fix
      app/controllers/presentations_controller.rb on lines 156..186

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

      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