Showing 91 of 91 total issues

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

            d["title"] = eval(d["title"]) if "title" in d else d["name"]
Severity: Major
Found in kotti/views/edit/__init__.py and 1 other location - About 1 hr to fix
kotti/views/edit/__init__.py on lines 27..28

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

        except (NameError, SyntaxError):
            d["title"] = _(d["title"]) if "title" in d else d["name"]
Severity: Major
Found in kotti/views/edit/__init__.py and 1 other location - About 1 hr to fix
kotti/views/edit/__init__.py on lines 21..21

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

Function login has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def login(context, request):
    """ Login view.  Renders either the login or password forgot form templates
    or handles their form submission and redirects to came_from on success.

    :result: Either a redirect response or a dictionary passed to the template
Severity: Minor
Found in kotti/views/login.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 __call__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def __call__(self):
        api = template_api(self.context, self.request, cp_links=CONTROL_PANEL_LINKS)

        api.page_title = _("User Management")

Severity: Minor
Found in kotti/views/users.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

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

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

def _setup_listeners(settings):

    # step 2: setup listeners

    for s in settings["kotti.sanitize_on_write"].split():
Severity: Minor
Found in kotti/sanitizers.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

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

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

    def __call__(self, request: Request) -> Response:
        """
        :param request: Current request
        :type request: :class:`kotti.request.Request`

Severity: Minor
Found in kotti/filedepot.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

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

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

    def search(self, match: Optional[str] = "any", **kwargs) -> Query:
        """ Search the principal database.

        :param match: ``any`` to return all principals matching any search
                      param, ``all`` to return only principals matching
Severity: Minor
Found in kotti/security.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 register has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def register(context, request):
    schema = RegisterSchema().bind(request=request)
    form = Form(schema, buttons=(Button("register", _("Register")),))
    rendered_form = None

Severity: Minor
Found in kotti/views/login.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in kotti/security.py - About 50 mins to fix

    Function deferred_email_validator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def deferred_email_validator(node, kw):
        def raise_invalid_email(node, value):
            raise colander.Invalid(node, _("A user with that email already exists."))
    
        request = kw["request"]
    Severity: Minor
    Found in kotti/views/users.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

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

        def __init__(
    Severity: Minor
    Found in kotti/filedepot.py - About 45 mins to fix

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

          def blank(cls, path, environ=None, base_url=None, headers=None, POST=None, **kw):
      Severity: Minor
      Found in kotti/testing.py - About 45 mins to fix

        Function _translate_titles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def _translate_titles(info):
            result = []
            for d in info:
                d = d.copy()
                try:
        Severity: Minor
        Found in kotti/views/edit/__init__.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

        Function set_default_view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def set_default_view(self):
                """
                :summary: Set the node's default view and redirect to it.
                :result: Redirect to the context URL.
                :rtype: pyramid.httpexceptions.HTTPFound
        Severity: Minor
        Found in kotti/views/edit/default_views.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

                                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
          Severity
          Category
          Status
          Source
          Language