File __init__.py
has 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import re
from collections import defaultdict
from dataclasses import dataclass, field
Function amsthm
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def amsthm(elem: Element, doc: Doc) -> None:
"""General amsthm transformation working for all document types.
Essentially we replicate LaTeX amsthm behavior in this filter.
"""
- 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 resolve_ref
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def resolve_ref(elem: Element, doc: Doc) -> pf.Str | None:
"""Resolve references to theorem numbers.
Consider this as post-process ref for general output formats.
"""
- 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_doc
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def from_doc(
cls,
doc: Doc,
) -> DocOptions:
options: dict[
- 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_theorem_header
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def to_panflute_theorem_header(
self,
options: DocOptions,
id: str | None,
info: str | None,
- 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 amsthm_latex
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def amsthm_latex(elem: Element, doc: Doc) -> pf.RawBlock | None:
"""Transform amsthm defintion to LaTeX package specifications."""
# check if it is a Div, and the class is an amsthm environment
options: DocOptions = doc._amsthm
if isinstance(elem, pf.Div):
- 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 isinstance(value, list):
for v in value:
theorem = NewTheorem(style, v, text=name_to_text.get(v, ""), shared_counter=key)
theorems[theorem.class_name] = theorem
else:
Avoid too many return
statements within this function. Open
return None
Avoid too many return
statements within this function. Open
return pf.Str(options.identifiers[id])
Avoid too many return
statements within this function. Open
return pf.Str(f"({options.identifiers[id]})")
Function latex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def latex(self) -> str:
res = [r"\newtheorem"]
if not self.numbered:
res.append(f"*{{{self.env_name}}}{{{self.text}}}")
elif self.shared_counter is None:
- 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 latex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def latex(self) -> str:
cur_style: str = ""
res: list[str] = []
for theorem in self.theorems.values():
# proof is predefined in amsthm
- 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"