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");
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[
- Read upRead up
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.
- Read upRead up
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],
*,
- Read upRead up
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__(
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.
- Read upRead up
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__(
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
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.
- Read upRead up
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(
Function validate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def validate(
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
Function convert_html_fields_in_state
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def convert_html_fields_in_state(
Function validate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def validate(
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function create_default_state
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_default_state(
Avoid too many return
statements within this function. Open
return True
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.
- Read upRead up
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"