benvial/gyptis

View on GitHub
src/gyptis/optimize.py

Summary

Maintainability
D
1 day
Test Coverage

Function minimize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def minimize(self, x0):
        self.x0 = x0
        if self.verbose:
            mpi_print("#################################################")
            mpi_print(f"Topology optimization with {self.nvar} variables")
Severity: Minor
Found in src/gyptis/optimize.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

File optimize.py has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Benjamin Vial
# This file is part of gyptis
# Version: 1.0.2
Severity: Minor
Found in src/gyptis/optimize.py - About 2 hrs to fix

    Function _topopt_wrapper has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def _topopt_wrapper(
            self,
            objfun,
            Asub,
            Actrl,
    Severity: Minor
    Found in src/gyptis/optimize.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 15 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in src/gyptis/optimize.py - About 1 hr to fix

      Function _topopt_wrapper has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _topopt_wrapper(
      Severity: Major
      Found in src/gyptis/optimize.py - About 1 hr to fix

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

            def __init__(
        Severity: Minor
        Found in src/gyptis/optimize.py - About 45 mins to fix

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

          def filtering(a, rfilt=0, function_space=None, degree=1, solver=None, mesh=None):
          Severity: Minor
          Found in src/gyptis/optimize.py - About 45 mins to fix

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

            def transfer_sub_mesh(x, geometry, source_space, target_space, subdomain):
            Severity: Minor
            Found in src/gyptis/optimize.py - About 35 mins to fix

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

              def simp(a, s_min=1, s_max=2, p=1, complex=True):
              Severity: Minor
              Found in src/gyptis/optimize.py - About 35 mins to fix

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

                    def weak(self, a):
                        self.mesh = a.function_space().mesh() if self._mesh is None else self._mesh
                        self.dim = self.mesh.ufl_domain().geometric_dimension()
                        self.function_space = self._function_space or df.FunctionSpace(
                            self.mesh, "CG", self.degree
                Severity: Minor
                Found in src/gyptis/optimize.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

                There are no issues that match your filters.

                Category
                Status