weblyzard/inscriptis

View on GitHub

Showing 15 of 15 total issues

File run_benchmarking.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# coding:utf-8
"""
Runs a benchmarking suite to compare speed
and output of different implementations.
Severity: Minor
Found in benchmarking/run_benchmarking.py - About 4 hrs to fix

    Function __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in src/inscriptis/model/html_element.py - About 1 hr to fix

      Function __call__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, annotated_text: Dict[str, Any]) -> str:
              tag_indices = defaultdict(list)
      
              for start, end, label in sorted(annotated_text["label"]):
                  tag_indices[start].append(label)
      Severity: Minor
      Found in src/inscriptis/annotation/output/html.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 cli has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def cli() -> None:
          """Run the inscript command line client."""
          args = parse_command_line()
          if not (html_content := get_html_content(args.input, args.timeout, args.encoding)):
              print("ERROR: Cannot open input file '{0}'.".format(args.input))
      Severity: Minor
      Found in src/inscriptis/cli/inscript.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 benchmark has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def benchmark(args, source_list):
          """
          Run the benchmark.
      
          Args:
      Severity: Minor
      Found in benchmarking/run_benchmarking.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in src/inscriptis/model/config.py - About 1 hr to fix

        Function get_annotations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_annotations(self, idx: int, row_width: int) -> List[Annotation]:
                """Return a list of all annotations within the TableCell.
        
                Returns:
                    A list of annotations that have been adjusted to the cell's
        Severity: Minor
        Found in src/inscriptis/model/table.py - About 55 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 _parse_html_tree has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _parse_html_tree(self, state: HtmlDocumentState, tree) -> Canvas:
                """Parse the HTML tree.
        
                Args:
                    tree: the HTML tree to parse.
        Severity: Minor
        Found in src/inscriptis/html_engine.py - About 55 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 close_tag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def close_tag(self, tag: HtmlElement) -> None:
                """Register that the given tag tag is closed.
        
                Args:
                    tag: the tag to close.
        Severity: Minor
        Found in src/inscriptis/model/canvas/__init__.py - About 55 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 _parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def _parse(model: dict) -> Tuple[Dict, List]:
                """Compute the AnnotationModel from a model dictionary.
        
                Returns:
                    the AnnotationModel matching the input dictionary.
        Severity: Minor
        Found in src/inscriptis/annotation/parser.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 get_refined_html_element has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_refined_html_element(self, new: "HtmlElement") -> "HtmlElement":
                """Compute the new HTML element based on the previous one.
        
                Adaptations:
                    margin_top: additional margin required when considering
        Severity: Minor
        Found in src/inscriptis/model/html_element.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 horizontal_shift has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def horizontal_shift(
        Severity: Minor
        Found in src/inscriptis/annotation/__init__.py - About 35 mins to fix

          Function merge_normal_text has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def merge_normal_text(self, text: str) -> None:
                  """Merge the given text with the current block.
          
                  Args:
                      text: the text to merge
          Severity: Minor
          Found in src/inscriptis/model/canvas/block.py - About 35 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 _set_column_width has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _set_column_width(self):
                  """Set the column width for all :class:`TableCell`s in the table."""
                  # determine maximum number of columns
                  max_columns = max((len(row.columns) for row in self.rows))
          
          
          Severity: Minor
          Found in src/inscriptis/model/table.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 get_annotations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_annotations(self, idx: int, left_margin_len: int) -> List[Annotation]:
                  r"""Return all annotations in the given table.
          
                  Args:
                      idx: the table's start index.
          Severity: Minor
          Found in src/inscriptis/model/table.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