KarrLab/datanator_query_python

View on GitHub

Showing 190 of 190 total issues

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

    def _get_common_canon_anc(self, org1, org2, canon_anc_1, canon_anc_2):
        """Get canon common ancestors between species.

        Args:
            org1(:obj:`str`): Name of species 1.
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 get_reaction_by_subunit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_reaction_by_subunit(self, _ids):
        """Get reactions by enzyme subunit uniprot IDs
        
        Args:
            _ids (:obj:`list` of :obj:`str`): List of uniprot IDs.
Severity: Minor
Found in datanator_query_python/query/query_sabiork_old.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_proximity_abundance_taxon has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_proximity_abundance_taxon(self, _id, max_distance=3):
        '''
            Get replacement abundance value by taxonomic distance
            with the same kegg_orthology number.

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

    def get_canon_rank_distance_by_name(self, name, front_end=False):
        '''Given the name of species, return canonically-ranked ancestors
            along the lineage and their non-canonical distances

        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

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

    def get_abundance_from_uniprot(self, uniprot_id):
        '''
            Get all abundance data for uniprot_id

            Args:
Severity: Minor
Found in datanator_query_python/query/query_pax.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_protein_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_protein_name(self):
        """Get protein name.

        Return:
            (:obj:`list` of :obj:`str`): list of protein names.
Severity: Minor
Found in datanator_query_python/query/query_uniprot_org.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_kinlaw_by_rxn has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_kinlaw_by_rxn(self, substrates, products, dof=0,
                          projection={'kinlaw_id': 1, '_id': 0},
                          bound='loose', skip=0, limit=0):
        ''' Find the kinlaw_id defined in sabio_rk using 
            rxn participants' inchikey
Severity: Minor
Found in datanator_query_python/query/query_sabiork_old.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 find_reaction_participants has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def find_reaction_participants(self, kinlaw_id):
        ''' Find the reaction participants defined in sabio_rk using kinetic law id
        
            Args:
                kinlaw_id (:obj:`list` of :obj:`int`) list of kinlaw_id to search for
Severity: Minor
Found in datanator_query_python/query/query_sabiork.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_info_by_text_abundances has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_info_by_text_abundances(self, name):
        '''
            Get proteins whose name or kegg name contains string 'name'.

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

    def get_similar_concentrations(self, metabolite, threshold=0.6):
        """Get metabolite's similar compounds' concentrations above
        threshold tanimoto value.

        Args:
Severity: Minor
Found in datanator_query_python/query/query_metabolite_concentrations.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_kinlaw_by_environment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_kinlaw_by_environment(self, taxon=None, taxon_wildtype=None, ph_range=None, temp_range=None,
                          name_space=None, observed_type=None, projection={'_id': 0}):
        """get kinlaw info based on experimental conditions
        
        Args:
Severity: Minor
Found in datanator_query_python/query/query_sabiork.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_observation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def update_observation(self, 
                           obj,
                           source,
                           db="test",
                           op="update",
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

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

        [canon_anc_1.append(anc) for (anc, rank) in zip(org1_anc_name, rank1_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 392..392

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

Avoid too many return statements within this function.
Open

        return {str(org1): distance1, str(org2): distance2, str(org1)+'_canon_ancestors':canon_anc_1,
Severity: Major
Found in datanator_query_python/query/query_taxon_tree.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return "%s-%s%s%s-%s" % (major, minor, flag, flagver, flagproto)
    Severity: Major
    Found in datanator_query_python/util/chem_util.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return {str(org1): distance1, str(org2): distance2, str(org1)+'_canon_ancestors':canon_anc_1,
      Severity: Major
      Found in datanator_query_python/query/query_taxon_tree.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return 'Invalid inchi string'
        Severity: Major
        Found in datanator_query_python/util/chem_util.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return 'Invalid inchi string'
          Severity: Major
          Found in datanator_query_python/util/chem_util.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return result
            Severity: Major
            Found in datanator_query_python/query/query_protein.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return 'Invalid inchi string'
              Severity: Major
              Found in datanator_query_python/util/chem_util.py - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language