genome/dgi-db

View on GitHub

Showing 193 of 193 total issues

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

            drug_claim = create_drug_claim(individual_drug_name, individual_drug_name, 'CGI Drug Name')
            if row['Gene'].include?(';')
              row['Gene'].split(';').each do |indv_gene|
                gene_claim = create_gene_claim(indv_gene, 'CGI Gene Name')
                interaction_claim = create_interaction_claim(gene_claim, drug_claim)
Severity: Major
Found in lib/genome/importers/cgi/new_cgi.rb and 1 other location - About 2 hrs to fix
lib/genome/importers/cgi/new_cgi.rb on lines 50..72

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

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

            drug_claim = create_drug_claim(individual_drug_name, individual_drug_name, 'CGI Drug Name')
            if row['Gene'].include?(';')
              row['Gene'].split(';').each do |indv_gene|
                gene_claim = create_gene_claim(indv_gene, 'CGI Gene Name')
                interaction_claim = create_interaction_claim(gene_claim, drug_claim)
Severity: Major
Found in lib/genome/importers/cgi/new_cgi.rb and 1 other location - About 2 hrs to fix
lib/genome/importers/cgi/new_cgi.rb on lines 78..100

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

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

    def write(self):
        print('Writing to .tsv...')
        i = 0
        no_ensembl = no_entrez = total = 0
        header = ('count', 'drug_id', 'drug_name', 'drug_synonyms', 'drug_cas_number', 'drug_brands',
Severity: Minor
Found in lib/genome/updaters/get_drugbank.py - 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

Method to_tsv has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def to_tsv
        # entrez = Genome::Updaters::GetEntrez.new
        # f = open(entrez.local_path('gene_info.gz'))
        check_files
        f = File.open(local_path('gene_info.gz'))
Severity: Minor
Found in lib/genome/updaters/get_entrez.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

Consider simplifying this complex logical expression.
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'
        elsif val == 'channel blocker' || val == 'blocker (channel blocker)' || val == 'nucleotide exchange blocker'
          'blocker'
        elsif val == 'antisense' || val == 'sirna drug'
Severity: Critical
Found in lib/genome/normalizers/interaction_claim_type.rb - About 2 hrs to fix

    Method create_interaction_claims has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_interaction_claims
        CSV.foreach(file_path, :headers => true) do |row|
          drug_id = row['compound_id']
          drug_name = row['compound_name']
          gene_name = row['gene_names']
    Severity: Minor
    Found in lib/genome/importers/dtc/dtc.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

    Method run has 64 lines of code (exceeds 25 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: Major
    Found in lib/genome/groupers/drug_grouper.rb - About 2 hrs to fix

      Method import_claims has 59 lines of code (exceeds 25 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: Major
      Found in lib/genome/importers/guide_to_pharmacology/guide_to_pharmacology.rb - About 2 hrs to fix

        Class GeneCategorySearchResultsPresenter has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class GeneCategorySearchResultsPresenter
          include Genome::Extensions
          attr_reader :search_results
        
          def initialize(search_results, params, start_time, view_context)
        Severity: Minor
        Found in app/presenters/gene_category_search_results_presenter.rb - About 2 hrs to fix

          Function fnUpdate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                  "fnUpdate": function ( oSettings, fnDraw ) {
                      var iListLength = 5;
                      var oPaging = oSettings.oInstance.fnPagingInfo();
                      var an = oSettings.aanFeatures.p;
                      var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
          Severity: Minor
          Found in app/assets/javascripts/pagination_bootstrap.js - 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

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

          Function parse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse(self):
                  self.rows = []
                  with open(os.path.join(self.download_path, 'gene_info.human')) as f:
                      fieldnames = ['tax_id', 'entrez_id', 'entrez_gene_symbol', 'locus_tag',
                                   'entrez_gene_synonyms', 'dbXrefs', 'chromosome', 'map_loc',
          Severity: Minor
          Found in lib/genome/updaters/get_entrez.py - 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

          File get_drugbank.py has 257 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          __author__ = 'Kelsy C Cotto'
          
          import zipfile
          import os
          import sys
          Severity: Minor
          Found in lib/genome/updaters/get_drugbank.py - About 2 hrs to fix

            Class InteractionSearchResultApiV1Presenter has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class InteractionSearchResultApiV1Presenter
              def initialize(search_result, identifier, interactions)
                @result = search_result
                @identifier = identifier
                @interactions = interactions.flat_map(&:interaction_claims).map{|i| InteractionWrapper.new(i)}
            Severity: Minor
            Found in app/presenters/interaction_search_result_api_v1_presenter.rb - About 2 hrs to fix

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

              class UpdateCgi < TsvUpdater
                def tempfile_name
                  ['cgi_biomarkers_per_variant', '.tsv']
                end
              
              
              Severity: Major
              Found in app/jobs/update_cgi.rb and 1 other location - About 2 hrs to fix
              app/jobs/update_pharmgkb.rb on lines 7..41

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

              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

              class UpdatePharmgkb < TsvUpdater
                def tempfile_name
                  ['pharmgkb_interactions', '.tsv']
                end
              
              
              Severity: Major
              Found in app/jobs/update_pharmgkb.rb and 1 other location - About 2 hrs to fix
              app/jobs/update_cgi.rb on lines 7..41

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

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

                    def dgidb_go_terms
                      @dgidb_go_terms ||= [{short_name: "Kinase", full_go_name: "KinaseActivity",
                                         human_readable: "Kinase", go_id: "GO0016301"},
                                        {short_name: "TyrosineKinase", full_go_name: "ProteinTyrosineKinaseActivity",
                                         human_readable: "Tyrosine Kinase", go_id: "GO0004713"},
              Severity: Major
              Found in lib/genome/updaters/get_go.rb - About 2 hrs to fix

                Consider simplifying this complex logical expression.
                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'
                        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)'
                Severity: Critical
                Found in lib/genome/normalizers/interaction_claim_type.rb - About 2 hrs to fix

                  Function truncate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function truncate() {
                          var data = this.data('trunk8'),
                              settings = data.settings,
                              width = settings.width,
                              side = settings.side,
                  Severity: Minor
                  Found in app/assets/javascripts/trunk8.js - About 1 hr to fix

                    Method get_normalized_record_for_chembl_match has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def get_normalized_record_for_chembl_match(chembl_match)
                            records = chembl_match['records']
                            if records.size == 1
                              return get_normalized_record_or_drug_for_chembl_id(records.first['concept_identifier'])
                            else
                    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

                    Severity
                    Category
                    Status
                    Source
                    Language