ickc/pandoc-amsthm

View on GitHub
src/amsthm/helper.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function merge_consecutive_type has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def merge_consecutive_type(
    elem: Element,
    doc: Doc,
    ElementType: type[EmphLike] = pf.Emph,
) -> list[EmphLike] | None:
Severity: Minor
Found in src/amsthm/helper.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

Avoid deeply nested control flow statements.
Open

                    if isinstance(elem_next_next, ElementType):
                        merged = list(elem_cur.content) + [pf.Space] + list(elem_next_next.content)
                        content = list(content[:i]) + [ElementType(*merged)] + list(content[i + 3 :])
                        mutated = True
        if mutated:
Severity: Major
Found in src/amsthm/helper.py - About 45 mins to fix

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

    def cancel_repeated_type(
        elem: Element,
        doc: Doc,
        ElementType: type[EmphLike] = pf.Emph,
    ) -> list[EmphLike] | None:
    Severity: Minor
    Found in src/amsthm/helper.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 cite_to_ref has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def cite_to_ref(elem: pf.Cite, doc: Doc, check_id: dict[str, str] | None = None) -> pf.RawInline | None:
        """Cite to raw LaTeX ref/eqref.
    
        :param check_id: if provided, transform only if id is in `check_id`
    
    
    Severity: Minor
    Found in src/amsthm/helper.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

    There are no issues that match your filters.

    Category
    Status