genome/dgi-db

View on GitHub

Showing 122 of 193 total issues

Class GeneCategorySearchResultsPresenter has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class GeneCategorySearchResultsPresenter
  include Genome::Extensions
  attr_reader :search_results

  def initialize(search_results, params, start_time, view_context)
Severity: Minor
Found in app/presenters/gene_category_search_results_presenter.rb - About 2 hrs to fix

    Function fnUpdate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

            "fnUpdate": function ( oSettings, fnDraw ) {
                var iListLength = 5;
                var oPaging = oSettings.oInstance.fnPagingInfo();
                var an = oSettings.aanFeatures.p;
                var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
    Severity: Minor
    Found in app/assets/javascripts/pagination_bootstrap.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 interaction_search_results has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def interaction_search_results
        if !params[:name].nil?
          params[:search_mode] = 'drugs'
          params[:identifiers] = params[:name]
          params[:gene_categories] = DataModel::GeneClaimCategory.all_category_names unless params[:gene_categories]
    Severity: Minor
    Found in app/controllers/interaction_claims_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

    Function parse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse(self):
            self.rows = []
            with open(os.path.join(self.download_path, 'gene_info.human')) as f:
                fieldnames = ['tax_id', 'entrez_id', 'entrez_gene_symbol', 'locus_tag',
                             'entrez_gene_synonyms', 'dbXrefs', 'chromosome', 'map_loc',
    Severity: Minor
    Found in lib/genome/updaters/get_entrez.py - 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

    File get_drugbank.py has 257 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    __author__ = 'Kelsy C Cotto'
    
    import zipfile
    import os
    import sys
    Severity: Minor
    Found in lib/genome/updaters/get_drugbank.py - About 2 hrs to fix

      Class InteractionSearchResultApiV1Presenter has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class InteractionSearchResultApiV1Presenter
        def initialize(search_result, identifier, interactions)
          @result = search_result
          @identifier = identifier
          @interactions = interactions.flat_map(&:interaction_claims).map{|i| InteractionWrapper.new(i)}
      Severity: Minor
      Found in app/presenters/interaction_search_result_api_v1_presenter.rb - About 2 hrs to fix

        Method dgidb_go_terms has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def dgidb_go_terms
                @dgidb_go_terms ||= [{short_name: "Kinase", full_go_name: "KinaseActivity",
                                   human_readable: "Kinase", go_id: "GO0016301"},
                                  {short_name: "TyrosineKinase", full_go_name: "ProteinTyrosineKinaseActivity",
                                   human_readable: "Tyrosine Kinase", go_id: "GO0004713"},
        Severity: Major
        Found in lib/genome/updaters/get_go.rb - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                  elsif val =~ /other/ || val =~ /unknown/ || val == 'protector' || val == 'oxidizer' || val == 'coating agent' || val == 'dilator' || val == 'deoxidizer' || val == 'diffusing substance'|| val == 'vesicant' || val == 'gene replacement'
                    'other/unknown'
                  elsif val == 'neutralizer' || val == 'reducer' || val == 'metabolizer' || val == 'acetylation' || val == 'chelator' || val == 'cross-linking/alkylation' || val == 'regulator'
                    'modulator'
                  elsif val == 'positive allosteric modulator' || val == 'regulator (upregulator)' || val == 'enhancer' || val == 'modulator (allosteric modulator)'
          Severity: Critical
          Found in lib/genome/normalizers/interaction_claim_type.rb - About 2 hrs to fix

            Function truncate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function truncate() {
                    var data = this.data('trunk8'),
                        settings = data.settings,
                        width = settings.width,
                        side = settings.side,
            Severity: Minor
            Found in app/assets/javascripts/trunk8.js - About 1 hr to fix

              Method get_normalized_record_for_chembl_match has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                    def get_normalized_record_for_chembl_match(chembl_match)
                      records = chembl_match['records']
                      if records.size == 1
                        return get_normalized_record_or_drug_for_chembl_id(records.first['concept_identifier'])
                      else
              Severity: Minor
              Found in lib/genome/groupers/drug_grouper.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 get_normalized_record_for_multi_matches has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def get_normalized_record_for_multi_matches(matches)
                      #2. a.
                      matches_with_chembl_id = matches.select{|t, m| chembl_ids_for_records(m['records']).size > 0}
                      if matches_with_chembl_id.size == 0
                        matches_with_chembl_id = matches
              Severity: Minor
              Found in lib/genome/groupers/drug_grouper.rb - About 1 hr to fix

                Method match_objects_to_drugs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.match_objects_to_drugs(unfiltered_results, filtered_results, search_terms)
                    results_to_drug_groups = search_terms.each_with_object({}) { |term, h| h[term] = [] }
                    ids_to_results = filtered_results.each_with_object({}) { |result, h| h[result.id] = result}
                    unfiltered_results.each do |unfiltered_result|
                      result = ids_to_results[unfiltered_result.id]
                Severity: Minor
                Found in app/searches/lookup_drugs.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 create_interaction_claims has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def create_interaction_claims
                      CSV.foreach(file_path, :headers => true, :col_sep => "\t") do |row|
                        next if row['Association'] == 'not associated' || row['Association'] == 'ambiguous'
                        if row['Entity1_type'] == 'Gene' and row['Entity2_type'] == 'Chemical'
                          gene_name = row['Entity1_name']
                Severity: Minor
                Found in lib/genome/importers/pharmgkb/new_pharmgkb.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 fnUpdate has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        "fnUpdate": function ( oSettings, fnDraw ) {
                            var iListLength = 5;
                            var oPaging = oSettings.oInstance.fnPagingInfo();
                            var an = oSettings.aanFeatures.p;
                            var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
                Severity: Minor
                Found in app/assets/javascripts/pagination_bootstrap.js - About 1 hr to fix

                  Method to_tsv has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def to_tsv
                          # entrez = Genome::Updaters::GetEntrez.new
                          # f = open(entrez.local_path('gene_info.gz'))
                          check_files
                          f = File.open(local_path('gene_info.gz'))
                  Severity: Minor
                  Found in lib/genome/updaters/get_entrez.rb - About 1 hr to fix

                    Method name_normalizer has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def self.name_normalizer(val)
                            val = val.downcase.strip
                            if val == 'na' || val == 'n/a'
                              'n/a'
                            elsif val =~ /other/ || val =~ /unknown/ || val == 'protector' || val == 'oxidizer' || val == 'coating agent' || val == 'dilator' || val == 'deoxidizer' || val == 'diffusing substance'|| val == 'vesicant' || val == 'gene replacement'
                    Severity: Minor
                    Found in lib/genome/normalizers/interaction_claim_type.rb - About 1 hr to fix

                      Method uniquify_interaction_claims has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def self.uniquify_interaction_claims
                            DataModel::InteractionClaim.find_each do |ic|
                              all_matching_claims = DataModel::InteractionClaim.where(drug_claim_id: ic.drug_claim_id, gene_claim_id: ic.gene_claim_id, source_id: ic.source_id).all
                              next if all_matching_claims.length == 1
                      
                      
                      Severity: Minor
                      Found in lib/utils/uniquify_claims.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 query_drug_claim_aliases has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def query_drug_claim_aliases(drug_claim_aliases)
                              record = nil
                              drug_claim_aliases.each do |a|
                                normalized_record = find_normalized_record_for_term(a.alias)
                                unless normalized_record.nil?
                      Severity: Minor
                      Found in lib/genome/groupers/drug_grouper.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 original_data_source_url has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def original_data_source_url
                            base_url = self.source.base_url
                            name = self.name
                            case self.source.source_db_name
                              when 'DrugBank'
                      Severity: Minor
                      Found in app/models/data_model/gene_claim.rb - About 1 hr to fix

                        Method process_drug has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def process_drug(current_id, alternate_names)
                                if alternate_names.any? { |name| existing_drugs[name.upcase.strip] }
                                  pubchem_primary_name = alternate_names.first.upcase.strip
                                  drug_claim = DataModel::DrugClaim.create(
                                    {
                        Severity: Minor
                        Found in lib/genome/updaters/get_pubchem.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language