mardiros/fastlife

View on GitHub

Showing 15 of 73 total issues

File configurator.py has 499 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
The configurator registers routes in a FastAPI application while
adding support for dependency injection during the configuration phase.

FastAPI does not provide any built-in support for dependency injection
Severity: Minor
Found in src/fastlife/config/configurator.py - About 1 day to fix

    Function from_payload has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_payload(
            cls, prefix: str, pydantic_type: type[T], data: Mapping[str, Any]
        ) -> "FormModel[T]":
            try:
                return cls(prefix, pydantic_type(**data.get(prefix, {})), {}, True)
    Severity: Minor
    Found in src/fastlife/request/form.py - About 6 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 unflatten_struct has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    def unflatten_struct(
        flatten_input: Mapping[str, Any],
        unflattened_output: MutableMapping[str, Any] | MutableSequence[Any],
        level: int = 0,
        *,
    Severity: Minor
    Found in src/fastlife/request/form_data.py - About 6 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 a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, client: "WebTestClient", origin: str, form: "Element"):
            self._client = client
            self._form = form
            self._origin = origin
            self._formfields: dict[str, Element] = {}
    Severity: Minor
    Found in src/fastlife/testing/form.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

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

    def generate_docstring(
        func_def: ast.FunctionDef, component_name: str, add_content: bool
    ) -> str:
        """Generate a docstring for a JinjaX component."""
        # Extract function name and docstring
    Severity: Minor
    Found in src/fastlife/adapters/jinjax/jinjax_ext/docstring.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 run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self) -> list[nodes.Node]:
            """Generate structured and styled documentation for the directive."""
            container_node = nodes.container(classes=["jinjax-component"])
    
            # Extract the signature (first line of arguments)
    Severity: Minor
    Found in src/fastlife/adapters/jinjax/jinjax_ext/jinjax_doc.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 iter_all_by_text has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def iter_all_by_text(
            self, text: str, *, node_name: str | None = None
        ) -> "Iterator[Element]":
            """Return an iterator of all elements that match the text."""
            nodes = self._tag.find_all(string=re.compile(rf"\s*{text}\s*"))
    Severity: Minor
    Found in src/fastlife/testing/dom.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 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in src/fastlife/adapters/jinjax/jinjax_ext/inspectable_component.py - About 1 hr to fix

      Function as_def has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def as_def(self) -> ast.FunctionDef:
              """Return the component definition as a python function definition."""
              signature = "def component(): pass"
              match = RX_META_HEADER.match(self.source)
              if match:
      Severity: Minor
      Found in src/fastlife/adapters/jinjax/jinjax_ext/inspectable_component.py - About 55 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 create_ref_node has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_ref_node(arg_type: str) -> nodes.Node:
          """
          Creates a cross-reference node if a type has been inferred.
      
          At the monent, type inferred are types containing a `.`, otherwise
      Severity: Minor
      Found in src/fastlife/adapters/jinjax/jinjax_ext/jinjax_doc.py - About 55 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 get_widget has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def get_widget(
      Severity: Major
      Found in src/fastlife/adapters/jinjax/widget_factory/factory.py - About 50 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if is_union(typ):
                                        args = typ.__args__
                                        for arg in args:
                                            if arg.__name__ == part:
                                                typ = arg
        Severity: Major
        Found in src/fastlife/request/form.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if "selected" in option.attrs:
                                      self._formdata[fieldname] = option.attrs.get(
                                          "value", option.text
                                      )
                                      break
          Severity: Major
          Found in src/fastlife/testing/form.py - About 45 mins to fix

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

            def unflatten_struct(
            Severity: Minor
            Found in src/fastlife/request/form_data.py - About 35 mins to fix

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

                  def post(
              Severity: Minor
              Found in src/fastlife/testing/testclient.py - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language