emory-libraries/eulfedora

View on GitHub

Showing 182 of 182 total issues

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

    @property
    def methods(self):
        if self._methods is None:
            self.get_methods()
        return self._methods
Severity: Minor
Found in eulfedora/models.py and 1 other location - About 30 mins to fix
eulfedora/models.py on lines 1402..1406

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

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

    @property
    def history(self):
        if self._history is None:
            self.getHistory()
        return self._history
Severity: Minor
Found in eulfedora/models.py and 1 other location - About 30 mins to fix
eulfedora/models.py on lines 1798..1802

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

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 ''
Severity: Major
Found in eulfedora/templatetags/fedora.py - About 30 mins to fix

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

                def run(self, test):
                    wrapped_test = alternate_test_fedora.wrap_test(test)
                    return super(FedoraXmlTestRunner, self).run(wrapped_test)
    Severity: Minor
    Found in eulfedora/testutil.py and 1 other location - About 30 mins to fix
    eulfedora/testutil.py on lines 176..178

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

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

    def index_data(request, id, repo=None):
        '''Return the fields and values to be indexed for a single object
        as JSON.  Index content is generated via
        :meth:`eulfedora.models.DigitalObject.index_data`.
    
    
    Severity: Minor
    Found in eulfedora/indexdata/views.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 add_relationship has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_relationship(self, rel_uri, obj):
            """
            Add a new relationship to the RELS-EXT for this object.
            Calls :meth:`API_M.addRelationship`.
    
    
    Severity: Minor
    Found in eulfedora/models.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 purge_relationship has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def purge_relationship(self, rel_uri, obj):
            """
            Purge a relationship from RELS-EXT for this object.
            Calls :meth:`API_M.purgeRelationship`.
    
    
    Severity: Minor
    Found in eulfedora/models.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 _build_foxml_doc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _build_foxml_doc(self):
            # make an lxml element builder - default namespace is foxml, display with foxml prefix
            E = ElementMaker(namespace=self.FOXML_NS, nsmap={'foxml': self.FOXML_NS})
            doc = E('digitalObject')
            doc.set('VERSION', '1.1')
    Severity: Minor
    Found in eulfedora/models.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 for_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def for_class(digobj, repo):
            '''Generate a ContentModel object for the specified
            :class:`DigitalObject` class.  Content model object is saved
            in the specified repository if it doesn't already exist.'''
            full_name = '%s.%s' % (digobj.__module__, digobj.__name__)
    Severity: Minor
    Found in eulfedora/models.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 undo_last_save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def undo_last_save(self, logMessage=None):
            """Undo the last change made to the datastream content and profile, effectively
            reverting to the object state in Fedora as of the specified timestamp.
    
            For a versioned datastream, this will purge the most recent datastream.
    Severity: Minor
    Found in eulfedora/models.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

    FIXME found
    Open

            # FIXME: **preliminary** actual last-modified, since the above does not
    Severity: Minor
    Found in eulfedora/models.py by fixme

    FIXME found
    Open

            elif "'" in val:    # FIXME: need better handling for literal strings
    Severity: Minor
    Found in eulfedora/api.py by fixme

    FIXME found
    Open

            # FIXME: not actually available in datastreamProfile !!
    Severity: Minor
    Found in eulfedora/models.py by fixme

    FIXME found
    Open

            # FIXME: catch exceptions on save, treat same as failure to save (?)
    Severity: Minor
    Found in eulfedora/models.py by fixme

    TODO found
    Open

            # TODO:
    Severity: Minor
    Found in eulfedora/models.py by fixme

    TODO found
    Open

            # FIXME/TODO: add count/summary info for content models objects created ?

    FIXME found
    Open

            # FIXME: how to make access to a versioned ds_list ?
    Severity: Minor
    Found in eulfedora/models.py by fixme

    FIXME found
    Open

    .. FIXME: raw_ds docs seem to be broken because of django decorators (?)
    Severity: Minor
    Found in doc/fedora/django.rst by fixme

    TODO found
    Open

    # TODO: Relation objects should probably have an intro section with a
    Severity: Minor
    Found in eulfedora/models.py by fixme

    TODO found
    Open

            # TODO: eventually we want to handle the case where a DigitalObject
    Severity: Minor
    Found in eulfedora/server.py by fixme
    Severity
    Category
    Status
    Source
    Language