ickc/pandoc-amsthm

View on GitHub

Showing 17 of 17 total issues

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
Severity: Minor
Found in src/amsthm/__init__.py - About 5 hrs to fix

    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.
        """
    Severity: Minor
    Found in src/amsthm/__init__.py - About 5 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 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.
        """
    Severity: Minor
    Found in src/amsthm/__init__.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 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

    Function from_doc has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_doc(
            cls,
            doc: Doc,
        ) -> DocOptions:
            options: dict[
    Severity: Minor
    Found in src/amsthm/__init__.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 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,
    Severity: Minor
    Found in src/amsthm/__init__.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 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):
    Severity: Minor
    Found in src/amsthm/__init__.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 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

    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

    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 setup_logging has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def setup_logging(
      Severity: Minor
      Found in src/amsthm/util.py - About 45 mins to fix

        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:
        Severity: Major
        Found in src/amsthm/__init__.py - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

              return None
          Severity: Major
          Found in src/amsthm/__init__.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                                return pf.Str(options.identifiers[id])
            Severity: Major
            Found in src/amsthm/__init__.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return pf.Str(f"({options.identifiers[id]})")
              Severity: Major
              Found in src/amsthm/__init__.py - About 30 mins to fix

                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:
                Severity: Minor
                Found in src/amsthm/__init__.py - About 25 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 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
                Severity: Minor
                Found in src/amsthm/__init__.py - About 25 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