benvial/gyptis

View on GitHub
src/gyptis/materials.py

Summary

Maintainability
D
2 days
Test Coverage

File materials.py has 389 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/materials.py - About 5 hrs to fix

    Function _make_constant_property_2d has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def _make_constant_property_2d(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 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 _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 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 _make_tensor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def _make_tensor(mapping):
        mapping_tens = mapping.copy()
        N = max(len(v) for v in mapping.values() if isiter(v))
        idf = np.eye(N).tolist()
        for k, v in mapping.items():
    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

    Avoid deeply nested control flow statements.
    Open

                        if callable(k):
                            const = False
                            break
                # if p.shape != (2, 2):
                #     p = p[:2][:2]
    Severity: Major
    Found in src/gyptis/materials.py - About 45 mins to fix

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

          def __init__(self, dict, geometry=None, pmls=None, dim=2, degree=1, element=None):
      Severity: Minor
      Found in src/gyptis/materials.py - About 45 mins to fix

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

            def __init__(self, markers, subdomains, mapping, *args, **kwargs):
        Severity: Minor
        Found in src/gyptis/materials.py - About 45 mins to fix

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

              def __new__(cls, markers, subdomains, mapping, cpp=True, **kwargs):
          Severity: Minor
          Found in src/gyptis/materials.py - About 35 mins to fix

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

                def __new__(cls, markers, subdomains, mapping, cpp=True, **kwargs):
            Severity: Minor
            Found in src/gyptis/materials.py - About 35 mins to fix

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

                  def __new__(cls, markers, subdomains, mapping, cpp=True, **kwargs):
              Severity: Minor
              Found in src/gyptis/materials.py - About 35 mins to fix

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

                    def __new__(self, markers, subdomains, mapping, cpp=True, **kwargs):
                Severity: Minor
                Found in src/gyptis/materials.py - About 35 mins to fix

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

                      def __new__(self, markers, subdomains, mapping, cpp=True, **kwargs):
                  Severity: Minor
                  Found in src/gyptis/materials.py - About 35 mins to fix

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

                        def jacobian_matrix(self):
                            if self.direction == "x":
                                s = self.stretch, 1, 1
                            elif self.direction == "y":
                                s = 1, self.stretch, 1
                    Severity: Minor
                    Found in src/gyptis/materials.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 __new__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def __new__(cls, markers, subdomains, mapping, cpp=True, **kwargs):
                            iterable = any(isiter(v) for v in mapping.values())
                            flatvals = _flatten_list(mapping.values())
                            cplx = any(iscomplex(v) and np.any(v.imag != 0) for v in flatvals)
                            if iterable:
                    Severity: Minor
                    Found in src/gyptis/materials.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 eval_cell has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def eval_cell(self, values, x, cell):
                            for sub, val in self.mapping.items():
                                if self.markers[cell.index] == self.subdomains[sub]:
                                    values[:] = val(x) if callable(val) else val
                    
                    
                    Severity: Minor
                    Found in src/gyptis/materials.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

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

                        def __init__(self, dict, geometry=None, pmls=None, dim=2, degree=1, element=None):
                            if pmls is None:
                                pmls = []
                            self.dict = dict
                            self.geometry = geometry
                    Severity: Minor
                    Found in src/gyptis/materials.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

                    There are no issues that match your filters.

                    Category
                    Status