MiraGeoscience/geoapps-utils

View on GitHub

Showing 16 of 16 total issues

Function update_object_options has a Cognitive Complexity of 27 (exceeds 6 allowed). Consider refactoring.
Open

    def update_object_options(
        self,
        ui_json_data: dict,
        filename: str,
        contents: str,
Severity: Minor
Found in geoapps_utils/application/dash_application.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_component has a Cognitive Complexity of 26 (exceeds 6 allowed). Consider refactoring.
Open

    def _init_component(
        comp: Component, ui_json_data: dict, kwargs: dict | None = None
    ):
        """
        Initialize dash component from ui_json_data.
Severity: Minor
Found in geoapps_utils/application/dash_application.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 get_params_dict has a Cognitive Complexity of 21 (exceeds 6 allowed). Consider refactoring.
Open

    def get_params_dict(self, update_dict: dict) -> dict:
        """
        Get dict of current params.

        :param update_dict: Dict of parameters with new values to convert to a params dict.
Severity: Minor
Found in geoapps_utils/application/dash_application.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 get_data_options has a Cognitive Complexity of 20 (exceeds 6 allowed). Consider refactoring.
Open

    def get_data_options(
        self,
        ui_json_data: dict,
        object_uid: str | None,
        object_name: str = "objects",
Severity: Minor
Found in geoapps_utils/application/dash_application.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 find_value has a Cognitive Complexity of 18 (exceeds 6 allowed). Consider refactoring.
Open

def find_value(labels: list, keywords: list, default=None) -> list:
    """
    Find matching keywords within a list of labels.

    :param labels: List of labels or list of [key, value] that may contain the keywords.
Severity: Minor
Found in geoapps_utils/iterables.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 update has a Cognitive Complexity of 18 (exceeds 6 allowed). Consider refactoring.
Open

    def update(self, params_dict: dict[str, Any]):
        """
        Update parameters with dictionary contents.

        :param params_dict: Dictionary of parameters.
Severity: Minor
Found in geoapps_utils/driver/params.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 free_parameter_dict has a Cognitive Complexity of 17 (exceeds 6 allowed). Consider refactoring.
Open

    def free_parameter_dict(self) -> dict:
        """
        Extract groups of free parameters from the ui_json dictionary that match
        the 'free_parameter_identifier' and 'free_parameter_keys'.

Severity: Minor
Found in geoapps_utils/driver/params.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 _copy_property_groups has a Cognitive Complexity of 15 (exceeds 6 allowed). Consider refactoring.
Open

    def _copy_property_groups(source_groups: list[ObjectBase], param_dict: dict):
        """Copy any property groups over to param_dict of temporary workspace"""
        temp_prop_groups = param_dict["objects"].property_groups
        for group in source_groups:
            if not isinstance(group, PropertyGroup):
Severity: Minor
Found in geoapps_utils/application/dash_application.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 sorted_children_dict has a Cognitive Complexity of 10 (exceeds 6 allowed). Consider refactoring.
Open

def sorted_children_dict(
    entity: UUID | Entity, workspace: Workspace | None = None
) -> dict[str, UUID] | None:
    """
    Uses natural sorting algorithm to order the keys of a dictionary containing
Severity: Minor
Found in geoapps_utils/iterables.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

                        if key not in label.lower():
                            raise ValueError(
                                f"Malformed input refinement group {group}. "
                                f"Must contain forms for all "
                                f"of {self._free_parameter_keys} in this order."
Severity: Major
Found in geoapps_utils/driver/params.py - About 45 mins to fix

    Function weighted_average has 8 arguments (exceeds 6 allowed). Consider refactoring.
    Open

    def weighted_average(  # pylint: disable=too-many-arguments, too-many-locals
    Severity: Major
    Found in geoapps_utils/numerical.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for elem in utils.collect(
                                  self.ui_json, "group", self.ui_json[key]["group"]
                              ):
                                  setattr(self, elem, None)
      
      
      Severity: Major
      Found in geoapps_utils/driver/params.py - About 45 mins to fix

        Function __init__ has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring.
        Open

            def __init__(
                self,
                ui_json: InputFile | None = None,
                ui_json_data: dict | None = None,
                params: BaseParams | None = None,
        Severity: Minor
        Found in geoapps_utils/application/dash_application.py - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function collect_input_from_dict has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring.
        Open

            def collect_input_from_dict(
                base_model: BaseModel, data: dict[str, Any]
            ) -> dict[str, dict | Any]:
                """
                Recursively replace BaseModel objects with dictionary of 'data' values.
        Severity: Minor
        Found in geoapps_utils/driver/data.py - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Avoid too many return statements within this function.
        Open

                        return
        Severity: Major
        Found in geoapps_utils/application/dash_application.py - About 30 mins to fix

          Function get_locations has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
          Open

          def get_locations(workspace: Workspace, entity: UUID | Points | GridObject | Data):
              """
              Returns entity's centroids or vertices.
          
              If no location data is found on the provided entity, the method will
          Severity: Minor
          Found in geoapps_utils/locations.py - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Severity
          Category
          Status
          Source
          Language