KarrLab/datanator_rest_api

View on GitHub

Showing 13 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

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

Severity
Category
Status
Source
Language