SysMO-DB/seek

View on GitHub

Showing 714 of 1,025 total issues

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

        def authorized_associations_for_action?
          result = true
          if self.class.respond_to?(:associations_and_actions_to_be_enforced)
            self.class.associations_and_actions_to_be_enforced.keys.each do |association|
              if self.respond_to?(association)
Severity: Minor
Found in lib/seek/permissions/authorization_enforcement.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 extract_species_and_reaction_names has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_species_and_reaction_names doc
        species = []
        reactions = []
        species_names_node = doc.find_first("//speciesNames")
        species_names_node.children.each do |child|
Severity: Minor
Found in lib/seek/jws/api_handling.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

Function tab_on_click has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function tab_on_click(scale_title, resource_type, resource_ids, actions_partial_disable){
    var click_tab = document.getElementsByClassName(scale_title + '_' + resource_type)[0];
    click_tab.onclick = function(){
        deactivate_previous_tab(this);
        click_tab.parentElement.className = 'tabberactive';
Severity: Minor
Found in app/assets/javascripts/tab_lazy_load.js - About 1 hr to fix

    Method list_item_visibility has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def list_item_visibility item,css_class="visibility_icon"
        title = ""
        html  = ""
        policy = item.policy
    
    
    Severity: Minor
    Found in app/helpers/resource_list_item_helper.rb - About 1 hr to fix

      Method summarize_permissions has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def summarize_permissions creators=[User.current_user.try(:person)], asset_managers = [], contributor=User.current_user.try(:person)
              #build the hash containing contributor_type as key and the people in these groups as value,exception:'Public' holds the access_type as the value
              people_in_group = {'Person' => [], 'FavouriteGroup' => [], 'WorkGroup' => [], 'Project' => [], 'Institution' => [], 'WhiteList' => [], 'BlackList' => [],'Network' => [], 'Public' => 0}
              #the result return: a hash contain the access_type as key, and array of people as value
              grouped_people_by_access_type = {}
      Severity: Minor
      Found in app/models/policy.rb - About 1 hr to fix

        Method matching_data_files has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def matching_data_files params_only=false
            
            results = {}
        
            if Seek::Config.solr_enabled && is_jws_supported?
        Severity: Minor
        Found in app/models/model.rb - About 1 hr to fix

          Method model_scales_list has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def model_scales_list model, list_item
              scales = model.scales
              if scales.empty?
                text_or_not_specified("")
              else
          Severity: Minor
          Found in app/helpers/scales_helper.rb - About 1 hr to fix

            Method create_from_existing has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def create_from_existing
                studied_factor_ids = []
                new_studied_factors = []
                #retrieve the selected FSes
            
            
            Severity: Minor
            Found in app/controllers/studied_factors_controller.rb - About 1 hr to fix

              Method index has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def index
                  if (params[:discipline_id])
                    @discipline=Discipline.find(params[:discipline_id])
                    #FIXME: strips out the disciplines that don't match
                    @people=Person.where(["disciplines.id=?",@discipline.id]).includes(:disciplines)
              Severity: Minor
              Found in app/controllers/people_controller.rb - About 1 hr to fix

                Method builder has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def builder
                    saved_file=params[:saved_file]
                    error=nil
                    supported=false
                    begin
                Severity: Minor
                Found in app/controllers/models_controller.rb - About 1 hr to fix

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

                    def create
                      content = params[:annotation_content].strip
                      if !content.blank?
                        worksheet = @content_blob.worksheets.select {|w| w.sheet_number == params[:annotation_sheet_id].to_i}.first
                  
                  
                  Severity: Minor
                  Found in app/controllers/spreadsheet_annotations_controller.rb - About 1 hr to fix

                    Method handle_download_zip has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def handle_download_zip asset
                            #get the list of filename and filepath, {:filename => filepath}
                            files_to_download = {}
                            #store content_type for the case of 1 file
                            content_type = nil
                    Severity: Minor
                    Found in lib/seek/download_handling/data_download.rb - About 1 hr to fix

                      Method create_from_existing has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def create_from_existing
                          experimental_condition_ids = []
                          new_experimental_conditions = []
                          #retrieve the selected FSes
                          params.each do |key, value|
                      Severity: Minor
                      Found in app/controllers/experimental_conditions_controller.rb - About 1 hr to fix

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

                          Function select_cells has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function select_cells(startCol, startRow, endCol, endRow, sheetNumber) {
                              var minRow = startRow;
                              var minCol = startCol;
                              var maxRow = endRow;
                              var maxCol = endCol;
                          Severity: Minor
                          Found in app/assets/javascripts/spreadsheet_explorer.js - About 1 hr to fix

                            Method authorized_list has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def authorized_list all_items, attribute, sort=true, max_length=75, count_hidden_items=false
                                items = all_items.select &:can_view?
                                if Seek::Config.is_virtualliver
                                  title_only_items = (all_items - items).select &:title_is_public?
                                else
                            Severity: Minor
                            Found in app/helpers/application_helper.rb - About 1 hr to fix

                              Method preview_permissions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def preview_permissions
                                    policy = sharing_params_to_policy
                                    current_person = User.current_user.try(:person)
                                    contributor_person = (params['is_new_file'] == 'false') ?  User.find_by_id(params['contributor_id'].to_i).try(:person) : current_person
                                    creators = (params["creators"].blank? ? [] : ActiveSupport::JSON.decode(params["creators"])).uniq
                              Severity: Minor
                              Found in app/controllers/policies_controller.rb - About 1 hr to fix

                                Method existing_specimens has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def existing_specimens
                                    specimens_of_strains = []
                                    strains = []
                                    specimens_with_default_strain =[]
                                    if params[:strain_ids]
                                Severity: Minor
                                Found in app/controllers/biosamples_controller.rb - About 1 hr to fix

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

                                    def create
                                      if handle_upload_data
                                        @model = Model.new(params[:model])
                                  
                                        @model.policy.set_attributes_with_sharing params[:sharing], @model.projects
                                  Severity: Minor
                                  Found in app/controllers/models_controller.rb - About 1 hr to fix

                                    Method resource_in_tab has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      def resource_in_tab
                                        resource_type = params[:resource_type]
                                        view_type = params[:view_type]
                                        scale_title = params[:scale_title] || ''
                                    
                                    
                                    Severity: Minor
                                    Found in app/controllers/application_controller.rb - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language