KarrLab/datanator

View on GitHub
datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py

Summary

Maintainability
D
2 days
Test Coverage
D
60%

Function fill_rna_halflife has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def fill_rna_halflife(self, df, species):
        """load data into rna_halflife collection
        
        Args:
            df (:obj:`pandas.DataFrame`): dataframe to be loaded into the database
Severity: Minor
Found in datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py - 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 __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, cache_dir=None, server=None, src_db=None, protein_col=None,
Severity: Major
Found in datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py - About 1 hr to fix

    Function fill_uniprot has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def fill_uniprot(self, url, sheet_name, usercols='B:D', skiprows=[0,1,2],
                        insertion=True):
            """Fill uniprot colleciton with ordered_locus_name
            from excel sheet
            
    Severity: Minor
    Found in datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py - 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 fill_uniprot has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def fill_uniprot(self, url, sheet_name, usercols='B:D', skiprows=[0,1,2],
    Severity: Minor
    Found in datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py - About 35 mins to fix

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

                  elif (gene_name is None and protein_name is not None and 
                        protein_name != 'Uncharacterized protein'): # record exists in uniprot collection with non-filler protein_name
                      self.rna_hl_collection.update_one({'protein_name': protein_name},
                                                        {'$set': {'modified': datetime.datetime.utcnow(),
                                                                  'gene_name': gene_name},
      datanator/data_source/rna_halflife/doi_10_1186_gb_2012_13_4_r30.py on lines 109..130

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

      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 __init__(self, cache_dir=None, server=None, src_db=None, protein_col=None,
                      authDB=None, readPreference=None, username=None, password=None,
                      verbose=None, max_entries=None, des_db=None, rna_col=None):
              """Init
              
      datanator/data_source/rna_halflife/doi_10_1186_gb_2012_13_4_r30.py on lines 11..34

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

      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

          src = Halflife(server=server, src_db=src_db,
              protein_col=protein_col, authDB='admin', readPreference='nearest',
              username=username, password=password, verbose=True, max_entries=float('inf'),
      datanator/data_source/rna_halflife/doi_10_1186_gb_2012_13_4_r30.py on lines 143..145

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

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

                      if index % 10 == 0 and self.verbose:
                          print("Inserting locus {} out of {} into uniprot collection.".format(index, row_count))
      Severity: Major
      Found in datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py and 13 other locations - About 35 mins to fix
      datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 246..247
      datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 307..308
      datanator/data_source/metabolites_meta_collection.py on lines 149..150
      datanator/data_source/rna_halflife/doi_10_1016_j_cell_2013_12_026.py on lines 48..49
      datanator/data_source/rna_halflife/doi_10_1038_srep01318.py on lines 49..50
      datanator/data_source/rna_halflife/doi_10_1091_mbc_e11_01_0028.py on lines 54..55
      datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py on lines 75..76
      datanator/data_source/rna_halflife/doi_10_1093_nar_gkt1150.py on lines 49..50
      datanator/data_source/rna_halflife/doi_10_1101_gr_131037_111.py on lines 72..73
      datanator/data_source/rna_halflife/doi_10_1186_gb_2012_13_4_r30.py on lines 61..62
      datanator/data_source/rna_halflife/doi_10_1371_journal_pone_0059059.py on lines 57..58
      datanator/data_source/rna_modification/rna_modification.py on lines 40..41
      datanator/data_source/rna_modification/rna_modification.py on lines 69..70

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

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

                  if i % 10 == 0 and self.verbose:
                      print("Processing locus {} out {}".format(i, row_count))
      Severity: Major
      Found in datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py and 13 other locations - About 35 mins to fix
      datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 246..247
      datanator/data_source/metabolite_concentration/doi_10_1038_nchembio_2077.py on lines 307..308
      datanator/data_source/metabolites_meta_collection.py on lines 149..150
      datanator/data_source/rna_halflife/doi_10_1016_j_cell_2013_12_026.py on lines 48..49
      datanator/data_source/rna_halflife/doi_10_1038_srep01318.py on lines 49..50
      datanator/data_source/rna_halflife/doi_10_1091_mbc_e11_01_0028.py on lines 54..55
      datanator/data_source/rna_halflife/doi_10_1093_nar_gks1019.py on lines 58..59
      datanator/data_source/rna_halflife/doi_10_1093_nar_gkt1150.py on lines 49..50
      datanator/data_source/rna_halflife/doi_10_1101_gr_131037_111.py on lines 72..73
      datanator/data_source/rna_halflife/doi_10_1186_gb_2012_13_4_r30.py on lines 61..62
      datanator/data_source/rna_halflife/doi_10_1371_journal_pone_0059059.py on lines 57..58
      datanator/data_source/rna_modification/rna_modification.py on lines 40..41
      datanator/data_source/rna_modification/rna_modification.py on lines 69..70

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

      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

      There are no issues that match your filters.

      Category
      Status