genome/dgi-db

View on GitHub

Showing 193 of 193 total issues

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

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

            go_ids = [':'.join((x['go_id'][:2], x['go_id'][2:])) for x in self.dgidb_go_terms]
    Severity: Major
    Found in lib/genome/updaters/get_go.py and 1 other location - About 1 hr to fix
    lib/genome/updaters/get_go.py on lines 91..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 48.

    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

            go_ids = [':'.join((x['go_id'][:2], x['go_id'][2:])) for x in self.dgidb_go_terms]
    Severity: Major
    Found in lib/genome/updaters/get_go.py and 1 other location - About 1 hr to fix
    lib/genome/updaters/get_go.py on lines 78..78

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

    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 match_objects_to_drugs has a Cognitive Complexity of 14 (exceeds 5 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

    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 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_interaction_claims
          CSV.foreach(file_path, :headers => true, :col_sep => "\t") do |row|
            next if row['Association'] == 'not associated' || row['Association'] == 'ambiguous'
            if row['Entity1_type'] == 'Gene' and row['Entity2_type'] == 'Chemical'
              gene_name = row['Entity1_name']
    Severity: Minor
    Found in lib/genome/importers/pharmgkb/new_pharmgkb.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

    Function fnUpdate has 41 lines of code (exceeds 25 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 1 hr to fix

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

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

          Method uniquify_interaction_claims has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.uniquify_interaction_claims
                DataModel::InteractionClaim.find_each do |ic|
                  all_matching_claims = DataModel::InteractionClaim.where(drug_claim_id: ic.drug_claim_id, gene_claim_id: ic.gene_claim_id, source_id: ic.source_id).all
                  next if all_matching_claims.length == 1
          
          
          Severity: Minor
          Found in lib/utils/uniquify_claims.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 query_drug_claim_aliases has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def query_drug_claim_aliases(drug_claim_aliases)
                  record = nil
                  drug_claim_aliases.each do |a|
                    normalized_record = find_normalized_record_for_term(a.alias)
                    unless normalized_record.nil?
          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 original_data_source_url has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def original_data_source_url
                base_url = self.source.base_url
                name = self.name
                case self.source.source_db_name
                  when 'DrugBank'
          Severity: Minor
          Found in app/models/data_model/gene_claim.rb - About 1 hr to fix

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

                    c.interaction_claims.each do |interaction|
                      clean_interaction = DataModel::InteractionClaim.where(drug_claim_id: interaction.drug_claim_id, gene_claim_id: clean_claim.id, source_id: interaction.source_id).first_or_create
                      interaction.interaction_claim_attributes.each do |attribute|
                        DataModel::InteractionClaimAttribute.where(name: attribute.name, value: attribute.value, interaction_claim_id: clean_interaction.id).first_or_create
                        attribute.delete
            Severity: Major
            Found in lib/utils/database.rb and 1 other location - About 1 hr to fix
            lib/utils/database.rb on lines 414..424

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

            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

                    c.interaction_claims.each do |interaction|
                      clean_interaction = DataModel::InteractionClaim.where(gene_claim_id: interaction.gene_claim_id, drug_claim_id: clean_claim.id, source_id: interaction.source_id).first_or_create
                      interaction.interaction_claim_attributes.each do |attribute|
                        DataModel::InteractionClaimAttribute.where(name: attribute.name, value: attribute.value, interaction_claim_id: clean_interaction.id).first_or_create
                        attribute.delete
            Severity: Major
            Found in lib/utils/database.rb and 1 other location - About 1 hr to fix
            lib/utils/database.rb on lines 353..363

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

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

                  def process_drug(current_id, alternate_names)
                    if alternate_names.any? { |name| existing_drugs[name.upcase.strip] }
                      pubchem_primary_name = alternate_names.first.upcase.strip
                      drug_claim = DataModel::DrugClaim.create(
                        {
            Severity: Minor
            Found in lib/genome/updaters/get_pubchem.rb - About 1 hr to fix

              Method delete_source has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.delete_source(source_db_name)
                    source_id = DataModel::Source.where('lower(sources.source_db_name) = ?',
                      source_db_name.downcase).pluck(:id).first
              
                    if source_id
              Severity: Minor
              Found in lib/utils/database.rb - About 1 hr to fix

                Function eatStr has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        eatStr: function (str, side, bite_size, fill) {
                            var length = str.length,
                                key = utils.eatStr.generateKey.apply(null, arguments),
                                half_length,
                                half_bite_size;
                Severity: Minor
                Found in app/assets/javascripts/trunk8.js - About 1 hr to fix

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

                    Method each_row has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def self.each_row(row_delimiter)
                            f = File.open(@tsv_path)
                            if @tsv_path.to_s.ends_with?('.tsv.gz')
                              f = Zlib::GzipReader(f)
                            end
                    Severity: Minor
                    Found in lib/genome/importers/tsv_importer.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 unpack_locals has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def unpack_locals(params)
                        @preset_fda = (params[:approved_drug] == "checked" ? "Approved" : "")
                        @preset_neo = (params[:anti_neoplastic] == "checked" ? "Anti-neoplastics" : "")
                        @preset_immuno = (params[:immunotherapy] == "checked" ? "Immunotherapies" : "")
                        @preset_clin = (params[:clinically_actionable] == "checked" ? "Clinically Actionable" : "")
                    Severity: Minor
                    Found in app/controllers/interaction_claims_controller.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 print_interaction_claim_row has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def self.print_interaction_claim_row(file_handle, interaction_claim)
                          row = [
                            interaction_claim.gene ? interaction_claim.gene.name : "",
                            interaction_claim.gene_claim.name,
                            interaction_claim.gene ? interaction_claim.gene.entrez_id : "",
                    Severity: Minor
                    Found in lib/utils/tsv.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