genome/dgi-db

View on GitHub

Showing 122 of 193 total issues

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

    def self.delete_source(source_db_name)
      source_id = DataModel::Source.where('lower(sources.source_db_name) = ?',
        source_db_name.downcase).pluck(:id).first

      if source_id
Severity: Minor
Found in lib/utils/database.rb - About 1 hr to fix

    Function eatStr has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            eatStr: function (str, side, bite_size, fill) {
                var length = str.length,
                    key = utils.eatStr.generateKey.apply(null, arguments),
                    half_length,
                    half_bite_size;
    Severity: Minor
    Found in app/assets/javascripts/trunk8.js - About 1 hr to fix

      Method import_claims has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def import_claims
            CSV.foreach(file_path, :headers => true, :col_sep => ",") do |row|
              next if row['Highest_status'] == 'Terminated' || row['Highest_status'] == 'Withdrawn from market' || row['Highest_status'].match(/Discontinued/) || row['Highest_status'] == 'Investigative'
      
              gene_name, gene_abbreviation = row['Target_Name'].split(' (', 2)
      Severity: Minor
      Found in lib/genome/importers/ttd/ttd.rb - About 1 hr to fix

        Method each_row has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.each_row(row_delimiter)
                f = File.open(@tsv_path)
                if @tsv_path.to_s.ends_with?('.tsv.gz')
                  f = Zlib::GzipReader(f)
                end
        Severity: Minor
        Found in lib/genome/importers/tsv_importer.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 unpack_locals has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def unpack_locals(params)
            @preset_fda = (params[:approved_drug] == "checked" ? "Approved" : "")
            @preset_neo = (params[:anti_neoplastic] == "checked" ? "Anti-neoplastics" : "")
            @preset_immuno = (params[:immunotherapy] == "checked" ? "Immunotherapies" : "")
            @preset_clin = (params[:clinically_actionable] == "checked" ? "Clinically Actionable" : "")
        Severity: Minor
        Found in app/controllers/interaction_claims_controller.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 print_interaction_claim_row has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.print_interaction_claim_row(file_handle, interaction_claim)
              row = [
                interaction_claim.gene ? interaction_claim.gene.name : "",
                interaction_claim.gene_claim.name,
                interaction_claim.gene ? interaction_claim.gene.entrez_id : "",
        Severity: Minor
        Found in lib/utils/tsv.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 parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse(self):
                self.rows = []
                go_ids = [':'.join((x['go_id'][:2], x['go_id'][2:])) for x in self.dgidb_go_terms]
                category_lookup = {x['go_id']: x['human_readable'].upper() for x in self.dgidb_go_terms}
        
        
        Severity: Minor
        Found in lib/genome/updaters/get_go.py - 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_gene_claims has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_gene_claims
              api_client = ApiClient.new
              categories.each do |category|
                start = 0
                count = 100
        Severity: Minor
        Found in lib/genome/online_updaters/pharos/updater.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 35 lines of code (exceeds 25 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

          Method uniquify_gene_claims has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.uniquify_gene_claims
                DataModel::GeneClaim.find_each do |gc|
                  all_matching_claims = DataModel::GeneClaim.where(name: gc.name, nomenclature: gc.nomenclature, source_id: gc.source_id).all
                  next if all_matching_claims.length == 1
          
          
          Severity: Minor
          Found in lib/utils/uniquify_claims.rb - About 1 hr to fix

            Method sort_value has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.sort_value(sortval)
                case sortval
                  when 'CIViC'
                    1
                  when 'DoCM'
            Severity: Minor
            Found in app/sort_orders/interaction_result_sort_order.rb - About 1 hr to fix

              Method uniquify_drug_claims has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.uniquify_drug_claims
                    DataModel::DrugClaim.find_each do |dc|
                      all_matching_claims = DataModel::DrugClaim.where(name: dc.name, nomenclature: dc.nomenclature, source_id: dc.source_id).all
                      next if all_matching_claims.length == 1
              
              
              Severity: Minor
              Found in lib/utils/uniquify_claims.rb - About 1 hr to fix

                Method initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def initialize
                        @term_to_matches_dict = {}
                        @term_to_record_dict = {}
                        @valid_chembl_ids = []
                        @invalid_chembl_ids = []
                Severity: Minor
                Found in lib/genome/groupers/drug_grouper.rb - About 1 hr to fix

                  Method import_claims has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def import_claims
                        CSV.foreach(file_path, :col_sep => "\t", :headers => true) do |row|
                          drug_claim = create_drug_claim(row['drug_id'].upcase, row['drug_name'], 'DrugBank Drug Identifier')
                  
                          create_drug_claim_alias(drug_claim, row['drug_name'].upcase, 'DrugBank Drug Name')
                  Severity: Minor
                  Found in lib/genome/importers/drug_bank/new_drug_bank.rb - About 1 hr to fix

                    Method match_search_terms_to_objects has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.match_search_terms_to_objects(search_terms, scope, filter)
                        search_terms = search_terms.dup
                        results_to_gene_groups = search_terms.each_with_object({}) { |term, h| h[term] = [] }
                    
                        unfiltered_gene_results = DataModel::Gene.send(scope).where(["genes.name in (?) or entrez_id in (?)", search_terms, search_terms.map {|x| Integer(x) rescue nil }.compact])
                    Severity: Minor
                    Found in app/searches/lookup_genes.rb - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                              elsif val == 'inhibitory immune response' || val == 'car-t-cell-therapy(dual specific)' || val == 'immunomodulator' || val == 'immunomodulator (immunostimulant)' || val == 'immune response agent' || val == 'car-t-cell-therapy' || val == 'immune response agent' || val == 'immunostimulant'
                                'immunotherapy'
                              elsif val == 'component of'
                                'product of'
                              elsif val == 'opener'
                      Severity: Critical
                      Found in lib/genome/normalizers/interaction_claim_type.rb - About 1 hr to fix

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

                            var config = $.cookie = function (key, value, options) {
                        
                                // write
                                if (value !== undefined) {
                                    options = $.extend({}, config.defaults, options);
                        Severity: Minor
                        Found in app/assets/javascripts/jquery.cookie.js - About 1 hr to fix

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

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

                                  def self.add_member(interaction_claim)
                                    drug = interaction_claim.drug_claim.drug
                                    gene = interaction_claim.gene_claim.gene
                                    interaction = DataModel::Interaction.where(drug_id: drug.id, gene_id: gene.id).first_or_create
                                    interaction_claim.interaction = interaction
                            Severity: Minor
                            Found in lib/genome/groupers/interaction_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 validate_interaction_request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def validate_interaction_request(params)
                                if params[:search_mode].nil?
                                  if params[:genes]
                                    params[:search_mode] = 'genes'
                                  elsif params[:drugs]
                            Severity: Minor
                            Found in app/controllers/application_controller.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

                            Severity
                            Category
                            Status
                            Source
                            Language