KarrLab/datanator_query_python

View on GitHub

Showing 190 of 190 total issues

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

        if doc is None:
            return None, None
        else:
            return doc['gene_name'], doc['protein_name']
Severity: Major
Found in datanator_query_python/query/query_uniprot.py and 2 other locations - About 45 mins to fix
datanator_query_python/query/query_uniprot.py on lines 60..63
datanator_query_python/query/query_uniprot.py on lines 109..112

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

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

    def get_num_source(self, q, q_index, index, fields=['name', 'synonyms'], 
                        count=10, from_=0, batch_size=100):
        """Extract a count number of source (ecmdb, ymdb, metabolite_meta, etc) index
        from ftx search result
        
Severity: Minor
Found in datanator_query_python/query/full_text_search.py - 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

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

            cursor = self._collection.find_one({'$or': [{'synonyms': compound},
                                                       {'name': compound}]},
Severity: Minor
Found in datanator_query_python/query/query_metabolites_meta.py and 1 other location - About 45 mins to fix
datanator_query_python/query/query_metabolites_meta.py on lines 156..157

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

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 get_single_index_count has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def get_single_index_count(self, q, index, num, 
Severity: Minor
Found in datanator_query_python/query/full_text_search.py - About 45 mins to fix

    Function get_index_in_page has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_index_in_page(self, r, index):
            """Get indices in current hits page
            
            Args:
                r (:obj:`dict`): ftx search result
    Severity: Minor
    Found in datanator_query_python/query/full_text_search.py - 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

    Function update_observation has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def update_observation(self, 
    Severity: Minor
    Found in datanator_query_python/util/mongo_util.py - About 45 mins to fix

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

              super().__init__(MongoDB=server, db=db, username=username,
      Severity: Major
      Found in datanator_query_python/query/query_rna_halflife.py and 3 other locations - About 40 mins to fix
      datanator_query_python/aggregate/tabu.py on lines 12..12
      datanator_query_python/query/full_text_search.py on lines 10..13
      datanator_query_python/query/query_metabolite_concentrations.py on lines 11..11

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

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

              super().__init__(MongoDB=MongoDB, db=db, username=username, password=password,
      Severity: Major
      Found in datanator_query_python/aggregate/tabu.py and 3 other locations - About 40 mins to fix
      datanator_query_python/query/full_text_search.py on lines 10..13
      datanator_query_python/query/query_metabolite_concentrations.py on lines 11..11
      datanator_query_python/query/query_rna_halflife.py on lines 10..10

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

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

              super().__init__(MongoDB=MongoDB, db=db, verbose=verbose, username=username,
      datanator_query_python/aggregate/tabu.py on lines 12..12
      datanator_query_python/query/full_text_search.py on lines 10..13
      datanator_query_python/query/query_rna_halflife.py on lines 10..10

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

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

          def __init__(self, profile_name=None, credential_path=None,
                      config_path=None, elastic_path=None,
                      cache_dir=None, service_name='es', max_entries=float('inf'), verbose=False):
              super().__init__(profile_name=profile_name, credential_path=credential_path,
      Severity: Major
      Found in datanator_query_python/query/full_text_search.py and 3 other locations - About 40 mins to fix
      datanator_query_python/aggregate/tabu.py on lines 12..12
      datanator_query_python/query/query_metabolite_concentrations.py on lines 11..11
      datanator_query_python/query/query_rna_halflife.py on lines 10..10

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

      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 get_file_by_quality has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def get_file_by_quality(self, organ, score=4.0, coverage=20, ncbi_id=None,
      Severity: Minor
      Found in datanator_query_python/query/query_pax.py - About 35 mins to fix

        Function search_taxon has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def search_taxon(self,
        Severity: Minor
        Found in datanator_query_python/query_schema_2/ftx_search.py - About 35 mins to fix

          Function aggregate_field_count has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def aggregate_field_count(self, field, projection={"parameter": 1},
          Severity: Minor
          Found in datanator_query_python/aggregate/pipelines.py - About 35 mins to fix

            Function get_index_ko_count has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def get_index_ko_count(self, q, num, agg_field="frontend_gene_aggregate", index='protein', **kwargs):
            Severity: Minor
            Found in datanator_query_python/query/full_text_search.py - About 35 mins to fix

              Function aggregate_all_occurences has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def aggregate_all_occurences(self, field, match=None,
              Severity: Minor
              Found in datanator_query_python/aggregate/pipelines.py - About 35 mins to fix

                Function get_meta_by_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_meta_by_id(self, _id):
                        '''
                            Get protein's metadata given uniprot id
                
                            Args:
                Severity: Minor
                Found in datanator_query_python/query/query_protein.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

                Function update_entity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def update_entity(self,
                                      obj,
                                      match,
                                      db="test",
                                      col="entity",
                Severity: Minor
                Found in datanator_query_python/util/mongo_util.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

                Function get_genes_ko_count has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_genes_ko_count(self, q, num, agg_field="ko_number", **kwargs):
                        """Get protein index with different ko_number field for up to num hits,
                        provided at least one of the proteins under ko_number has abundance info.
                        
                        Args:
                Severity: Minor
                Found in datanator_query_python/query/full_text_search.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

                Function get_canon_common_ancestor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_canon_common_ancestor(self, org1, org2, org_format='tax_id'):
                        ''' Get the closest common ancestor between
                            two organisms and their distances to the 
                            said ancestor
                            Args:
                Severity: Minor
                Found in datanator_query_python/query/query_taxon_tree.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

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

                        [canon_anc_2.append(anc) for (anc, rank) in zip(org2_anc_name, rank2_anc) if rank != '+']
                Severity: Minor
                Found in datanator_query_python/query/query_taxon_tree.py and 1 other location - About 35 mins to fix
                datanator_query_python/query/query_taxon_tree.py on lines 391..391

                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

                Severity
                Category
                Status
                Source
                Language