SEIAROTg/autobean

View on GitHub

Showing 46 of 46 total issues

File policy_lib_test.py has 514 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import decimal
import textwrap
from typing import Any, Callable, Iterator, Optional, TypeVar
from beancount.parser import parser
from beancount.core.data import Balance, Custom, Directive, Transaction
Severity: Major
Found in autobean/share/policy_lib_test.py - About 1 day to fix

    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

      File importer.py has 409 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import datetime
      from decimal import Decimal
      import http.server
      import logging
      import os
      Severity: Minor
      Found in autobean/truelayer/importer.py - About 5 hrs to fix

        Function deduplicate has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        def deduplicate(
                new_entries: list[Directive],
                existing_entries: list[Directive],
                window_days: int = 10) -> list[Directive]:
            """De-duplicate entries.
        Severity: Minor
        Found in autobean/utils/deduplicate.py - About 4 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 check_file_entries has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def check_file_entries(entries: list[Directive]) -> list[error_lib.Error]:
            """Checks entries are in order and finds out-of-order entries.
        
            We find a longest non-descending subsequence and assumes all other
            entries are out-of-order.
        Severity: Minor
        Found in autobean/sorted/plugin.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 plugin has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        def plugin(entries: list[Directive], options: dict[str, Any]) -> tuple[list[Directive], list[error_lib.Error]]:
            entries_by_file: defaultdict[str | None, list[Directive]] = defaultdict(list)
            ignored_files: set[str] = set()
            errors: list[error_lib.Error] = []
            for entry in entries:
        Severity: Minor
        Found in autobean/sorted/plugin.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 try_parse_policy_definition has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        def try_parse_policy_definition(meta: Optional[dict[str, Any]]) -> Optional[PolicyDefinition]:
            if not meta:
                return None
            weights = {}
            for key, value in meta.items():
        Severity: Minor
        Found in autobean/share/policy_lib.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 _get_args has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def _get_args(
                values: list[grammar.ValueType],
                handler: _CustomHandler,
        ) -> Optional[list[Any]]:
            queue = values[::-1]
        Severity: Minor
        Found in autobean/utils/plugin_lib.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 _get_arg has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def _get_arg(annotation: Any, queue: list[grammar.ValueType]) -> Optional[Any]:
            if not queue:
                return None
            value = queue.pop()
            if get_origin(annotation) is Union:
        Severity: Minor
        Found in autobean/utils/plugin_lib.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 _process_entry has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def _process_entry(self, entry: Directive) -> Iterator[Directive]:
                if isinstance(entry, Custom) and (handlers := self._CUSTOM_HANDLERS.get(entry.type)):
                    for chandler in handlers:
                        if (args := _get_args(entry.values or [], chandler)) is not None:
                            with _wrap_plugin_exception(entry, self._error_logger):
        Severity: Minor
        Found in autobean/utils/plugin_lib.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 load_test_suite has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def load_test_suite(tests_path: str, suite: str) -> tuple[list[str], list[Testcase]]:
            full_path = os.path.join(tests_path, suite)
            ids = list[str]()
            testcases = list[Testcase]()
            if not os.path.isdir(full_path) or suite.startswith('.') or suite.startswith('_'):
        Severity: Minor
        Found in autobean/utils/plugin_test_utils.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 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 deduplicate_open_close has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def deduplicate_open_close(entries: list[Directive]) -> list[Directive]:
            """Deduplicates Open / Close directives.
            
            This deduplicates Open / Close directives in a simple way because duplication inside each file should have been
            caught during loading.
        Severity: Minor
        Found in autobean/share/include.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 _override_policy_def has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def _override_policy_def(
                policy_def: PolicyDefinition,
                parent: Optional[PolicyDefinition],
                *,
                is_ephemeral: bool,
        Severity: Minor
        Found in autobean/share/policy_lib.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 merge_narration has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def merge_narration(entry: Directive, comment_narrations: dict[str, dict[int, str]]) -> Directive:
            if not isinstance(entry, Transaction):
                return entry
            narrations = []
            for posting in entry.postings:
        Severity: Minor
        Found in autobean/narration/plugin.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 subgraphs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def subgraphs(self) -> Iterable[set[_Node]]:
                visited = set()
                for new_node in self._new_nodes:
                    if new_node in visited:
                        continue
        Severity: Minor
        Found in autobean/utils/deduplicate.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 test_ok has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def test_ok() -> None:
            entries, errors = load(_FOO_TEXT)
            assert not errors
            txn = entries[-15]
            assert isinstance(txn, Transaction)
        Severity: Minor
        Found in autobean/stock_split/plugin_test.py - About 1 hr to fix

          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 get_balance_policy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_balance_policy(self, balance: Balance) -> Optional[Policy[WeightedOwnership]]:
                  has_explicit_policy = False
                  balance_policy_def = try_parse_policy_definition(balance.meta)
                  if balance_policy_def:
                      balance_policy_def = self._resolve_parent(balance_policy_def)
          Severity: Minor
          Found in autobean/share/policy_lib.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 assert_same_errors has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def assert_same_errors(actuals: list[error_lib.Error], expecteds: ExpectedErrors) -> None:
              actual_errors = ExpectedErrors()
              matched_expected_errors = ExpectedErrors()
              unmatched_expected_errors = copy.deepcopy(expecteds)
              for actual in actuals:
          Severity: Minor
          Found in autobean/utils/plugin_test_utils.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

          Severity
          Category
          Status
          Source
          Language