SEIAROTg/autobean

View on GitHub
autobean/share/split_account.py

Summary

Maintainability
D
1 day
Test Coverage
A
93%

File split_account.py has 445 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import collections
import dataclasses
import decimal
import functools
import itertools
Severity: Minor
Found in autobean/share/split_account.py - About 6 hrs to fix

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

        def from_grouped_postings(cls, grouped_postings: _GroupedPostings) -> '_ConversionTable':
            entries_by_currency = collections.defaultdict[str, set[_UnambiguousConversionTableEntry]](set)
            no_conversion_currencies: set[str] = set()
            weighted: list[_PostingPolicy] = grouped_postings.weighted
            prorated: list[_PostingPolicy] = grouped_postings.prorated
    Severity: Minor
    Found in autobean/share/split_account.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 is_small has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def is_small(self, tolerances: decimal.Decimal | dict[str, decimal.Decimal]) -> bool:
            if isinstance(tolerances, decimal.Decimal):
                for balance in self._positions.values():
                    if abs(balance) > tolerances:
                        return False
    Severity: Minor
    Found in autobean/share/split_account.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in autobean/share/split_account.py - About 45 mins to fix

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

          def process_open_close(self, entries: list[Directive]) -> list[Directive]:
              if self._viewpoint != viewpoint_lib.EVERYONE:
                  return entries
              results = []
              for entry in entries:
      Severity: Minor
      Found in autobean/share/split_account.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 create_complement_posting has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def create_complement_posting(
      Severity: Minor
      Found in autobean/share/split_account.py - About 45 mins to fix

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

            def __init__(
        Severity: Minor
        Found in autobean/share/split_account.py - About 35 mins to fix

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

          def _check_balance(
          Severity: Minor
          Found in autobean/share/split_account.py - About 35 mins to fix

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

                def _get_split_postings(
                        self,
                        *,
                        used_subaccounts: dict[str, set[str]],
                ) -> Iterator[Posting]:
            Severity: Minor
            Found in autobean/share/split_account.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 from_transaction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def from_transaction(
                        cls,
                        transaction: Transaction,
                        policy_db: policy_lib.PolicyDatabase,
                ) -> '_GroupedPostings':
            Severity: Minor
            Found in autobean/share/split_account.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 process_balance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def process_balance(self, balance: Balance, error_logger: error_lib.ErrorLogger) -> list[Balance]:
                    if self._viewpoint == viewpoint_lib.NOBODY:
                        policy_lib.strip_share_meta(balance.meta)
                        return [balance]
                    tolerance = balance_lib.get_balance_tolerance(balance, self._options)
            Severity: Minor
            Found in autobean/share/split_account.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

            Avoid too many return statements within this function.
            Open

                    return [
            Severity: Major
            Found in autobean/share/split_account.py - About 30 mins to fix

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

                  def _process_transaction(
                          self,
                          grouped_postings: _GroupedPostings,
                  ) -> None:
                      prorated_ownership_builder = _ProratedOwnershipBuilder()
              Severity: Minor
              Found in autobean/share/split_account.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 realize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def realize(self, root: realization.RealAccount, accounts: set[str]) -> None:
                      for party, postings in self._postings_by_party.items():
                          for posting in postings:
                              if posting.account in accounts:
                                  real_account = realization.get_or_create(root, f'{posting.account}:{party}')
              Severity: Minor
              Found in autobean/share/split_account.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