core/domain/state_domain.py

Summary

Maintainability
F
1 wk
Test Coverage

File state_domain.py has 3954 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding: utf-8
#
# Copyright 2018 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Severity: Major
Found in core/domain/state_domain.py - About 1 wk to fix

    Function convert_html_in_solution has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        def convert_html_in_solution(
            interaction_id: Optional[str],
            solution_dict: SolutionDict,
            conversion_fn: Callable[[str], str],
            html_field_types_to_rule_specs: Dict[
    Severity: Minor
    Found in core/domain/state_domain.py - About 5 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 _validate_numeric_input has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def _validate_numeric_input(self, strict: bool = False) -> None:
            """Validates the NumericInput interaction.
    
            Args:
                strict: bool. If True, the exploration is assumed to be published.
    Severity: Minor
    Found in core/domain/state_domain.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 validate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(
            self,
            interaction: base.BaseInteraction,
            exp_param_specs_dict: Dict[str, param_domain.ParamSpec],
            *,
    Severity: Minor
    Found in core/domain/state_domain.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 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in core/domain/state_domain.py - About 1 hr to fix

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

          def is_rte_content_supported_on_android(
              self, require_valid_component_names: Callable[[str], bool]
          ) -> bool:
              """Determines whether the RTE content in interaction answer groups,
              hints and solution is supported by Android app.
      Severity: Minor
      Found in core/domain/state_domain.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 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in core/domain/state_domain.py - About 1 hr to fix

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

            def __init__(
        Severity: Major
        Found in core/domain/state_domain.py - About 1 hr to fix

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

              def _is_enclosed_by(
                  self, test_range: RangeVariableDict, base_range: RangeVariableDict
              ) -> bool:
                  """Returns `True` when `test_range` variable lies within
                  `base_range` variable.
          Severity: Minor
          Found in core/domain/state_domain.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_lower_and_upper_bounds has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _set_lower_and_upper_bounds(
          Severity: Major
          Found in core/domain/state_domain.py - About 50 mins to fix

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

                def validate(
            Severity: Minor
            Found in core/domain/state_domain.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (
                                              html_type ==
                                              feconf.ANSWER_TYPE_LIST_OF_SETS_OF_HTML):
              
                                          # Here correct_answer can only be of type
              Severity: Major
              Found in core/domain/state_domain.py - About 45 mins to fix

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

                    def convert_html_fields_in_state(
                Severity: Minor
                Found in core/domain/state_domain.py - About 45 mins to fix

                  Function validate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def validate(
                  Severity: Minor
                  Found in core/domain/state_domain.py - About 35 mins to fix

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

                        def __init__(
                    Severity: Minor
                    Found in core/domain/state_domain.py - About 35 mins to fix

                      Function create_default_state has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def create_default_state(
                      Severity: Minor
                      Found in core/domain/state_domain.py - About 35 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return True
                        Severity: Major
                        Found in core/domain/state_domain.py - About 30 mins to fix

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

                              def _validates_choices_should_be_unique_and_nonempty(
                                  self, choices: List[SubtitledHtml]
                              ) -> None:
                                  """Validates that the choices should be unique and non empty.
                          
                          
                          Severity: Minor
                          Found in core/domain/state_domain.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

                          There are no issues that match your filters.

                          Category
                          Status