benvial/gyptis

View on GitHub

Showing 160 of 202 total issues

Function _adaptive_sampler has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

def _adaptive_sampler(f, z0, max_bend=10, max_z_rel=1e-3, max_df=0.05):

    z0 = np.sort(z0)
    zmin = min(z0)
    zmax = max(z0)
Severity: Minor
Found in src/gyptis/utils/sample.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

File geometry.py has 533 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
# License: MIT
Severity: Major
Found in src/gyptis/geometry/geometry.py - About 1 day to fix

    File materials.py has 417 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
    # License: MIT
    Severity: Minor
    Found in src/gyptis/materials.py - About 6 hrs to fix

      Function diffraction_efficiencies has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def diffraction_efficiencies(
              self,
              N_d_order=0,
              cplx_effs=False,
              orders=False,
      Severity: Minor
      Found in src/gyptis/models/grating3d.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

      File stack.py has 371 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
      # License: MIT
      Severity: Minor
      Found in src/gyptis/sources/stack.py - About 4 hrs to fix

        File grating2d.py has 328 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
        # License: MIT
        Severity: Minor
        Found in src/gyptis/models/grating2d.py - About 3 hrs to fix

          Function minimize has a Cognitive Complexity of 24 (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

          Geometry has 28 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Geometry:
              """Base class for geometry models."""
          
              def __init__(
                  self,
          Severity: Minor
          Found in src/gyptis/geometry/geometry.py - About 3 hrs to fix

            File optimize.py has 296 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
            # License: MIT
            Severity: Minor
            Found in src/gyptis/optimize.py - About 3 hrs to fix

              Function diffraction_efficiencies has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  def diffraction_efficiencies(
                      self,
                      N_order=0,
                      cplx_effs=False,
                      orders=False,
              Severity: Minor
              Found in src/gyptis/models/grating2d.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

              Complex has 26 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Complex:
                  """A complex object.
              
                  Parameters
                  ----------
              Severity: Minor
              Found in src/gyptis/complex.py - About 3 hrs to fix

                Function make_stack has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                def make_stack(
                    geometry,
                    coefficients,
                    plane_wave,
                    polarization="TM",
                Severity: Minor
                Found in src/gyptis/sources/stack.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 _topopt_wrapper has a Cognitive Complexity of 20 (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

                File complex.py has 280 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
                # License: MIT
                Severity: Minor
                Found in src/gyptis/complex.py - About 2 hrs to fix

                  Function __init__ has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def __init__(
                          self,
                          box_size=(1, 1, 1),
                          box_center=(0, 0, 0),
                          pml_width=(0.2, 0.2, 0.2),
                  Severity: Major
                  Found in src/gyptis/geometry/scattering3d.py - About 2 hrs to fix

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

                    def read_mesh(mesh_file, data_dir=None, data_dir_xdmf=None, dim=3, subdomains=None):
                        data_dir_xdmf = data_dir_xdmf or tempfile.mkdtemp()
                        meshio_mesh = meshio.read(mesh_file)
                        base_cell_type = "tetra" if dim == 3 else "triangle"
                    
                    
                    Severity: Minor
                    Found in src/gyptis/mesh/mesh.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

                    File scattering3d.py has 254 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
                    # License: MIT
                    Severity: Minor
                    Found in src/gyptis/models/scattering3d.py - About 2 hrs to fix

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

                      def postpro_download_links(fn):
                          sgfoot = None
                          with open(fn, "r") as file:
                              soup = BeautifulSoup(file, "html.parser")
                          for item in soup.findAll(["div"]):
                      Severity: Minor
                      Found in docs/postprocess.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 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def __init__(
                              self,
                              vectors,
                              periodic_tol=1e-8,
                              **kwargs,
                      Severity: Minor
                      Found in src/gyptis/geometry/phc3d.py - About 1 hr to fix

                        Function _get_effective_coeff has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _get_effective_coeff(self, case, scalar=False):
                                self.solve_param(case, scalar=scalar)
                                xi = self.formulation.xi.as_subdomain()
                                if xi.real.ufl_shape == (2, 2):
                                    if scalar:
                        Severity: Minor
                        Found in src/gyptis/models/twoscale2d.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

                        Severity
                        Category
                        Status
                        Source
                        Language