genome/dgi-db

View on GitHub

Showing 122 of 193 total issues

Avoid deeply nested control flow statements.
Open

                        if isinstance(datum, tuple):
                            datum = ';'.join(str(x) for x in datum)
                        datum = str(datum).replace("\t", '')
Severity: Major
Found in lib/genome/updaters/get_drugbank.py - About 45 mins to fix

    Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def initialize(collection, request, item_presenter_type, pagination_presenter_type, additional_meta = {}, page_state_param_names = [])
    Severity: Minor
    Found in app/presenters/paginated_collection_presenter.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if species == '9606':  # Grab human only
                                  wf.write(line_ascii)
      
      
      Severity: Major
      Found in lib/genome/updaters/get_entrez.py - About 45 mins to fix

        Method import has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def self.import(tsv_path, rowtype, source_info, header = true, row_delimiter = "\t",  &block)
        Severity: Minor
        Found in lib/genome/importers/tsv_importer.rb - About 45 mins to fix

          Method uniquify_gene_claims has a Cognitive Complexity of 8 (exceeds 5 allowed). 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: Minor
          Found in lib/utils/uniquify_claims.rb - About 45 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 uniquify_drug_claims has a Cognitive Complexity of 8 (exceeds 5 allowed). 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: Minor
          Found in lib/utils/uniquify_claims.rb - About 45 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_claim_aliases has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_gene_claim_aliases (gene_claim, line)
                create_gene_claim_alias(gene_claim, line['target'], 'GuideToPharmacology Name') unless blank?(line['target'])
                unless blank?(line['target_ensembl_gene_id'])
                  line['target_ensembl_gene_id'].split('|').each do |ensembl_id|
                    create_gene_claim_alias(gene_claim, ensembl_id, 'Ensembl ID')
          Severity: Minor
          Found in lib/genome/importers/guide_to_pharmacology/guide_to_pharmacology.rb - About 45 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

          Avoid deeply nested control flow statements.
          Open

                            if records_with_trade_name.size == 1
                              return records_with_trade_name.first
                            elsif records_with_trade_name.size == 0
                              return get_normalized_record_or_drug_for_chembl_id(get_min_chembl_id(chembl_ids_for_records(records_with_highest_max_phase)))
                            else
          Severity: Major
          Found in lib/genome/groupers/drug_grouper.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if identifier.find('entry:resource',ns).text == 'HUGO Gene Nomenclature Committee (HGNC)':
                                        hgnc_gene_acc = identifier.find('entry:identifier', ns).text
                                        # Some identifiers are incorrectly labeled by DrugBank
                                        r = re.compile(r'^\d+$')
                                        if hgnc_gene_acc.startswith('GNC:'):
            Severity: Major
            Found in lib/genome/updaters/get_drugbank.py - About 45 mins to fix

              Method parse_interaction_information has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_interaction_information(variant)
                    return [] unless variant.include?('meta')
                    drug_data = variant['meta'].find { |table| table.include?('Drug Interaction Data') }
                    return [] unless drug_data.present?
                    fields = drug_data['Drug Interaction Data']['fields']
              Severity: Minor
              Found in lib/genome/online_updaters/docm/updater.rb - About 45 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 add_interaction_claim_publications has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def add_interaction_claim_publications(interaction_claim, source_string)
                    if source_string.include?(';')
                      source_string.split(';').each do |value|
                        value.split(/[^\d]/).each do |pmid|
                          unless pmid.nil? || pmid == ''
              Severity: Minor
              Found in lib/genome/importers/pharmgkb/new_pharmgkb.rb - About 45 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

              Avoid deeply nested control flow statements.
              Open

                                      if not datum or datum == 'None':
                                          datum = 'N/A'
                                      out.append(datum)
              Severity: Major
              Found in lib/genome/updaters/get_drugbank.py - About 45 mins to fix

                Method add_interaction_claim_publications has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def add_interaction_claim_publications(interaction_claim, source_string)
                      if source_string.include?(';')
                        source_string.split(';').each do |value|
                          value.split(/[^\d]/).each do |pmid|
                            unless pmid.nil? || pmid == ''
                Severity: Minor
                Found in lib/genome/importers/cgi/new_cgi.rb - About 45 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

                Consider simplifying this complex logical expression.
                Open

                        elsif val == 'incorporation into and destabilization' || val == 'intercalation' || val == 'desensitize the target' || val == 'disrupter' || val == 'intercalator' || val == 'downregulator'
                          'negative modulator'
                        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'
                        elsif val == 'component of'
                Severity: Major
                Found in lib/genome/normalizers/interaction_claim_type.rb - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                            unless pmid.nil? || pmid == "" || pmid == '""' || pmid == "''" || pmid[0] =='-' || pmid =='15288657'
                              create_interaction_claim_publication(interaction_claim, pmid)
                            end
                  Severity: Major
                  Found in lib/genome/importers/dtc/dtc.rb - About 40 mins to fix

                    Method validate_search_request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def validate_search_request(params)
                        bad_request("Please enter at least one gene to search!") if params[:genes].blank?
                        params[:gene_categories] = DataModel::GeneClaimCategory.all_category_names unless params[:gene_categories]
                        params[:sources] = DataModel::Source.potentially_druggable_source_names unless params[:sources]
                        params[:source_trust_levels] = DataModel::SourceTrustLevel.all_trust_levels unless params[:source_trust_levels]
                    Severity: Minor
                    Found in app/controllers/genes_controller.rb - About 35 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_entries_for_evidence_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def create_entries_for_evidence_item(variant, ei, source)
                          ei['drugs'].select { |d| valid_drug?(d) }.each do |drug|
                            gc = create_gene_claim(variant['entrez_name'], 'Entrez Gene Symbol')
                            create_gene_claim_aliases(gc, variant)
                            if ei['clinical_significance'] == 'Resistance'
                    Severity: Minor
                    Found in lib/genome/online_updaters/civic/updater.rb - About 35 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 extract has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def extract(self, file):
                            with gzip.open(file, 'rb') as rf:
                                with open(os.path.join(self.download_path, file.rsplit('.', 1)[0] + '.human'), 'w') as wf:
                                    for i, line in enumerate(rf):
                                        line_ascii = line.decode('utf-8')
                    Severity: Minor
                    Found in lib/genome/updaters/get_entrez.py - About 35 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_drug_claims has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def create_drug_claims(row, gene_claim, fusion_protein)
                          if row['Drug'].include?(',')
                            combination_therapy = row['Drug']
                            row['Drug'].split(',').each do |drug|
                              drug_claim = create_drug_claim(drug, drug, 'FDA Drug Name')
                    Severity: Minor
                    Found in lib/genome/importers/fda/fda.rb - About 35 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

                    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_trade_name)))
                    Severity: Major
                    Found in lib/genome/groupers/drug_grouper.rb - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language