HazyResearch/fonduer

View on GitHub

Showing 224 of 224 total issues

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

    def upsert_keys(
        self,
        keys: Iterable[str],
        candidate_classes: Union[Candidate, Iterable[Candidate], None] = None,
    ) -> None:
Severity: Minor
Found in src/fonduer/features/featurizer.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 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 _get_axis_ngrams has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

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

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

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

            def __init__(
        Severity: Major
        Found in src/fonduer/candidates/candidates.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

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

                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

                                      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

                    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_neighbor_sentence_ngrams has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

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

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

                          def get_cell_ngrams(
                              mention: Union[Candidate, Mention, TemporarySpanMention],
                              attrib: str = "words",
                              n_min: int = 1,
                              n_max: int = 1,
                          Severity: Minor
                          Found in src/fonduer/utils/data_model_utils/tabular.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 feature, value in _strlib_unary_features(span):
                                                      unary_strlib_feats[span.stable_id].add((feature, value))
                          
                          
                          Severity: Major
                          Found in src/fonduer/features/feature_libs/structural_features.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 _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 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

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