HazyResearch/fonduer

View on GitHub

Showing 134 of 224 total issues

Function create_task has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def create_task(
Severity: Major
Found in src/fonduer/learning/task.py - About 50 mins to fix

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

        def apply(  # type: ignore
    Severity: Major
    Found in src/fonduer/features/featurizer.py - About 50 mins to fix

      Function _get_direction_ngrams has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _get_direction_ngrams(
      Severity: Major
      Found in src/fonduer/utils/data_model_utils/visual.py - About 50 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for ngram in tokens_to_ngrams(
                                getattr(sentence, attrib), n_min=n_min, n_max=n_max, lower=lower
                            ):
                                yield ngram
        
        
        Severity: Major
        Found in src/fonduer/utils/data_model_utils/tabular.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

          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

          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

          Avoid deeply nested control flow statements.
          Open

                              for span, sent, s_idx, i in zip(
                                  spans, sents, s_idxs, range(len(spans))
                              ):
          
                                  for f in _get_ddlib_feats(span, sent, s_idx):
          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 __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 _after_apply has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _after_apply(
                        self, train: bool = False, table: Table = Label, **kwargs: Any
                    ) -> None:
                        # Insert all Label Keys
                        if train:
                Severity: Minor
                Found in src/fonduer/supervision/labeler.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_vert_ngrams has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def get_vert_ngrams(
                Severity: Minor
                Found in src/fonduer/utils/data_model_utils/visual.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 "x_wconf" not in parent.attrs:
                                                parent["x_wconf"] = []
                                            parent["x_wconf"].append(x_wconf)
                    Severity: Major
                    Found in src/fonduer/parser/preprocessors/hocr_doc_preprocessor.py - About 45 mins to fix

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

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

                        Avoid deeply nested control flow statements.
                        Open

                                            for f in multinary_tdl_feats[candidate.id]:
                                                yield candidate.id, f"TDL_{f}", DEF_VALUE
                                    for i, span in enumerate(spans):
                        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 r.search(styles.text) is not None:
                                                          if cur_style_index is not None:
                                                              parts["html_attrs"][cur_style_index] += (
                                                                  r.search(styles.text)
                                                                  .group(3)
                          Severity: Major
                          Found in src/fonduer/parser/parser.py - About 45 mins to fix

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

                            def _assign_alignment_features(sentences_by_key: defaultdict, align_type: str) -> None:
                                for key, sentences in sentences_by_key.items():
                                    if len(sentences) == 1:
                                        continue
                                    context_lemmas: Set[str] = set()
                            Severity: Minor
                            Found in src/fonduer/utils/data_model_utils/visual.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 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 __getitem__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def __getitem__(self, key: slice) -> "TemporarySpanMention":
                                      """Slice operation returns a new candidate sliced according to **char index**.
                              
                                      Note that the slicing is w.r.t. the candidate range (not the abs.
                                      sentence char indexing).
                              Severity: Minor
                              Found in src/fonduer/candidates/models/span_mention.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

                              Severity
                              Category
                              Status
                              Source
                              Language