core/domain/exp_domain.py

Summary

Maintainability
F
1 mo
Test Coverage

File exp_domain.py has 5347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Function validate has a Cognitive Complexity of 218 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self, strict: bool = False) -> None:
            """Validates various properties of the Exploration.
    
            Args:
                strict: bool. If True, the exploration is assumed to be published,
    Severity: Minor
    Found in core/domain/exp_domain.py - About 4 days 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 _fix_drag_and_drop_input_interaction has a Cognitive Complexity of 164 (exceeds 5 allowed). Consider refactoring.
    Open

        def _fix_drag_and_drop_input_interaction(
            cls, state_dict: state_domain.StateDict, state_name: str
        ) -> None:
            """Fixes the DragAndDropInput interaction with following checks:
            - The rules should not be duplicate else the one with not pointing to
    Severity: Minor
    Found in core/domain/exp_domain.py - About 3 days 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 is_change_list_mergeable has a Cognitive Complexity of 151 (exceeds 5 allowed). Consider refactoring.
    Open

        def is_change_list_mergeable(
            self,
            change_list: List[ExplorationChange],
            exp_at_change_list_version: Exploration,
            current_exploration: Exploration
    Severity: Minor
    Found in core/domain/exp_domain.py - About 3 days 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 _fix_text_input_interaction has a Cognitive Complexity of 135 (exceeds 5 allowed). Consider refactoring.
    Open

        def _fix_text_input_interaction(
            cls, state_dict: state_domain.StateDict, state_name: str
        ) -> None:
            """Fixes the TextInput interaction with following checks:
            - The rules should not be duplicate else the one with not pointing to
    Severity: Minor
    Found in core/domain/exp_domain.py - About 2 days 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

    Exploration has 95 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Exploration(translation_domain.BaseTranslatableObject):
        """Domain object for an Oppia exploration."""
    
        def __init__(
            self,
    Severity: Major
    Found in core/domain/exp_domain.py - About 1 day to fix

      Function _fix_numeric_input_interaction has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
      Open

          def _fix_numeric_input_interaction(
              cls, state_dict: state_domain.StateDict, state_name: str
          ) -> None:
              """Fixes NumericInput interaction for the following cases:
              - The rules should not be duplicate else the one with not pointing to
      Severity: Minor
      Found in core/domain/exp_domain.py - About 1 day 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 _fix_rte_tags has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
      Open

          def _fix_rte_tags(
              cls, html: str,
              *,
              is_tags_nested_inside_tabs_or_collapsible: bool = False
          ) -> str:
      Severity: Minor
      Found in core/domain/exp_domain.py - About 1 day 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_states_v41_dict_to_v42_dict has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
      Open

          def _convert_states_v41_dict_to_v42_dict(
              cls, states_dict: Dict[str, state_domain.StateDict]
          ) -> Dict[str, state_domain.StateDict]:
              """Converts from version 41 to 42. Version 42 changes rule input types
              for DragAndDropSortInput and ItemSelectionInput interactions to better
      Severity: Minor
      Found in core/domain/exp_domain.py - About 1 day 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_duplicate_rules_inside_answer_groups has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
      Open

          def _remove_duplicate_rules_inside_answer_groups(
              cls,
              answer_groups: List[state_domain.AnswerGroupDict],
              state_name: str
          ) -> None:
      Severity: Minor
      Found in core/domain/exp_domain.py - About 1 day 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 _fix_fraction_input_interaction has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
      Open

          def _fix_fraction_input_interaction(
              cls, state_dict: state_domain.StateDict, state_name: str
          ) -> None:
              """Fixes FractionInput interaction for the following cases:
              - The rules should not be duplicate else the one with not pointing to
      Severity: Minor
      Found in core/domain/exp_domain.py - About 1 day 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 51 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate(self) -> None:
              """Validates various properties of the ExplorationSummary.
      
              Raises:
                  ValidationError. One or more attributes of the ExplorationSummary
      Severity: Minor
      Found in core/domain/exp_domain.py - About 7 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 _choices_should_be_unique_and_non_empty has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
      Open

          def _choices_should_be_unique_and_non_empty(
              cls,
              choices: List[state_domain.SubtitledHtmlDict],
              answer_groups: List[state_domain.AnswerGroupDict],
              state_dict: state_domain.StateDict,
      Severity: Minor
      Found in core/domain/exp_domain.py - About 7 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 _update_state_rte has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

          def _update_state_rte(
              cls, states_dict: Dict[str, state_domain.StateDict]
          ) -> Dict[str, state_domain.StateDict]:
              """Update the state RTE content and translations
      
      
      Severity: Minor
      Found in core/domain/exp_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 _fix_tabs_and_collapsible_tags has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          def _fix_tabs_and_collapsible_tags(cls, html: str) -> str:
              """Fixes all tabs and collapsible tags, performs the following:
              - `oppia-noninteractive-tabs`
                  - If no `tab_contents-with-value` attribute, tag will be removed
                  - If `tab_contents-with-value` is empty then the tag will be removed
      Severity: Minor
      Found in core/domain/exp_domain.py - About 4 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 _update_rule_value_having_empty_choices has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def _update_rule_value_having_empty_choices(
              cls,
              empty_choices: List[state_domain.SubtitledHtmlDict],
              rule_value_x: List[List[str]],
              solution: Optional[List[List[str]]]
      Severity: Minor
      Found in core/domain/exp_domain.py - About 4 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 _fix_item_selection_input_interaction has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def _fix_item_selection_input_interaction(
              cls, state_dict: state_domain.StateDict, state_name: str
          ) -> None:
              """Fixes ItemSelectionInput interaction for the following cases:
              - The rules should not be duplicate else the one with not pointing to
      Severity: Minor
      Found in core/domain/exp_domain.py - About 3 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 _verify_no_dead_ends has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def _verify_no_dead_ends(self) -> None:
              """Verifies that all states can reach a terminal state.
      
              Raises:
                  ValidationError. If is impossible to complete the exploration from
      Severity: Minor
      Found in core/domain/exp_domain.py - About 3 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 _verify_all_states_reachable has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def _verify_all_states_reachable(self) -> None:
              """Verifies that all states are reachable from the initial state.
      
              Raises:
                  ValidationError. One or more states are not reachable from the
      Severity: Minor
      Found in core/domain/exp_domain.py - About 3 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 _convert_states_v49_dict_to_v50_dict has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def _convert_states_v49_dict_to_v50_dict(
              cls, states_dict: Dict[str, state_domain.StateDict]
          ) -> Dict[str, state_domain.StateDict]:
              """Converts from version 49 to 50. Version 50 removes rules from
              explorations that use one of the following rules:
      Severity: Minor
      Found in core/domain/exp_domain.py - About 3 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 __init__ has 21 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in core/domain/exp_domain.py - About 2 hrs to fix

        Function _remove_unwanted_content_ids_from_translations_and_voiceovers_from_state_v51_or_v52 has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def _remove_unwanted_content_ids_from_translations_and_voiceovers_from_state_v51_or_v52( # pylint: disable=line-too-long
                cls, state_dict: state_domain.StateDict, state_schema: int
            ) -> None:
                """Helper function to remove the content IDs from the translations
                and voiceovers which are deleted from the state.
        Severity: Minor
        Found in core/domain/exp_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 _convert_states_v45_dict_to_v46_dict has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def _convert_states_v45_dict_to_v46_dict(
                cls, states_dict: Dict[str, state_domain.StateDict]
            ) -> Dict[str, state_domain.StateDict]:
                """Converts from version 45 to 46. Version 46 ensures that the written
                translations in a state containing unicode content do not contain HTML
        Severity: Minor
        Found in core/domain/exp_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 __init__ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, change_list: Sequence[ExplorationChange]) -> None:
                """Constructs an ExplorationVersionsDiff domain object.
        
                Args:
                    change_list: list(ExplorationChange). A list of all of the commit
        Severity: Minor
        Found in core/domain/exp_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 __init__ has 19 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in core/domain/exp_domain.py - About 2 hrs to fix

          Function _migrate_to_latest_yaml_version has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def _migrate_to_latest_yaml_version(
                  cls, yaml_content: str
              ) -> VersionedExplorationDict:
                  """Return the YAML content of the exploration in the latest schema
                  format.
          Severity: Minor
          Found in core/domain/exp_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 _parse_exp_change has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def _parse_exp_change(self, change: ExplorationChange) -> None:
                  """This function take the change and according to the cmd
                  add the property name in the lists defined above.
          
                  Args:
          Severity: Minor
          Found in core/domain/exp_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 __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
          Open

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

            Function from_dict has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def from_dict(
                    cls,
                    exploration_dict: ExplorationDict,
                    exploration_version: int = 0,
                    exploration_created_on: Optional[datetime.datetime] = None,
            Severity: Minor
            Found in core/domain/exp_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 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

              Function validate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def validate(self) -> None:
                      """Validates various properties of the ExplorationSummary.
              
                      Raises:
                          ValidationError. One or more attributes of the ExplorationSummary
              Severity: Minor
              Found in core/domain/exp_domain.py - About 1 hr to fix

                Function rename_state has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def rename_state(self, old_state_name: str, new_state_name: str) -> None:
                        """Renames the given state.
                
                        Args:
                            old_state_name: str. The old name of state to rename.
                Severity: Minor
                Found in core/domain/exp_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 delete_state has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def delete_state(self, state_name: str) -> None:
                        """Deletes the given state.
                
                        Args:
                            state_name: str. The state name to be deleted.
                Severity: Minor
                Found in core/domain/exp_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 get_trainable_states_dict has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_trainable_states_dict(
                        self,
                        old_states: Dict[str, state_domain.State],
                        exp_versions_diff: ExplorationVersionsDiff
                    ) -> Dict[str, List[str]]:
                Severity: Minor
                Found in core/domain/exp_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 validate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def validate(self, strict: bool = False) -> None:
                        """Validates various properties of the Exploration.
                
                        Args:
                            strict: bool. If True, the exploration is assumed to be published,
                Severity: Minor
                Found in core/domain/exp_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(
                          cls,
                          test_range: RangeVariableDict,
                          base_range: RangeVariableDict
                      ) -> bool:
                  Severity: Minor
                  Found in core/domain/exp_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

                  Avoid deeply nested control flow statements.
                  Open

                                          for outcome in all_outcomes:
                                              if outcome.dest == curr_state_name:
                                                  curr_queue.append(state_name)
                                                  break
                  
                  
                  Severity: Major
                  Found in core/domain/exp_domain.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if cls._is_empty_choice_in_rule_value(
                                                empty_choices, value_x
                                            ):
                                                invalid_rules.append(rule_spec)
                                                continue
                    Severity: Major
                    Found in core/domain/exp_domain.py - About 45 mins to fix

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

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

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

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

                          Avoid deeply nested control flow statements.
                          Open

                                                  if any(
                                                      item in rule_values for item in
                                                      invalid_choices_content_ids
                                                  ):
                                                      invalid_rules.append(rule_spec)
                          Severity: Major
                          Found in core/domain/exp_domain.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if (
                                                        answer_group['outcome']['dest'] == state_name or
                                                        len(rule_value) == 0
                                                    ):
                                                        invalid_rules.append(rule_spec)
                            Severity: Major
                            Found in core/domain/exp_domain.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      for ele_x_at_y_rule in ele_x_at_y_rules:
                                                          assert isinstance(ele_x_at_y_rule, dict)
                                                          ele_position = ele_x_at_y_rule['position']
                                                          ele_element = ele_x_at_y_rule['element']
                                                          assert isinstance(ele_position, int)
                              Severity: Major
                              Found in core/domain/exp_domain.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        for start_with_rule_string in start_with_rule_ele:
                                                            for rule_value in rule_values:
                                                                if rule_value.startswith(
                                                                    start_with_rule_string
                                                                ):
                                Severity: Major
                                Found in core/domain/exp_domain.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          for element in translation['translation']:
                                                              translated_element_list.append(
                                                                  cls.fix_content(element))
                                                          translation['translation'] = translated_element_list
                                  Severity: Major
                                  Found in core/domain/exp_domain.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            for contain_rule_string in contain_rule_ele:
                                                                for rule_value in rule_values:
                                                                    if contain_rule_string in rule_value:
                                                                        invalid_rules.append(rule_spec)
                                                        # `Startswith` should always come after the `Equals`
                                    Severity: Major
                                    Found in core/domain/exp_domain.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              for outcome in all_outcomes:
                                                                  dest_state = outcome.dest
                                                                  # Ruling out the possibility of None for mypy type
                                                                  # checking, because above we are already validating
                                                                  # if outcome exists then it should have destination.
                                      Severity: Major
                                      Found in core/domain/exp_domain.py - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                                if den['denominator'] == rule_spec_f['denominator']:
                                                                    invalid_rules.append(rule_spec)
                                        
                                        
                                        Severity: Major
                                        Found in core/domain/exp_domain.py - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                                  for contain_rule_string in contain_rule_ele:
                                                                      for rule_value in rule_values:
                                                                          if contain_rule_string in rule_value:
                                                                              invalid_rules.append(rule_spec)
                                                              seen_strings_contains.append(rule_values)
                                          Severity: Major
                                          Found in core/domain/exp_domain.py - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                                    if rule_type in rule_types_with_list_of_sets:
                                                                        # For rule type IsEqualToOrdering and
                                                                        # IsEqualToOrderingWithOneItemAtIncorrectPosition,
                                                                        # the x input will be migrated from
                                                                        # ListOfSetsOfHtmlStrings to
                                            Severity: Major
                                            Found in core/domain/exp_domain.py - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                                      if not self.changed_properties[state_name].intersection(
                                                                              self.PROPERTIES_CONFLICTING_CUST_ARGS_CHANGES +
                                                                              [STATE_PROPERTY_INTERACTION_SOLUTION]):
                                                                          if (change.property_name not in
                                                                                  self.changed_translations[state_name]):
                                              Severity: Major
                                              Found in core/domain/exp_domain.py - About 45 mins to fix

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

                                                    def _update_state_interaction(
                                                        cls,
                                                        states_dict: Dict[str, state_domain.StateDict],
                                                        language_code: str
                                                    ) -> Dict[str, state_domain.StateDict]:
                                                Severity: Minor
                                                Found in core/domain/exp_domain.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 layer_idx, layer in enumerate(rule_spec_val_x):
                                                                            for item in layer:
                                                                                item_to_layer_idx[item] = layer_idx
                                                
                                                
                                                Severity: Major
                                                Found in core/domain/exp_domain.py - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                                          for start_with_rule_string in start_with_rule_ele:
                                                                              for rule_value in rule_values:
                                                                                  if rule_value.startswith(
                                                                                      start_with_rule_string
                                                                                  ):
                                                  Severity: Major
                                                  Found in core/domain/exp_domain.py - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                                            if (STATE_PROPERTY_CONTENT not in
                                                                                    self.changed_translations[state_name] and
                                                                                    STATE_PROPERTY_RECORDED_VOICEOVERS not in
                                                                                    self.changed_properties[state_name]):
                                                                                change_is_mergeable = True
                                                    Severity: Major
                                                    Found in core/domain/exp_domain.py - About 45 mins to fix

                                                      Avoid deeply nested control flow statements.
                                                      Open

                                                                              if state.card_is_checkpoint:
                                                                                  raise utils.ValidationError(
                                                                                      'Expected card_is_checkpoint of terminal state '
                                                                                      'to be False but found it to be %s'
                                                                                      % state.card_is_checkpoint
                                                      Severity: Major
                                                      Found in core/domain/exp_domain.py - About 45 mins to fix

                                                        Avoid deeply nested control flow statements.
                                                        Open

                                                                                if choice == empty_choice['content_id']:
                                                                                    choice_list.remove(choice)
                                                                                    break
                                                                            if len(choice_list) == 0:
                                                        Severity: Major
                                                        Found in core/domain/exp_domain.py - About 45 mins to fix

                                                          Avoid deeply nested control flow statements.
                                                          Open

                                                                                  if cls._is_empty_choice_in_rule_value(
                                                                                      empty_choices, element
                                                                                  ):
                                                                                      invalid_rules.append(rule_spec)
                                                                                      continue
                                                          Severity: Major
                                                          Found in core/domain/exp_domain.py - About 45 mins to fix

                                                            Avoid deeply nested control flow statements.
                                                            Open

                                                                                    if (
                                                                                        dest_state is not None and
                                                                                        dest_state not in curr_queue and
                                                                                        dest_state not in processed_queue
                                                                                    ):
                                                            Severity: Major
                                                            Found in core/domain/exp_domain.py - About 45 mins to fix

                                                              Avoid deeply nested control flow statements.
                                                              Open

                                                                                      if rule_type not in MATH_INTERACTION_DEPRECATED_RULES:
                                                                                          filtered_rule_specs.append(
                                                                                              copy.deepcopy(rule_spec_dict))
                                                                                  answer_group_dict['rule_specs'] = filtered_rule_specs
                                                              Severity: Major
                                                              Found in core/domain/exp_domain.py - About 45 mins to fix

                                                                Avoid deeply nested control flow statements.
                                                                Open

                                                                                        if not self.changed_properties[state_name].intersection(
                                                                                                self.PROPERTIES_CONFLICTING_CUST_ARGS_CHANGES +
                                                                                                [STATE_PROPERTY_INTERACTION_CUST_ARGS]):
                                                                                            if (change.property_name not in
                                                                                                    self.changed_translations[state_name]):
                                                                Severity: Major
                                                                Found in core/domain/exp_domain.py - About 45 mins to fix

                                                                  Avoid deeply nested control flow statements.
                                                                  Open

                                                                                          for html_content in rule_inputs['x']:
                                                                                              assert isinstance(html_content, str)
                                                                                              list_of_html_contents.append(html_content)
                                                                                          rule_inputs['x'] = migrate_rule_inputs_and_answers(
                                                                  Severity: Major
                                                                  Found in core/domain/exp_domain.py - About 45 mins to fix

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

                                                                        def _fix_continue_interaction(
                                                                            cls, state_dict: state_domain.StateDict, language_code: str
                                                                        ) -> None:
                                                                            """Fixes Continue interaction where the length of the text value
                                                                            is more than 20. We simply replace them with the word `Continue`
                                                                    Severity: Minor
                                                                    Found in core/domain/exp_domain.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 cls._is_empty_choice_in_rule_value(
                                                                                                empty_choices, value_y
                                                                                            ):
                                                                                                invalid_rules.append(rule_spec)
                                                                                                continue
                                                                    Severity: Major
                                                                    Found in core/domain/exp_domain.py - About 45 mins to fix

                                                                      Avoid deeply nested control flow statements.
                                                                      Open

                                                                                              if (
                                                                                                  dest_if_stuck_state is not None and
                                                                                                  dest_if_stuck_state not in curr_queue and
                                                                                                  dest_if_stuck_state not in processed_queue
                                                                                              ):
                                                                      Severity: Major
                                                                      Found in core/domain/exp_domain.py - About 45 mins to fix

                                                                        Avoid deeply nested control flow statements.
                                                                        Open

                                                                                                for off_by_one_rule in off_by_one_rules:
                                                                                                    assert isinstance(off_by_one_rule, list)
                                                                                                    wrong_positions = 0
                                                                                                    for layer_idx, layer in enumerate(off_by_one_rule):
                                                                                                        for item in layer:
                                                                        Severity: Major
                                                                        Found in core/domain/exp_domain.py - About 45 mins to fix

                                                                          Avoid deeply nested control flow statements.
                                                                          Open

                                                                                                  if not multi_item_value and len(ele) > 1:
                                                                                                      invalid_rules.append(rule_spec)
                                                                          
                                                                                              # `IsEqualToOrdering` rule should not have empty values.
                                                                                              if len(rule_spec_val_x) <= 0:
                                                                          Severity: Major
                                                                          Found in core/domain/exp_domain.py - About 45 mins to fix

                                                                            Avoid deeply nested control flow statements.
                                                                            Open

                                                                                                    if not self.changed_properties[state_name].intersection(
                                                                                                            self.PROPERTIES_CONFLICTING_CUST_ARGS_CHANGES +
                                                                                                            [STATE_PROPERTY_INTERACTION_ANSWER_GROUPS]):
                                                                                                        if (change.property_name not in
                                                                                                                self.changed_translations[state_name]):
                                                                            Severity: Major
                                                                            Found in core/domain/exp_domain.py - About 45 mins to fix

                                                                              Avoid deeply nested control flow statements.
                                                                              Open

                                                                                                      if not self.changed_properties[state_name].intersection(
                                                                                                              (self
                                                                                                               .PROPERTIES_CONFLICTING_INTERACTION_ID_CHANGES
                                                                                                              )):
                                                                                                          change_is_mergeable = True
                                                                              Severity: Major
                                                                              Found in core/domain/exp_domain.py - About 45 mins to fix

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

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

                                                                                  Avoid deeply nested control flow statements.
                                                                                  Open

                                                                                                          for language_code in translations_mapping[content_id]:
                                                                                                              written_translation = (
                                                                                                                  translations_mapping[content_id][language_code])
                                                                                                              written_translation['data_format'] = (
                                                                                                                  schema_utils.SCHEMA_TYPE_UNICODE)
                                                                                  Severity: Major
                                                                                  Found in core/domain/exp_domain.py - About 45 mins to fix

                                                                                    Avoid deeply nested control flow statements.
                                                                                    Open

                                                                                                            for contain_rule_string in contain_rule_ele:
                                                                                                                for rule_value in rule_values:
                                                                                                                    if contain_rule_string in rule_value:
                                                                                                                        invalid_rules.append(rule_spec)
                                                                                                        seen_strings_startswith.append(rule_values)
                                                                                    Severity: Major
                                                                                    Found in core/domain/exp_domain.py - About 45 mins to fix

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

                                                                                          def _choices_should_be_unique_and_non_empty(
                                                                                      Severity: Minor
                                                                                      Found in core/domain/exp_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/exp_domain.py - About 35 mins to fix

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

                                                                                              def _is_tag_removed_with_empty_content(
                                                                                                  cls,
                                                                                                  tag: bs4.BeautifulSoup,
                                                                                                  content: Union[str, List[str]],
                                                                                                  *,
                                                                                          Severity: Minor
                                                                                          Found in core/domain/exp_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

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

                                                                                              def _fix_labelled_as_correct_value_in_state_dict(
                                                                                                  cls, states_dict: Dict[str, state_domain.StateDict]
                                                                                              ) -> Dict[str, state_domain.StateDict]:
                                                                                                  """If destination is `try again` and the value of labelled_as_correct
                                                                                                      is True, replaces it with False
                                                                                          Severity: Minor
                                                                                          Found in core/domain/exp_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