HazyResearch/fonduer

View on GitHub

Showing 134 of 224 total issues

File pdf_visual_parser.py has 304 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Fonduer visual parser that parses visual information from PDF."""
import logging
import os
import re
import shutil
Severity: Minor
Found in src/fonduer/parser/visual_parser/pdf_visual_parser.py - About 3 hrs to fix

    Function get_head_ngrams has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_head_ngrams(
        mention: Union[Candidate, Mention, TemporarySpanMention],
        axis: Optional[str] = None,
        attrib: str = "words",
        n_min: int = 1,
    Severity: Minor
    Found in src/fonduer/utils/data_model_utils/tabular.py - About 2 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

    File featurizer.py has 278 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Fonduer featurizer."""
    import itertools
    import logging
    from collections import defaultdict
    from typing import (
    Severity: Minor
    Found in src/fonduer/features/featurizer.py - About 2 hrs to fix

      File implicit_span_mention.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Fonduer implicit span mention model."""
      from typing import Any, Dict, List, Optional, Type
      
      from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
      from sqlalchemy.dialects import postgresql
      Severity: Minor
      Found in src/fonduer/candidates/models/implicit_span_mention.py - About 2 hrs to fix

        Function save_model has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def save_model(
            fonduer_model: FonduerModel,
            path: str,
            preprocessor: DocPreprocessor,
            parser: Parser,
        Severity: Minor
        Found in src/fonduer/packaging/fonduer_model.py - About 2 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 create_task has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def create_task(
            task_names: Union[str, List[str]],
            n_arities: Union[int, List[int]],
            n_features: int,
            n_classes: Union[int, List[int]],
        Severity: Minor
        Found in src/fonduer/learning/task.py - About 2 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 f has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def f(self, m: TemporaryContext) -> bool:
                """Non-composed version of filter function f."""
                if not isinstance(m, TemporarySpanMention):
                    raise ValueError(
                        f"{self.__class__.__name__} only supports TemporarySpanMention"
        Severity: Minor
        Found in src/fonduer/candidates/matchers.py - About 2 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

        File candidates.py has 267 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Fonduer candidate."""
        import logging
        from builtins import range
        from itertools import product
        from typing import (
        Severity: Minor
        Found in src/fonduer/candidates/candidates.py - About 2 hrs to fix

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

              def __init__(
          Severity: Major
          Found in src/fonduer/parser/parser.py - About 2 hrs to fix

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

                def __init__(
            Severity: Major
            Found in src/fonduer/candidates/models/implicit_span_mention.py - About 2 hrs to fix

              File sentence.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """Fonduer sentence context model."""
              from builtins import object
              from typing import Any, Dict
              
              from sqlalchemy import Column, ForeignKey, Integer, String, Text, UniqueConstraint
              Severity: Minor
              Found in src/fonduer/parser/models/sentence.py - About 2 hrs to fix

                TemporarySpanMention has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class TemporarySpanMention(TemporaryContext):
                    """The TemporaryContext version of Span."""
                
                    def __init__(
                        self,
                Severity: Minor
                Found in src/fonduer/candidates/models/span_mention.py - About 2 hrs to fix

                  File spacy_parser.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """Fonduer Spacy parser."""
                  import importlib
                  import logging
                  from collections import defaultdict
                  from pathlib import Path
                  Severity: Minor
                  Found in src/fonduer/parser/lingual_parser/spacy_parser.py - About 2 hrs to fix

                    Function corenlp_to_xmltree_sub has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def corenlp_to_xmltree_sub(
                        s: Dict[str, Any], dep_parents: List[int], rid: int = 0
                    ) -> _Element:
                        """Construct XMLTree with CoreNLP information.
                    
                    
                    Severity: Minor
                    Found in src/fonduer/features/feature_libs/tree_structs.py - About 2 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 save_model has 16 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def save_model(
                    Severity: Major
                    Found in src/fonduer/packaging/fonduer_model.py - About 2 hrs to fix

                      Function _coordinates_from_HTML has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _coordinates_from_HTML(
                              self, page: Tag, page_num: int
                          ) -> Tuple[List[PdfWord], Dict[PdfWordId, Bbox]]:
                              pdf_word_list: List[PdfWord] = []
                              coordinate_map: Dict[PdfWordId, Bbox] = {}
                      Severity: Minor
                      Found in src/fonduer/parser/visual_parser/pdf_visual_parser.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 log_model has 15 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def log_model(
                      Severity: Major
                      Found in src/fonduer/packaging/fonduer_model.py - About 1 hr to fix

                        Function get_mentions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def get_mentions(
                                self, docs: Union[Document, Iterable[Document], None] = None, sort: bool = False
                            ) -> List[List[Mention]]:
                                """Return a list of lists of the mentions associated with this extractor.
                        
                        
                        Severity: Minor
                        Found in src/fonduer/candidates/mentions.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 get_candidates has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def get_candidates(
                                self,
                                docs: Union[Document, Iterable[Document], None] = None,
                                split: int = 0,
                                sort: bool = False,
                        Severity: Minor
                        Found in src/fonduer/candidates/candidates.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 _apply has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _apply(
                                self, doc_loader: Collection[Document], parallelism: int, **kwargs: Any
                            ) -> None:
                                """Run the UDF multi-threaded using python multiprocessing."""
                                if not Meta.postgres:
                        Severity: Minor
                        Found in src/fonduer/utils/udf.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

                        Severity
                        Category
                        Status
                        Source
                        Language