genome/dgi-db

View on GitHub

Showing 193 of 193 total issues

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

$(function() {
    var categories = [];
    var names = [];
    var tabs = [];
    
Severity: Major
Found in app/assets/javascripts/gene-list-tabs.js and 1 other location - About 3 days to fix
app/assets/javascripts/source-list-tabs.js on lines 1..58

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

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

$(function() {
    var categories = [];
    var names = [];
    var tabs = [];
    
Severity: Major
Found in app/assets/javascripts/source-list-tabs.js and 1 other location - About 3 days to fix
app/assets/javascripts/gene-list-tabs.js on lines 1..58

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

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

    def parse(self):
        print('Parsing Entrez...')
        symbol_to_info = dict()
        hgnc_id_to_info = dict()
        entrez_to_info = dict()
Severity: Minor
Found in lib/genome/updaters/get_drugbank.py - About 2 days 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 59 (exceeds 5 allowed). Consider refactoring.
Open

    def create_interaction_claims
      CSV.foreach(file_path, :headers => true, :col_sep => "\t") do |row|
        next if row['Drug'].nil? || row['Drug'] == '[]'
        if row['Drug'].include?(',') || row['Drug'].include?(';')
          combination_drug_name = row['Drug']
Severity: Minor
Found in lib/genome/importers/cgi/new_cgi.rb - About 1 day 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 run has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

      def run(source_id: nil)
        claims = DataModel::DrugClaim.eager_load(:drug_claim_aliases, :drug_claim_attributes).where(drug_id: nil)
        unless source_id.nil?
          claims = claims.where(source_id: source_id)
        end
Severity: Minor
Found in lib/genome/groupers/drug_grouper.rb - About 1 day 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_claims has a Cognitive Complexity of 46 (exceeds 5 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 7 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 cleanup_whitespaces has 146 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.cleanup_whitespaces
      DataModel::InteractionClaimType.where("type LIKE ' %' or type LIKE '% '").all.each do |t|
        t.value = t.value.strip
        t.save!
      end
Severity: Major
Found in lib/utils/database.rb - About 5 hrs to fix

    Method import_claims has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        def import_claims
          CSV.foreach(gene_file_path, :headers => true) do |line|
            gene_name = line['Human Entrez Gene']
            next if blank?(gene_name)
    
    
    Severity: Minor
    Found in lib/genome/importers/guide_to_pharmacology/guide_to_pharmacology.rb - About 5 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 database.rb has 380 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Utils
      module Database
    
        def self.delete_genes
          sql = <<-SQL
    Severity: Minor
    Found in lib/utils/database.rb - About 5 hrs to fix

      Method cleanup_whitespaces has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.cleanup_whitespaces
            DataModel::InteractionClaimType.where("type LIKE ' %' or type LIKE '% '").all.each do |t|
              t.value = t.value.strip
              t.save!
            end
      Severity: Minor
      Found in lib/utils/database.rb - About 5 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 import_claims has a Cognitive Complexity of 32 (exceeds 5 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 4 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 drug_grouper.rb has 364 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'net/https'
      
      module Genome
        module Groupers
          class DrugGrouper
      Severity: Minor
      Found in lib/genome/groupers/drug_grouper.rb - About 4 hrs to fix

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

            def download_file(self, url, local_filename):
                # NOTE the stream=True parameter
                r = requests.get(url, stream=True, allow_redirects=True, auth=HTTPBasicAuth(self.username, self.password))
                with open(local_filename, 'wb') as f:
                    for chunk in r.iter_content(chunk_size=1024):
        Severity: Major
        Found in lib/genome/updaters/get_entrez.py and 1 other location - About 4 hrs to fix
        lib/genome/updaters/get_drugbank.py on lines 47..53

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

        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 download_file(self, url, local_filename):
                # NOTE the stream=True parameter
                r = requests.get(url, stream=True, allow_redirects=True, auth=HTTPBasicAuth(self.username, self.password))
                with open(local_filename, 'wb') as f:
                    for chunk in r.iter_content(chunk_size=1024):
        Severity: Major
        Found in lib/genome/updaters/get_drugbank.py and 1 other location - About 4 hrs to fix
        lib/genome/updaters/get_entrez.py on lines 37..43

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

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

            def self.destroy_na
              sql = <<-SQL
                delete from drug_claim_types_drug_claims d
                where
                d.drug_claim_id in
        Severity: Major
        Found in lib/utils/database.rb - About 4 hrs to fix

          Method create_interaction_claims has 85 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['Drug'].nil? || row['Drug'] == '[]'
                  if row['Drug'].include?(',') || row['Drug'].include?(';')
                    combination_drug_name = row['Drug']
          Severity: Major
          Found in lib/genome/importers/cgi/new_cgi.rb - About 3 hrs to fix

            Similar blocks of code found in 2 locations. 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: Major
            Found in lib/utils/uniquify_claims.rb and 1 other location - About 3 hrs to fix
            lib/utils/uniquify_claims.rb on lines 12..45

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

            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

                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: Major
            Found in lib/utils/uniquify_claims.rb and 1 other location - About 3 hrs to fix
            lib/utils/uniquify_claims.rb on lines 50..83

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

            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 get_normalized_record_for_multi_matches has a Cognitive Complexity of 22 (exceeds 5 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 3 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 name_normalizer has a Cognitive Complexity of 21 (exceeds 5 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 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

            Severity
            Category
            Status
            Source
            Language