KarrLab/datanator

View on GitHub
datanator/data_source/sabio_reaction.py

Summary

Maintainability
C
1 day
Test Coverage
F
47%

Function hash_null_reactants has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def hash_null_reactants(self, start=0):
        """(https://github.com/KarrLab/datanator/issues/50)
           (https://github.com/KarrLab/datanator_rest_api/issues/116)

        Args:
Severity: Minor
Found in datanator/data_source/sabio_reaction.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_collection has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def fill_collection(self):
        projection = {'_id': 0,'resource': 1, 'reaction_participant': 1,
                    'reaction_participant': 1, 'kinlaw_id': 1, 'enzymes': 1}
        collection = self.db_obj['sabio_rk_old']
        docs = collection.find({}, projection=projection)
Severity: Minor
Found in datanator/data_source/sabio_reaction.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 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, username=None, password=None, server=None, authSource='admin',
Severity: Major
Found in datanator/data_source/sabio_reaction.py - About 1 hr to fix

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

        def label_existence(self, start=0):
            """Label reactant's existence in metabolites collections.
            """
            docs = self.metabolites_meta_manager.find({})
            count = self.metabolites_meta_manager.count_documents({})
    Severity: Minor
    Found in datanator/data_source/sabio_reaction.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 extract_enzyme_names has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def extract_enzyme_names(self, doc):
            """Extract enzyme names
            
            Args:
                doc (:obj:`dict`): sabio_rk_old document
    Severity: Minor
    Found in datanator/data_source/sabio_reaction.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

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

                if i % 10 == 0 and self.verbose:
                    print("Process entry {} out of {} ...".format(i+start, count))
    Severity: Major
    Found in datanator/data_source/sabio_reaction.py and 8 other locations - About 1 hr to fix
    datanator/data_source/gene_ortholog.py on lines 162..163
    datanator/data_source/metabolites_meta_collection.py on lines 173..174
    datanator/data_source/sabio_reaction.py on lines 170..171
    datanator/data_source/uniprot_nosql.py on lines 147..148
    datanator/data_source/uniprot_nosql.py on lines 162..163
    datanator/data_source/uniprot_nosql.py on lines 234..235
    datanator/data_source/uniprot_nosql.py on lines 269..270
    datanator/data_source/uniprot_nosql.py on lines 304..305

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

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

                if i % 50 == 0 and self.verbose:
                    print("Process metabolite {} out of {} ...".format(i+start, count))
    Severity: Major
    Found in datanator/data_source/sabio_reaction.py and 8 other locations - About 1 hr to fix
    datanator/data_source/gene_ortholog.py on lines 162..163
    datanator/data_source/metabolites_meta_collection.py on lines 173..174
    datanator/data_source/sabio_reaction.py on lines 198..199
    datanator/data_source/uniprot_nosql.py on lines 147..148
    datanator/data_source/uniprot_nosql.py on lines 162..163
    datanator/data_source/uniprot_nosql.py on lines 234..235
    datanator/data_source/uniprot_nosql.py on lines 269..270
    datanator/data_source/uniprot_nosql.py on lines 304..305

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

    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

                substrates_hashed = [x if x is not None else substrates_name_hashed[i] for i, x in enumerate(substrates_hashed)]
    Severity: Major
    Found in datanator/data_source/sabio_reaction.py and 1 other location - About 1 hr to fix
    datanator/data_source/sabio_reaction.py on lines 213..213

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

    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

                products_hashed = [x if x is not None else products_name_hashed[i] for i, x in enumerate(products_hashed)]
    Severity: Major
    Found in datanator/data_source/sabio_reaction.py and 1 other location - About 1 hr to fix
    datanator/data_source/sabio_reaction.py on lines 214..214

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

    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

                self.col.update_one({'_id': doc['_id']},
                                    {'$set': {'products': products_hashed,
                                              'substrates': substrates_hashed}},
    Severity: Minor
    Found in datanator/data_source/sabio_reaction.py and 1 other location - About 50 mins to fix
    datanator/data_source/protein_aggregate.py on lines 135..137

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

    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

        src = RxnAggregate(username=username, password=password, server=server, 
    Severity: Minor
    Found in datanator/data_source/sabio_reaction.py and 1 other location - About 45 mins to fix
    datanator/data_source/protein_aggregate.py on lines 321..321

    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

    There are no issues that match your filters.

    Category
    Status