SysMO-DB/seek

View on GitHub

Showing 714 of 1,025 total issues

Function validateResourceFields has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function validateResourceFields(is_new_file, resource_name, is_managed) {
    // check if sharing rights are defined
    if (!($(document.getElementById('sharing_scope_0')).checked) &&
        !($(document.getElementById('sharing_scope_2')).checked) &&
        !($(document.getElementById('sharing_scope_4')).checked))
Severity: Minor
Found in app/assets/javascripts/resource.js - About 1 hr to fix

    Method cytoscape_node_elements has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def cytoscape_node_elements nodes
        cytoscape_node_elements = []
        nodes.each do |node|
          item_type, item_id = node.split('_')
          item = item_type.constantize.find_by_id(item_id)
    Severity: Minor
    Found in app/helpers/i_s_a_helper.rb - About 1 hr to fix

      Method list_samples_and_assay_organisms has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def list_samples_and_assay_organisms attribute, assay_samples, assay_organisms, html_options={}, none_text="Not Specified"
      
          result= "<p class='#{html_options[:class]}' id='#{html_options[:id]}'> <b>#{attribute}</b>: "
      
          result +="<span class='none_text'>#{none_text}</span>" if assay_samples.blank? and assay_organisms.blank?
      Severity: Minor
      Found in app/helpers/assays_helper.rb - About 1 hr to fix

        Method update has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def update
            data_file_ids = (params[:sample_data_file_ids].nil? ? [] : params[:sample_data_file_ids].reject(&:blank?)) || []
            model_ids = (params[:sample_model_ids].nil? ? [] : params[:sample_model_ids].reject(&:blank?)) || []
            sop_ids = (params[:sample_sop_ids].nil? ? [] : params[:sample_sop_ids].reject(&:blank?)) || []
            @sample.attributes = params[:sample]
        Severity: Minor
        Found in app/controllers/samples_controller.rb - About 1 hr to fix

          Method paginate_after_fetch has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def paginate_after_fetch(collection, *args)
                options=args.pop unless args.nil?
                options ||= {}
                reorder = options[:reorder].nil? ? true : options[:reorder]
          
          
          Severity: Minor
          Found in lib/grouped_pagination.rb - About 1 hr to fix

            Function onTouchEnd has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    var onTouchEnd = function(e){
                        slider.viewport.unbind('touchmove', onTouchMove);
                        var orig = e.originalEvent;
                        var value = 0;
                        // record end x, y positions
            Severity: Minor
            Found in app/assets/javascripts/jquery.bxslider.js - About 1 hr to fix

              Function updateEvents has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function updateEvents() {
                  event_text = '<ul class="related_asset_list">'
                  for (var i = 0; i < events_array.length; i++) {
                      var event = events_array[i];
                      var title = event[0];
              Severity: Minor
              Found in app/assets/javascripts/associate_events.js - About 1 hr to fix

                Function getViewportHeight has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        var getViewportHeight = function(){
                            var height = 0;
                            // first determine which children (slides) should be used in our height calculation
                            var children = $();
                            // if mode is not "vertical" and adaptiveHeight is false, include all children
                Severity: Minor
                Found in app/assets/javascripts/jquery.bxslider.js - About 1 hr to fix

                  Method set_attributes_with_sharing has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def set_attributes_with_sharing sharing, projects
                      # if no data about sharing is given, it should be some user (not the owner!)
                      # who is editing the asset - no need to do anything with policy / permissions: return success
                      self.tap do |policy|
                        if sharing
                  Severity: Minor
                  Found in app/models/policy.rb - About 1 hr to fix

                    Method set_parameters_for_sharing_form has 32 lines of code (exceeds 25 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

                      Method new_object_based_on_existing_one has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def new_object_based_on_existing_one
                          @existing_assay =  Assay.find(params[:id])
                          @assay = @existing_assay.clone_with_associations
                          params[:data_file_ids]=@existing_assay.data_file_masters.collect{|d|"#{d.id},None"}
                          params[:related_publication_ids]= @existing_assay.related_publications.collect{|p| "#{p.id},None"}
                      Severity: Minor
                      Found in app/controllers/assays_controller.rb - About 1 hr to fix

                        Method update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def update
                            if params[:workflow]
                              [:contributor_id, :contributor_type, :original_filename, :content_type, :content_blob_id, :created_at, :updated_at, :last_used_at].each do |column_name|
                                params[:workflow].delete(column_name)
                              end
                        Severity: Minor
                        Found in app/controllers/workflows_controller.rb - About 1 hr to fix

                          Method create has 32 lines of code (exceeds 25 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 1 hr to fix

                            Method create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                               def create
                                  compound = params[:compound]
                                  compound_name =  compound[:title]
                            
                                    unless compound_name.blank?
                            Severity: Minor
                            Found in app/controllers/compounds_controller.rb - About 1 hr to fix

                              Method generate_triples has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                    def generate_triples subject, method, property,uri_or_literal,transformation,collection_transform,rdf_graph
                                      resource = subject.rdf_resource
                                      transform = transformation.strip unless transformation.nil?
                                      collection_transform = collection_transform.strip unless collection_transform.nil?
                                      items = subject.send(method)
                              Severity: Minor
                              Found in lib/seek/rdf/rdf_generation.rb - About 1 hr to fix

                                Method add has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def add
                                    if request.post?
                                      if params[:id]=="drag_search" #needs to create the SavedSearch resource first
                                        saved_search = SavedSearch.new(:user_id => current_user.id, :search_query => params[:search_query], :search_type => params[:search_type],:include_external_search=>params[:include_external_search]=="1")
                                        if SavedSearch.find_by_user_id_and_search_query_and_search_type_and_include_external_search(current_user,params[:search_query],params[:search_type],params[:include_external_search]=="1").nil? && saved_search.save
                                Severity: Minor
                                Found in app/controllers/favourites_controller.rb - About 1 hr to fix

                                  Method paginate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      def paginate(*args)
                                        options=args.pop unless args.nil?
                                        options ||= {}                
                                  
                                        default_page = options[:default_page] || @default_page
                                  Severity: Minor
                                  Found in lib/grouped_pagination.rb - About 1 hr to fix

                                    Method populate_db has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        def populate_db data
                                    
                                          assay = nil
                                          assay_json = data["assay"]
                                    
                                    
                                    Severity: Minor
                                    Found in lib/seek/data/bio_samples.rb - About 1 hr to fix

                                      Method extract_as_table has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                            def extract_as_table treatments_heading_row, sample_col, treatments_first_col,treatments_last_col,sheet
                                              table = []
                                              sheet_name = sheet.attributes["name"]
                                              cells = sheet.find("//ss:sheet[@name='#{sheet_name}']/ss:rows/ss:row/ss:cell[@row >= '#{(treatments_heading_row).to_s}' and (@column = '#{sample_col.to_s}' or (@column>='#{treatments_first_col.to_s}' and @column<='#{treatments_last_col.to_s}'))]")
                                      
                                      
                                      Severity: Minor
                                      Found in lib/seek/data/treatments.rb - About 1 hr to fix

                                        Function updateAssays has a Cognitive Complexity of 11 (exceeds 5 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

                                        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