KarrLab/datanator_rest_api

View on GitHub

Showing 272 of 273 total issues

Function get has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

        def get(ko_number, _from=0, size=10, target_organism='Escherichia coli', taxon_distance=False):
            result = []
            query = {"orthodb_id": ko_number}
            docs = rna_manager.db_obj['rna_modification'].find(filter=query, skip=_from,
                                                                limit=size, projection={'_id': 0})
Severity: Minor
Found in datanator_rest_api/routes/rna.py - About 2 hrs 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

    class num_obs_abundances():
        def get():
            pipeline = pipelines.Pipeline().aggregate_total_array_length("observation")
            for doc in p_manager.db_obj['pax'].aggregate(pipeline):
                return doc['total']
Severity: Major
Found in datanator_rest_api/routes/proteins.py and 1 other location - About 2 hrs to fix
datanator_rest_api/routes/rna.py on lines 140..144

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

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

    class get_total_modifications:
        def get():
            pipeline = pipelines.Pipeline().aggregate_total_array_length("modifications")
            for doc in rna_manager.db_obj['rna_modification'].aggregate(pipeline):
                return doc['total']
Severity: Major
Found in datanator_rest_api/routes/rna.py and 1 other location - About 2 hrs to fix
datanator_rest_api/routes/proteins.py on lines 105..109

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

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

                    for i, concentration in enumerate(doc['concentrations']):
                        queried_species, distance_obj, concentration = dist_manager.get_dist_object(concentration, queried_species, distance_obj,
                                                                                         target_species, tax_field='species_name', org_format='tax_name')
                        doc['concentrations'][i] = concentration
Severity: Major
Found in datanator_rest_api/routes/metabolites.py and 1 other location - About 1 hr to fix
datanator_rest_api/routes/rna.py on lines 114..117

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

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

                            for i, mod in enumerate(mods):
                                queried_species, distance_obj, mod = dist_manager.get_dist_object(mod, queried_species, distance_obj,
                                                                                                  target_organism, tax_field='organism', org_format='tax_name')
                                doc['modifications'][i] = mod
Severity: Major
Found in datanator_rest_api/routes/rna.py and 1 other location - About 1 hr to fix
datanator_rest_api/routes/metabolites.py on lines 63..66

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

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

    def get(substrates, products, _from, size, bound, dof,
Severity: Major
Found in datanator_rest_api/routes/reactions.py - About 1 hr to fix

Function get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def get(inchikey, threshold=0.6, target_species='homo sapiens', taxon_distance=False):
            docs = mc_manager.get_similar_concentrations(inchikey, threshold=threshold)
            doc = concentrations.get(inchikey, species=target_species, taxon_distance=False)
            if doc != {}:
                doc['similarity_score'] = 1.0
Severity: Minor
Found in datanator_rest_api/routes/metabolites.py - About 55 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 has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def get(substrates, products, _from, size, bound, taxon_distance=True, 
Severity: Major
Found in datanator_rest_api/routes/reactions.py - About 50 mins to fix

Function get_dist_object has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def get_dist_object(self, doc, queried_species, distance_obj,
Severity: Major
Found in datanator_rest_api/util/taxon_distance.py - About 50 mins to fix

Avoid deeply nested control flow statements.
Open

                            for i, mod in enumerate(mods):
                                queried_species, distance_obj, mod = dist_manager.get_dist_object(mod, queried_species, distance_obj,
                                                                                                  target_organism, tax_field='organism', org_format='tax_name')
                                doc['modifications'][i] = mod
                            result.append(doc)
Severity: Major
Found in datanator_rest_api/routes/rna.py - About 45 mins to fix

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

        def get(query_message, index, from_, size, fields,
Severity: Minor
Found in datanator_rest_api/routes/ftx.py - About 45 mins to fix

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

    def get(query_message, index, from_, size, fields, _source_includes=[]):
Severity: Minor
Found in datanator_rest_api/routes/ftx.py - About 35 mins to fix

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

        def get(query_message, iof, index, from_, size, fields):
Severity: Minor
Found in datanator_rest_api/routes/ftx.py - About 35 mins to fix

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

def create_app(apiName="DatanatorAPI.yaml", entryModule="datanator_rest_api.routes", 
Severity: Minor
Found in datanator_rest_api/core.py - About 35 mins to fix

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

    def page(self, _from=0, size=10):
        """Calculate page information.

        Args:
            _from (:obj:`int`, optional): Page starting from. Defaults to 0.
Severity: Minor
Found in datanator_rest_api/util/paginator.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def get(parameter):
            if parameter == 'k_is':
                docs =r_manager.db_obj['sabio_rk_old'].aggregate([
                        {"$project": {"parameter": 1}},
                        {"$match": {"parameter.observed_name": "Ki"}},
Severity: Minor
Found in datanator_rest_api/routes/reactions.py - About 25 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_dist_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_dist_object(self, doc, queried_species, distance_obj,
                    target_species, org_format='tax_id',
                    tax_field='species_name', obj_name='taxon_distance'):
        """Return taxon_distance object for frontend.

Severity: Minor
Found in datanator_rest_api/util/taxon_distance.py - About 25 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

Line too long (97 > 79 characters)
Open

            docs(:obj:`Iter`): Documents that need calculation of taxon_distance and rearranging.

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to
have several windows side-by-side.  The default wrapping on such
devices looks ugly.  Therefore, please limit all lines to a maximum
of 79 characters. For flowing long blocks of text (docstrings or
comments), limiting the length to 72 characters is recommended.

Reports error E501.

Trailing whitespace
Open

        r = f_manager.simple_query_string(query_message, index, from_=from_, 
Severity: Minor
Found in datanator_rest_api/routes/ftx.py by pep8

Trailing whitespace is superfluous.

The warning returned varies on whether the line itself is blank,
for easier filtering for those who want to indent their blank lines.

Okay: spam(1)\n#
W291: spam(1) \n#
W293: class Foo(object):\n    \n    bang = 12

Blank line contains whitespace
Open

    

Trailing whitespace is superfluous.

The warning returned varies on whether the line itself is blank,
for easier filtering for those who want to indent their blank lines.

Okay: spam(1)\n#
W291: spam(1) \n#
W293: class Foo(object):\n    \n    bang = 12
Severity
Category
Status
Source
Language