genome/dgi-db

View on GitHub

Showing 122 of 193 total issues

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

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 trust_level_map has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.trust_level_map
      {
        'Expert curated' =>
          [
            'MyCancerGenome',
Severity: Minor
Found in lib/genome/normalizers/source_trust_level.rb - About 1 hr to fix

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

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

            def self.run(tsv_path)
              blank_filter = ->(x) { x.blank? || x == "''" || x == '""' }
              upcase = ->(x) {x.upcase}
              downcase = ->(x) {x.downcase}
              known = ->() {if :action_type.blank?
      Severity: Minor
      Found in lib/genome/importers/chembl/chembl_tsv_importer.rb - About 1 hr to fix

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

            def create_interaction_claims
              api_client = ApiClient.new
              genes = get_genes(api_client)
              drugs = get_drugs(api_client)
              api_client.variants.each do |variant|
        Severity: Minor
        Found in lib/genome/online_updaters/oncokb/updater.rb - About 1 hr to fix

          Method categories has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def categories
                {
                  "KINASE" => "0016301",
                  "TYROSINE KINASE" => "0004713",
                  "SERINE THREONINE KINASE" => "0004674",
          Severity: Minor
          Found in lib/genome/online_updaters/go/updater.rb - About 1 hr to fix

            Method run has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def self.run(tsv_path)
                    na_filter = ->(x) { x.upcase == 'N/A' }
                    TSVImporter.import tsv_path, PharmgkbRow, source_info do
                      interaction known_action_type: 'unknown' do
                        attribute 'Interaction Type', name: 'n/a'
            Severity: Minor
            Found in lib/genome/importers/pharmgkb/pharmgkb_tsv_importer.rb - About 1 hr to fix

              Method process_pubchem_file has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def process_pubchem_file(pubchem_file)
                      alternate_names = []
                      current_id = nil
                      lines_processed = 0
                      Zlib::GzipReader.new(pubchem_file).each_line do |line|
              Severity: Minor
              Found in lib/genome/updaters/get_pubchem.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 add_drug_claim_attributes_to_drug has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_drug_claim_attributes_to_drug(drug_claim, drug)
                      drug_attributes = drug.drug_attributes.pluck(:name, :value)
                                            .map { |drug_attribute| drug_attribute.map(&:upcase) }
                                            .to_set
                      drug_claim.drug_claim_attributes.each do |drug_claim_attribute|
              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 add_member has 27 lines of code (exceeds 25 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

                Method ambiguous_matches has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def ambiguous_matches
                    unless @ambiguous_matches
                      @ambiguous_matches = []
                      results = ambiguous_result_presenters.uniq{|r| r.gene_categories}
                      results.each do |result|
                Severity: Minor
                Found in app/presenters/gene_category_search_results_presenter.rb - About 1 hr to fix

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

                    Method create_interaction_claims has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def create_interaction_claims
                          api_client = ApiClient.new
                          api_client.genes.each do |gene|
                            gene_claim = create_gene_claim(gene['geneName'], 'CKB Gene Name')
                            create_gene_claim_aliases(gene_claim, gene)
                    Severity: Minor
                    Found in lib/genome/online_updaters/ckb/updater.rb - About 1 hr to fix

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

                        Method add_drug_claim_attributes_to_drug has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def add_drug_claim_attributes_to_drug(drug_claim, drug)
                                drug_attributes = drug.drug_attributes.pluck(:name, :value)
                                                      .map { |drug_attribute| drug_attribute.map(&:upcase) }
                                                      .to_set
                                drug_claim.drug_claim_attributes.each do |drug_claim_attribute|
                        Severity: Minor
                        Found in lib/genome/groupers/drug_grouper.rb - About 1 hr to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  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)'
                                    'positive modulator'
                                  elsif val == 'inhibitor, competitive' || val == 'gating inhibitor' || val == 'inhibitor; antagonist; blocker' || val == 'inhibitor (gating inhibitor)' || val == 'growth_inhibition' || val == 'inhibition' || val == 'weak inhibitor' || val == 'aggregation inhibitor' || val == 'inhibition of synthesis' || val == "translocation inhibitor" || val == 'inhibits downstream inflammation cascades' || val == 'inactivator'
                          Severity: Major
                          Found in lib/genome/normalizers/interaction_claim_type.rb - About 1 hr to fix

                            Method partition has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def partition
                                if has_results?
                                  if is_ambiguous? && has_interactions?
                                      :ambiguous
                                  elsif is_ambiguous? && !has_interactions?
                            Severity: Minor
                            Found in app/models/interaction_search_result.rb - About 55 mins 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 sorted_claims has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def sorted_claims
                                drug_claims.sort_by{ |d| [(d.drug_claim_attributes.empty? ? 1 : 0), (DrugClaimPresenter.new(d).publications.empty? ? 1 : 0), (d.drug_claim_aliases.empty? ? 1 : 0), d.sort_value] }
                              end
                            Severity: Minor
                            Found in app/presenters/drug_presenter.rb - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def create_interaction_claims
                                  api_client = ApiClient.new
                                  genes = get_genes(api_client)
                                  drugs = get_drugs(api_client)
                                  api_client.variants.each do |variant|
                            Severity: Minor
                            Found in lib/genome/online_updaters/oncokb/updater.rb - About 55 mins 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 sorted_claims has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def sorted_claims
                                gene_claims.sort_by{ |g| [(g.gene_claim_attributes.empty? ? 1 : 0), (GeneClaimPresenter.new(g).publications.empty? ? 1 : 0), (g.gene_claim_aliases.empty? ? 1 : 0), g.sort_value] }
                              end
                            Severity: Minor
                            Found in app/presenters/gene_presenter.rb - About 55 mins 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