File ast.py
has 1565 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import re
from dataclasses import MISSING, dataclass, field, fields
from fractions import Fraction
Function parse_data_markdown
has a Cognitive Complexity of 140 (exceeds 5 allowed). Consider refactoring. Open
def parse_data_markdown(
str_array: np.ndarray[np.str_],
fancy_table: bool = False,
ica_cell_pat=re.compile(r'^(\([0-9, ]+\))?({[^{}]*})?$'),
fancy_table_pat=re.compile(r'^({[^{}]*})?? ?(---|===|___)? ?({[^{}]*})?$'),
- 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 normalize
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def normalize(self, shape: Tuple[int, int]):
'''normalize
assume the types are correct. Normalize what's beyond type-correctness.
- 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 to_str_array
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def to_str_array(self, fancy_table: bool = False) -> np.ndarray[np.str_]:
'''construct a table with both content and ica together
'''
# prepend a column if fancy-table
offset = int(fancy_table)
- 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 simplify
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def simplify(self):
'''Reduced equivalent attrs to simplest form
e.g. from PanTableStr to PanCodeBlock should uses this
'''
- 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 auto_width
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def auto_width(
self,
override_width: bool = False,
cell_width_func: Optional[Callable[[str], int]] = cell_width_func,
):
- 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
PanTableAbstract
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class PanTableAbstract:
'''an abstract class of PanTables
'''
cells: Union[TableArray, np.ndarray[Union[ListContainer, str]]]
Function put
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def put(
self,
content: Union[ListContainer, str],
row_span: int,
col_span: int,
- 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 to_pantable
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def to_pantable(self) -> PanTable:
'''return a PanTable representation of self
'''
# * 1st pass: assemble the caches
cache_texts: Dict[Union[str, Tuple[str, int], Tuple[str, int, int]], str] = {}
- 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 __post_init__
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def __post_init__(self):
'''fall back to default if invalid type
Only check for type here. e.g. positivity of width and table_width are not checked at this point.
'''
- 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 to_pantablemarkdown
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def to_pantablemarkdown(self) -> PanTableMarkdown:
'''return a PanTableMarkdown representation of self
'''
# * 1st pass: assemble the caches
cache_elems: Dict[Union[str, Tuple[str, int], Tuple[str, int, int]], ListContainer] = {}
- 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 stringified
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def stringified(self, width: int = 15, cannonical=True) -> TableArray:
'''return stringified TableArray
:param int width: width per column
'''
- 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 __post_init__
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def __post_init__(self):
super().__post_init__()
shape = self.shape
m, n = shape
- 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_panflute_ast
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def from_panflute_ast(cls, table: Table) -> PanTable:
ica_table = Ica(
table.identifier,
table.classes,
table.attributes,
Function to_pantable
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_pantable(self) -> PanTable:
'''return a PanTable representation of self
'''
# * 1st pass: assemble the caches
cache_texts: Dict[Union[str, Tuple[str, int], Tuple[str, int, int]], str] = {}
Avoid deeply nested control flow statements. Open
if ica_:
ica = ica_
else:
Avoid deeply nested control flow statements. Open
if cell_n_new > 1:
temp[j + 1].append((width_int_resid, cell_n_new))
else:
temp[j + 1].append(width_int_resid)
Avoid deeply nested control flow statements. Open
if founds:
found = founds[0]
has_ica = True
ica_temp = found[1]
ica = f'[]{ica_temp}' if ica_temp else ''
Function put
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def put(
Function from_panflute_ast
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def from_panflute_ast(cls, table: Table) -> PanTable:
ica_table = Ica(
table.identifier,
table.classes,
table.attributes,
- 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 deeply nested control flow statements. Open
if ica_row:
icas_row[i] = f'[]{ica_row}'
else:
Avoid deeply nested control flow statements. Open
if body_list and 'body' not in last_body:
last_body['body'] = temp
else:
body_list.append({'body': temp})
# is_body_head
Avoid deeply nested control flow statements. Open
if marker:
temp_markers.append(marker)
temp_icas.append(found[0])
temp_idxs.append(i)
# * ignore the case that somone might put 2 attrs side-by-side
Avoid deeply nested control flow statements. Open
if ica_:
ica = ica_
else:
Function to_spec
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_spec(self, size: int) -> Spec:
'''to Spec
assume normalized self.
'''
- 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 to_pantable
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_pantable(self) -> PanTable:
'''return a PanTable representation of self
'''
cells = self.cells
contents = cells.contents
- 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 to_panflute_ast
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_panflute_ast(self) -> CodeBlock:
'''return a panflute AST representation
TODO: handle differently if include exists and writable
need to be able to configure pantable2csv on write location
- 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 cannonical
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cannonical(self) -> TableArray:
'''return a cell array where spanned cells appeared in cannonical location only
top-left corner of the grid is the cannonical location of a spanned cell
'''
- 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 panflute_tablecells
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def panflute_tablecells(self) -> np.ndarray[TableCell]:
cells = self.cells
contents = cells.contents
shape = contents.shape
m, n = shape
- 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"