benvial/gyptis

View on GitHub
src/gyptis/geometry/geometry.py

Summary

Maintainability
F
3 days
Test Coverage

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

    Geometry has 31 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

      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 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 __init__ has 32 lines of code (exceeds 25 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

        Function set_mesh_size has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def set_mesh_size(self, params, dim=None):
                dim = self._check_dim(dim)
                if dim == 3:
                    type_entity = "volumes"
                elif dim == 2:
        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 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

          Function _build_serial has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _build_serial(
          Severity: Major
          Found in src/gyptis/geometry/geometry.py - About 50 mins to fix

            Function fragment has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def fragment(self, id1, id2, dim1=None, dim2=None, sync=True, map=False, **kwargs):
            Severity: Major
            Found in src/gyptis/geometry/geometry.py - About 50 mins to fix

              Function intersect has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def intersect(self, id1, id2, dim1=None, dim2=None, sync=True, map=False, **kwargs):
              Severity: Major
              Found in src/gyptis/geometry/geometry.py - About 50 mins to fix

                Function add_ellipse has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def add_ellipse(self, x, y, z, ax, ay, surface=True, **kwargs):
                Severity: Major
                Found in src/gyptis/geometry/geometry.py - About 50 mins to fix

                  Function build has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def build(
                  Severity: Major
                  Found in src/gyptis/geometry/geometry.py - About 50 mins to fix

                    Function get_boundaries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_boundaries(self, idf, dim=None, physical=True):
                            dim = self._check_dim(dim)
                            if isinstance(idf, str):
                                if dim == 2:
                                    type_entity = "surfaces"
                    Severity: Minor
                    Found in src/gyptis/geometry/geometry.py - About 45 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 cut has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def cut(self, id1, id2, dim1=None, dim2=None, sync=True, **kwargs):
                    Severity: Minor
                    Found in src/gyptis/geometry/geometry.py - About 45 mins to fix

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

                          def add_circle(self, x, y, z, r, surface=True, **kwargs):
                      Severity: Minor
                      Found in src/gyptis/geometry/geometry.py - About 45 mins to fix

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

                        def is_on_plane(P, A, B, C, eps=dolfin.DOLFIN_EPS):
                        Severity: Minor
                        Found in src/gyptis/geometry/geometry.py - About 35 mins to fix

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

                              def fuse(self, id1, id2, dim1=None, dim2=None, sync=True):
                          Severity: Minor
                          Found in src/gyptis/geometry/geometry.py - About 35 mins to fix

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

                                def rotate(self, tag, point, axis, angle, dim=None):
                            Severity: Minor
                            Found in src/gyptis/geometry/geometry.py - About 35 mins to fix

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

                                  def add_square(self, x, y, z, dx, **kwargs):
                              Severity: Minor
                              Found in src/gyptis/geometry/geometry.py - About 35 mins to fix

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

                                    def set_size(self, idf, s, dim=None):
                                        if hasattr(idf, "__len__") and not isinstance(idf, str):
                                            for i, id_ in enumerate(idf):
                                                s_ = s[i] if hasattr(s, "__len__") else s
                                                params = {id_: s_}
                                Severity: Minor
                                Found in src/gyptis/geometry/geometry.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 _check_subdomains has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def _check_subdomains(self):
                                        groups = self.model.getPhysicalGroups()
                                        names = [self.model.getPhysicalName(*g) for g in groups]
                                        for subtype, subitems in self.subdomains.items():
                                            for idf in subitems.copy().keys():
                                Severity: Minor
                                Found in src/gyptis/geometry/geometry.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 read_mesh_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def read_mesh_file(self, subdomains=None):
                                        if subdomains is not None:
                                            if isinstance(subdomains, str):
                                                subdomains = [subdomains]
                                            key = "volumes" if self.dim == 3 else "surfaces"
                                Severity: Minor
                                Found in src/gyptis/geometry/geometry.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