uktrade/lite-forms

View on GitHub

Showing 39 of 39 total issues

Avoid deeply nested control flow statements.
Open

                    for _component in option.components:
                        if _component and hasattr(_component, "name"):
                            components.append(_component)

Severity: Major
Found in helpers.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if question.prefix in key:
                            exists = True
                            continue
                    elif hasattr(question, "name"):
    Severity: Major
    Found in submitters.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if question.name == key:
                              exists = True
                              continue
      
      
      Severity: Major
      Found in submitters.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for sub_value in value:
                                current_form.questions.insert(0, HiddenField(key + "[]", sub_value))
                        else:
        Severity: Major
        Found in submitters.py - About 45 mins to fix

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

              def __init__(
                  self,
                  title=None,
                  description=None,
                  questions=None,
          Severity: Minor
          Found in components.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 flatten_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def flatten_data(d, parent_key="", sep="."):
              """
              Flattens dictionaries eg
              {
                  'site': {
          Severity: Minor
          Found in helpers.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 remove_unused_errors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def remove_unused_errors(errors, form: Form):
              """
              Removes all errors that don't belong to a form's fields
              :param errors: ['errors'] children
              :param form: Form object
          Severity: Minor
          Found in helpers.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

          Avoid too many return statements within this function.
          Open

                      return data["key"] == key
          Severity: Major
          Found in templatetags/custom_tags.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return True
            Severity: Major
            Found in templatetags/custom_tags.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return True
              Severity: Major
              Found in templatetags/custom_tags.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return True
                Severity: Major
                Found in templatetags/custom_tags.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return data
                  Severity: Major
                  Found in templatetags/custom_tags.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return False
                    Severity: Major
                    Found in templatetags/custom_tags.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return redirect(request.path)
                      Severity: Major
                      Found in views.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return data["id"] == key
                        Severity: Major
                        Found in templatetags/custom_tags.py - About 30 mins to fix

                          Function _prepare_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def _prepare_data(request, inject_data):
                              data = request.POST.copy()
                          
                              # Handle lists (such as checkboxes)
                              data = handle_lists(data)
                          Severity: Minor
                          Found in submitters.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 update_progress_indicators has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def update_progress_indicators(self):
                                  index = 0
                                  if self.show_progress_indicators:
                                      for form in self.forms:
                                          if form:
                          Severity: Minor
                          Found in components.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 convert_list_to_tree has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def convert_list_to_tree(items, key="key", value="value", children="children", exclude=None):
                              return_value = []
                          
                              for item in items:
                                  node = TreeNode(item[key], item[value])
                          Severity: Minor
                          Found in helpers.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 nest_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def nest_data(sent_data):
                              """
                              Nests strings into dictionaries eg
                              {
                                  'site.name': 'SITE1'
                          Severity: Minor
                          Found in helpers.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