kotti/views/edit/actions.py

Summary

Maintainability
F
3 days
Test Coverage

File actions.py has 518 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Action views
"""
from pyramid.exceptions import Forbidden
from pyramid.httpexceptions import HTTPFound
Severity: Major
Found in kotti/views/edit/actions.py - About 1 day to fix

    Function change_state has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        def change_state(self):
            """ Change state view. Renders either a view to handle workflow changes
            for multiple nodes or handle the selected workflow changes and get
            back to the referrer of the request.
    
    
    Severity: Minor
    Found in kotti/views/edit/actions.py - About 6 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 paste_nodes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def paste_nodes(self):
            """ Paste nodes view.  Paste formerly copied or cutted nodes into the
            current context.  Note that a cutted node can not be pasted into itself.
    
            :result: Redirect response to the referrer of the request.
    Severity: Minor
    Found in kotti/views/edit/actions.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 rename_nodes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def rename_nodes(self):
            """ Rename nodes view. Renders either a view to change the titles and
            names for multiple nodes or handle the changes and get back to the
            referrer of the request.
    
    
    Severity: Minor
    Found in kotti/views/edit/actions.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 move_child_position has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def move_child_position(context, request):
        """ Move the child from one position to another.
    
        :param context: "Container" node in which the child changes its position.
        :type context: :class:kotti.resources.Node or descendant
    Severity: Minor
    Found in kotti/views/edit/actions.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 set_visibility has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_visibility(self, show):
            """ Do the real work to set the visibility of nodes in the menu. Called
            by the show and the hide view.
    
            :result: Redirect response to the referrer of the request.
    Severity: Minor
    Found in kotti/views/edit/actions.py - About 45 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

    Avoid deeply nested control flow statements.
    Open

                            if tran_info not in transitions:
                                transitions.append(tran_info)
            return {
    Severity: Major
    Found in kotti/views/edit/actions.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for child in childs:
                                  wf = get_workflow(child)
                                  if wf is not None:
                                      wf.transition_to_state(child, self.request, to_state)
                      self.flash(_("Your changes have been saved."), "success")
      Severity: Major
      Found in kotti/views/edit/actions.py - About 45 mins to fix

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

            def delete_nodes(self):
                """ Delete nodes view. Renders either a view to delete multiple nodes or
                delete the selected nodes and get back to the referrer of the request.
        
                :result: Either a redirect response or a dictionary passed to the
        Severity: Minor
        Found in kotti/views/edit/actions.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 contents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def contents(context, request):
            """ Contents view. Renders either the contents view or handle the action
            button actions of the view.
        
            :result: Either a redirect response or a dictionary passed to the
        Severity: Minor
        Found in kotti/views/edit/actions.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

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                if "cancel" in self.request.POST:
                    self.flash(_("No changes were made."), "info")
                    return self.back("@@contents")
        Severity: Major
        Found in kotti/views/edit/actions.py and 2 other locations - About 55 mins to fix
        kotti/views/edit/actions.py on lines 296..298
        kotti/views/edit/actions.py on lines 402..404

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

        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

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                if "cancel" in self.request.POST:
                    self.flash(_("No changes were made."), "info")
                    return self.back("@@contents")
        Severity: Major
        Found in kotti/views/edit/actions.py and 2 other locations - About 55 mins to fix
        kotti/views/edit/actions.py on lines 296..298
        kotti/views/edit/actions.py on lines 361..363

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

        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

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                if "cancel" in self.request.POST:
                    self.flash(_("No changes were made."), "info")
                    return self.back("@@contents")
        Severity: Major
        Found in kotti/views/edit/actions.py and 2 other locations - About 55 mins to fix
        kotti/views/edit/actions.py on lines 361..363
        kotti/views/edit/actions.py on lines 402..404

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

        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