HazyResearch/fonduer

View on GitHub

Showing 134 of 224 total issues

Function get_aligned_ngrams has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def get_aligned_ngrams(
Severity: Minor
Found in src/fonduer/utils/data_model_utils/tabular.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if directions:
                            if col_diff == 0:
                                direction = "DOWN" if 0 < row_diff else "UP"
                            else:
                                direction = "RIGHT" if 0 < col_diff else "LEFT"
    Severity: Major
    Found in src/fonduer/utils/data_model_utils/tabular.py - About 45 mins to fix

      Function apply has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def apply(
      Severity: Minor
      Found in src/fonduer/utils/udf.py - About 45 mins to fix

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

        def get_between_ngrams(
            c: Candidate,
            attrib: str = "words",
            n_min: int = 1,
            n_max: int = 1,
        Severity: Minor
        Found in src/fonduer/utils/data_model_utils/textual.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

                                for end_idx in end_idxs:
                                    if start_idx < end_idx:
                                        ts = TemporarySpanMention(
                                            char_start=start_idx,
                                            char_end=end_idx - 1,
        Severity: Major
        Found in src/fonduer/candidates/mentions.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for f in _get_ddlib_feats(span, get_as_dict(span.sentence), sidxs):
                                  yield candidate.id, f"DDL_{f}", DEF_VALUE
                              # Add TreeDLib entity features
                              if span.stable_id not in unary_tdl_feats:
          Severity: Major
          Found in src/fonduer/features/feature_libs/textual_features.py - About 45 mins to fix

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

                def __init__(
            Severity: Minor
            Found in src/fonduer/parser/preprocessors/csv_doc_preprocessor.py - About 45 mins to fix

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

                  def display_words(
                      self,
                      sentences: List[Sentence],
                      target: Optional[str] = None,
                      pdf_file: Optional[str] = None,
              Severity: Minor
              Found in src/fonduer/utils/visualizer.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 clear has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def clear(self) -> None:  # type: ignore
                      """Delete Mentions of each class in the extractor from the given split."""
                      # Create set of candidate_subclasses associated with each mention_subclass
                      cand_subclasses = set()
                      for mentions, tablename in [
              Severity: Minor
              Found in src/fonduer/candidates/mentions.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 self.space:
                                          word.string.replace_with(" ".join(tokens))
                                      else:
                                          word.string.replace_with("".join(tokens))
                                  word.unwrap()
              Severity: Major
              Found in src/fonduer/parser/preprocessors/hocr_doc_preprocessor.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if child.strip() == "":  # remove if space or linebreak
                                            child.extract()
                                        else:
                                            tmp = re.sub(r"[\n\s]+", " " if self.space else "", child)
                                            n = NavigableString(tmp.strip())
                Severity: Major
                Found in src/fonduer/parser/preprocessors/hocr_doc_preprocessor.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if span.stable_id not in unary_tdl_feats:
                                          unary_tdl_feats[span.stable_id] = set()
                                          for f in get_tdl_feats(xmltree.root, sidxs):
                                              unary_tdl_feats[span.stable_id].add(f)
                                      for f in unary_tdl_feats[span.stable_id]:
                  Severity: Major
                  Found in src/fonduer/features/feature_libs/textual_features.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if not to_add:
                                                to_add = "None"
                                            new_pos_tags.append(to_add)
                    Severity: Major
                    Found in src/fonduer/features/feature_libs/textual_features.py - About 45 mins to fix

                      Function _get_window_features has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def _get_window_features(
                      Severity: Minor
                      Found in src/fonduer/features/feature_libs/textual_features.py - About 35 mins to fix

                        Function apply has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def apply(  # type: ignore
                        Severity: Minor
                        Found in src/fonduer/parser/parser.py - About 35 mins to fix

                          Function get_cell_ngrams has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def get_cell_ngrams(
                          Severity: Minor
                          Found in src/fonduer/utils/data_model_utils/tabular.py - About 35 mins to fix

                            Function apply has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def apply(  # type: ignore
                            Severity: Minor
                            Found in src/fonduer/supervision/labeler.py - About 35 mins to fix

                              Function get_sentence_ngrams has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              def get_sentence_ngrams(
                              Severity: Minor
                              Found in src/fonduer/utils/data_model_utils/tabular.py - About 35 mins to fix

                                Function get_between_ngrams has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                def get_between_ngrams(
                                Severity: Minor
                                Found in src/fonduer/utils/data_model_utils/textual.py - About 35 mins to fix

                                  Function get_sentence_ngrams has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  def get_sentence_ngrams(
                                  Severity: Minor
                                  Found in src/fonduer/utils/data_model_utils/textual.py - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language