genome/dgi-db

View on GitHub

Showing 193 of 193 total issues

Avoid too many return statements within this method.
Open

              return nil
Severity: Major
Found in lib/genome/groupers/drug_grouper.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return get_normalized_record_or_drug_for_chembl_id(get_min_chembl_id(chembl_ids_for_records(records_with_highest_max_phase)))
    Severity: Major
    Found in lib/genome/groupers/drug_grouper.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                          return records_with_trade_name.first
      Severity: Major
      Found in lib/genome/groupers/drug_grouper.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                            return get_normalized_record_or_drug_for_chembl_id(get_min_chembl_id(chembl_ids_for_records(records_with_highest_max_phase)))
        Severity: Major
        Found in lib/genome/groupers/drug_grouper.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return nil
          Severity: Major
          Found in lib/genome/groupers/gene_grouper.rb - About 30 mins to fix

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

                          drug :pubchem_name, nomenclature: 'Primary Drug Name', primary_name: :pubchem_name, transform: upcase do
                            name :drug_name, nomenclature: 'Drug Trade Name', unless: blank_filter
                            name :cid, nomenclature: 'PubChem Drug ID', unless: blank_filter
                            names :other_drug_names, nomenclature: 'Other Drug Name', unless: blank_filter
                          end
            lib/genome/importers/tdg_clinical_trial/tdg_clinical_trial_tsv_importer.rb on lines 31..35

            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 32.

            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

                        drug :drug_name, nomenclature: 'Drug Name', primary_name: :drug_name, transform: upcase do
                          attributes :indication, name: 'Drug Indications', unless: blank_filter
                          attribute :drug_class, name: 'Drug Class', unless: blank_filter
                          attribute :fda_approval, name: 'FDA Approval', unless: blank_filter
                        end
            lib/genome/importers/my_cancer_genome_clinical_trial/my_cancer_genome_clinical_trial_tsv_importer.rb on lines 31..35

            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 32.

            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 3 locations. Consider refactoring.
            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'
            Severity: Minor
            Found in lib/genome/normalizers/interaction_claim_type.rb and 2 other locations - About 25 mins to fix
            lib/genome/normalizers/interaction_claim_type.rb on lines 80..81
            lib/genome/normalizers/interaction_claim_type.rb on lines 90..91

            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 31.

            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 3 locations. Consider refactoring.
            Open

                    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'
                      'inhibitor'
            Severity: Minor
            Found in lib/genome/normalizers/interaction_claim_type.rb and 2 other locations - About 25 mins to fix
            lib/genome/normalizers/interaction_claim_type.rb on lines 74..75
            lib/genome/normalizers/interaction_claim_type.rb on lines 90..91

            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 31.

            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 3 locations. Consider refactoring.
            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'
            Severity: Minor
            Found in lib/genome/normalizers/interaction_claim_type.rb and 2 other locations - About 25 mins to fix
            lib/genome/normalizers/interaction_claim_type.rb on lines 74..75
            lib/genome/normalizers/interaction_claim_type.rb on lines 80..81

            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 31.

            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 attribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.attribute(name, type = String, opts = {})
                    unless type == String || type == Array
                      raise 'Sorry, only string and array types are supported'
                    end
            
            
            Severity: Minor
            Found in lib/genome/importers/delimited_row.rb - About 25 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 make_get_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.make_get_request(url)
                retries = 0
                begin
                  uri = URI(url)
                  res = Net::HTTP.get_response(uri)
            Severity: Minor
            Found in lib/utils/pmid.rb - About 25 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 import! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def import!
                      File.open(@tsv_path).each_with_index do |line, index|
                        next if (line.blank? || index == 0)
                        process_row(EntrezGenePathwayRow.new(line))
                        if index % 10_000 == 0
            Severity: Minor
            Found in lib/genome/importers/entrez/entrez_gene_pathway_importer.rb - About 25 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 chembl_ids_for_records has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def chembl_ids_for_records(records)
                    chembl_ids = records.each_with_object([]) do |r, ids|
                      if r['concept_identifier'].start_with?('chembl:') && valid_chembl_id?(r['concept_identifier'])
                        ids << r['concept_identifier']
                      end
            Severity: Minor
            Found in lib/genome/groupers/drug_grouper.rb - About 25 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

            Function create_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def create_request(self):
                    self.request = "https://dgidb.org/api/v1/interactions.json?genes=FLT1&drug_types=antineoplastic&interaction_sources=TALC"
                    self.payload = {}
                    if(self.genes):
                        self.payload['genes'] = self.genes
            Severity: Minor
            Found in files/python_example.py - About 25 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

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

              def gene_id_mapping
                validate_gene_id_mapping_request(params)
                gene_claim = DataModel::GeneClaim.for_gene_id_mapping
                  .where(name: params[:gene_id]).first ||
                  not_found("A gene with the ID #{params[:gene_id]} was not found!")
            Severity: Minor
            Found in app/controllers/services_v1_controller.rb and 1 other location - About 25 mins to fix
            app/controllers/services_v2_controller.rb on lines 103..109

            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 30.

            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

            Function write_log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def write_log(self):
                    self.load_versions()
                    if self.append:
                        today = datetime.date.today().strftime("%d-%B-%Y")
                        if self.version is not None:
            Severity: Minor
            Found in lib/genome/updaters/version_logger.py - About 25 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_gene_claims has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def create_gene_claims
                  CSV.foreach(file_path, :headers => true, :col_sep => "\t") do |row|
                    gene_claim = create_gene_claim(row["Gene"], 'Gene Symbol')
                    create_gene_claim_alias(gene_claim, row["Ensembl"], 'Ensembl Gene ID')
                    unless row['Gene synonym'].nil?
            Severity: Minor
            Found in lib/genome/importers/human_protein_atlas/human_protein_atlas.rb - About 25 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_entity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def create_entity(property_type, val, opts)
                      if !opts[:unless].call(val)
                        if property_type == :alias
                          @importer.send("create_#{@type}_alias", "#{@type}_id".to_sym => @id, alias: val, nomenclature: opts[:nomenclature])
                        elsif property_type == :attribute
            Severity: Minor
            Found in lib/genome/importers/dsl/node.rb - About 25 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 group_gene_claim has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def group_gene_claim(gene_claim)
                    if (gene = DataModel::Gene.where('upper(name) = ? or upper(long_name) = ?', gene_claim.name.upcase, gene_claim.name.upcase)).one?
                      add_gene_claim_to_gene(gene_claim, gene.first)
                      return gene_claim
                    end
            Severity: Minor
            Found in lib/genome/groupers/gene_grouper.rb - About 25 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