genome/dgi-db

View on GitHub

Showing 193 of 193 total issues

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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                def update(self):
                    if not self.is_current():
                        self.download_files()
                        self.parse()
                        self.write()
            Severity: Major
            Found in lib/genome/updaters/get_drugbank.py and 1 other location - About 1 hr to fix
            lib/genome/updaters/get_entrez.py on lines 123..127

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 39.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                def update(self):
                    if not self.is_current():
                        self.download_files()
                        self.parse()
                        self.write()
            Severity: Major
            Found in lib/genome/updaters/get_entrez.py and 1 other location - About 1 hr to fix
            lib/genome/updaters/get_drugbank.py on lines 259..263

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 39.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                DataModel::GeneAttribute.where("name LIKE ' %' or name LIKE '% '").all.each do |a|
                                  clean_attribute = DataModel::GeneAttribute.where(name: a.name.strip, value: a.value.strip, gene_id: a.gene_id).first_or_create
                                  a.sources.each do |source|
                                    clean_attribute.sources << source unless clean_attribute.sources.include? source
                                    a.sources.delete(source)
                          Severity: Minor
                          Found in lib/utils/database.rb and 1 other location - About 1 hr to fix
                          lib/utils/database.rb on lines 334..340

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 47.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                DataModel::GeneAttribute.where("value LIKE ' %' or value LIKE '% '").all.each do |a|
                                  clean_attribute = DataModel::GeneAttribute.where(name: a.name.strip, value: a.value.strip, gene_id: a.gene_id).first_or_create
                                  a.sources.each do |source|
                                    clean_attribute.sources << source unless clean_attribute.sources.include? source
                                    a.sources.delete(source)
                          Severity: Minor
                          Found in lib/utils/database.rb and 1 other location - About 1 hr to fix
                          lib/utils/database.rb on lines 326..332

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 47.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language