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
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
- Read upRead up
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
- Read upRead up
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(
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
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:
- Read upRead up
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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function _check_balance
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _check_balance(
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)
- Read upRead up
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':
- Read upRead up
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_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]:
- Read upRead up
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 [
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}')
- Read upRead up
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_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()
- Read upRead up
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"