HazyResearch/fonduer

View on GitHub

Showing 224 of 224 total issues

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

def get_row_ngrams(
Severity: Minor
Found in src/fonduer/utils/data_model_utils/tabular.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) -> "TemporaryImplicitSpanMention":
            """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/implicit_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

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

        def __init__(
    Severity: Minor
    Found in src/fonduer/learning/dataset.py - About 45 mins to fix

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

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

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

            def _f_gen(self, c: Candidate) -> Iterator[Tuple[int, str, int]]:
                """Convert lfs into a generator of id, name, and labels.
        
                In particular, catch verbose values and convert to integer ones.
                """
        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_right_ngrams has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

          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

                                    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

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

              def get_head_ngrams(
              Severity: Minor
              Found in src/fonduer/utils/data_model_utils/tabular.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/utils/udf.py - About 45 mins to fix

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

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

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

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

                      Avoid deeply nested control flow statements.
                      Open

                                              for f, v in _tablelib_unary_features(span):
                                                  unary_tablelib_feats[span.stable_id].add((f, v))
                      
                      
                      Severity: Major
                      Found in src/fonduer/features/feature_libs/tabular_features.py - About 45 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
                                    else:
                        Severity: Major
                        Found in src/fonduer/utils/data_model_utils/visual.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

                            Avoid deeply nested control flow statements.
                            Open

                                                if [span_sentences[1:] == span_sentences[:-1]]:
                                                    yield "SAME_SENTENCE", DEF_VALUE
                                    else:
                            Severity: Major
                            Found in src/fonduer/features/feature_libs/tabular_features.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

                                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 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

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

                                        def __init__(
                                    Severity: Minor
                                    Found in src/fonduer/candidates/mentions.py - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language