benvial/gyptis

View on GitHub

Showing 211 of 211 total issues

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

    def __init__(
        self,
        model_name="geometry",
        mesh_name="mesh.msh",
        data_dir=None,
Severity: Minor
Found in src/gyptis/geometry/geometry.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 read_mesh_info has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def read_mesh_info(self):
        if self.dim == 1:
            marker_dim = "line"
            sub_dim = "curves"
            marker_dim_minus_1 = "point"
Severity: Minor
Found in src/gyptis/geometry/geometry.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 15 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

    Function _get_effective_coeff has a Cognitive Complexity of 14 (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

    Function eigensolve has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def eigensolve(
            self,
            n_eig=6,
            wavevector_target=0.0,
            tol=1e-6,
    Severity: Minor
    Found in src/gyptis/models/simulation.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 _weak has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _weak(self, u, v, u1):
            xi = self.xi.as_subdomain()
            chi = self.chi.as_subdomain()
    
            xi_dict = self.xi.as_property()
    Severity: Minor
    Found in src/gyptis/formulations/maxwell2d.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 _make_constant_property_3d has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def _make_constant_property_3d(prop, inv=False, real=False):
        new_prop = {}
        for d, p in prop.items():
            lenp = _check_len(p)
            if lenp > 0:
    Severity: Minor
    Found in src/gyptis/materials.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_T_matrix_coeff has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_T_matrix_coeff(
            self,
            p0,
            p1,
            source_type,
    Severity: Minor
    Found in src/gyptis/models/scattering3d.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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            return (form[0] + k0**2 * form[1]) * self.dx(domain)
    Severity: Major
    Found in src/gyptis/formulations/maxwell3d.py and 1 other location - About 1 hr to fix
    src/gyptis/formulations/maxwell2d.py on lines 64..64

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            return (form[0] + k0**2 * form[1]) * self.dx(domain)
    Severity: Major
    Found in src/gyptis/formulations/maxwell2d.py and 1 other location - About 1 hr to fix
    src/gyptis/formulations/maxwell3d.py on lines 54..54

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function solve has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def solve(thicknesses, eps, mu, lambda0, theta0, phi0, psi0):
        k0 = 2 * pi / lambda0
        omega = k0 * c
    
        alpha0 = -k0 * np.sin(theta0) * np.cos(phi0)
    Severity: Minor
    Found in src/gyptis/sources/stack.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    for direction in ["x", "y"]:
                        form = TwoScale2D(
                            geometry,
                            coefficients,
                            function_space,
        Severity: Major
        Found in src/gyptis/models/twoscale2d.py and 1 other location - About 1 hr to fix
        src/gyptis/models/twoscale3d.py on lines 40..50

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 44.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    for direction in ["x", "y", "z"]:
                        form = TwoScale3D(
                            geometry,
                            coefficients,
                            function_space,
        Severity: Major
        Found in src/gyptis/models/twoscale3d.py and 1 other location - About 1 hr to fix
        src/gyptis/models/twoscale2d.py on lines 40..50

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 44.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function u has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def u(x, n, m, y=None):
            y = y or sqrt_safe(1 - x**2)
            if m < 0:
                return (-1) ** (-m + 1) * u(x, n, -m)
            elif m == 0:
        Severity: Minor
        Found in src/gyptis/sources/spharm.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 tensor_const has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def tensor_const(T, dim=3, real=False, const=True):
            if dim not in (2, 3):
                raise NotImplementedError("only supports dim = 2 or 3")
        
            def _treal(T):
        Severity: Minor
        Found in src/gyptis/materials.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_periodic_bnds has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_periodic_bnds(self):
                # define lines equations
                def _is_on_line(p, p1, p2):
                    x, y = p
                    x1, y1 = p1
        Severity: Minor
        Found in src/gyptis/geometry/phc2d.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 compute_absorption has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def compute_absorption(self, subdomain_absorption=False):
                P0 = (
                    self.period[0]
                    * self.period[1]
                    * (epsilon_0 / mu_0) ** 0.5
        Severity: Minor
        Found in src/gyptis/models/grating3d.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 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def __init__(
                self,
                box_size=(1, 1),
                box_center=(0, 0),
                pml_width=(0.2, 0.2),
        Severity: Minor
        Found in src/gyptis/geometry/scattering2d.py - About 1 hr to fix

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

              def __init__(
          Severity: Major
          Found in src/gyptis/models/scattering3d.py - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language