chrislit/abydos

View on GitHub

Showing 383 of 4,191 total issues

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

    def __init__(
Severity: Minor
Found in abydos/corpus/_corpus.py - About 45 mins to fix

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

        def decode(self, longval: int, nbits: int) -> str:
            """Decode the number to a string using the given statistics.
    
            Parameters
            ----------
    Severity: Minor
    Found in abydos/compression/_arithmetic.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 backtrace:
                                trace_mat[i + 1, j + 1] = 2
    
    
    Severity: Major
    Found in abydos/distance/_levenshtein.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (
                                  abs(sp - tp) <= self._max_dist
                                  and sp not in src_matched
                                  and tp not in tar_matched
                              ):
      Severity: Major
      Found in abydos/distance/_positional_q_gram_jaccard.py - About 45 mins to fix

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

            def decode(self, text: str) -> str:
                r"""Perform decoding of run-length-encoding (RLE).
        
                Parameters
                ----------
        Severity: Minor
        Found in abydos/compression/_rle.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 is_trans:
                                    trans += 1
                                elif not ofs['trans']:
                                    ofs['trans'] = True
                                    trans += 1
        Severity: Major
        Found in abydos/distance/_sift4.py - About 45 mins to fix

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

              def __init__(
          Severity: Minor
          Found in abydos/distance/_jaro_winkler.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if k - i > best:
                                        best = k - i
                                        start_src = i
                                        end_src = k
                                        start_tar = p
            Severity: Major
            Found in abydos/distance/_iterative_substring.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if yang_flag[j] == 0 and _in_range(yang[j]):
                                          if (ying[i], yang[j]) in adjwt:
                                              n_simi += adjwt[(ying[i], yang[j])]
                                              yang_flag[j] = 2
                                              break
              Severity: Major
              Found in abydos/distance/_strcmp95.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if mode == 2:
                                            self._ordered_tokens.append(new_token)
                                            new_token = char
                                        else:
                                            new_token += char
                Severity: Major
                Found in abydos/tokenizer/_c_or_v_cluster.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if masked == 0:
                                          feature_dict[feature] = '0'  # 0
                                      elif masked == mask:
                                          feature_dict[feature] = '+/-'  # +/-
                                      elif masked & pos_mask:
                  Severity: Major
                  Found in abydos/phones/_phones.py - About 45 mins to fix

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

                        def sim_score(self, src: str, tar: str) -> float:
                            """Return the Morisita similarity of two strings.
                    
                            Parameters
                            ----------
                    Severity: Minor
                    Found in abydos/distance/_morisita.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 mode == 1:
                                                self._ordered_tokens.append(new_token)
                                                new_token = char
                                            else:
                                                new_token += char
                    Severity: Major
                    Found in abydos/tokenizer/_vc_cluster.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if mode == 2:
                                                  self._ordered_tokens.append(new_token)
                                                  new_token = char
                                              else:
                                                  new_token += char
                      Severity: Major
                      Found in abydos/tokenizer/_cv_cluster.py - About 45 mins to fix

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

                            def encode(self, word: str) -> str:
                                r"""Return the Burrows-Wheeler transformed form of a word.
                        
                                Parameters
                                ----------
                        Severity: Minor
                        Found in abydos/compression/_bwt.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

                                                while j < lt and k < ls and src[k] == tar[j]:
                                                    j += 1
                                                    k += 1
                                                if k - i > best:
                        Severity: Major
                        Found in abydos/distance/_iterative_substring.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  while word in sentence_words:
                                                      sentence_words.remove(word)
                                          for char in set(filter_chars):
                          Severity: Major
                          Found in abydos/corpus/_corpus.py - About 45 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if (
                                        len(word) >= 4
                                        and word[-3] == word[-2]
                                        and word[-2] in {'a', 'e', 'o', 'u'}
                                        and word[-4] not in self._vowels
                            Severity: Major
                            Found in abydos/stemmer/_snowball_dutch.py - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                          if (len(word) > 4 and word[-2:] in {'em', 'er'}) or (
                                              len(word) > 5 and word[-2:] == 'nd'
                                          ):
                                              word = word[:-2]
                                          elif (word[-1] in {'e', 's', 'n'}) or (
                              Severity: Major
                              Found in abydos/stemmer/_caumanns.py - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                        if wlen > 4 and word[-3:] == 'ern':
                                            word = word[:-3]
                                        elif wlen > 3 and word[-2:] in {'em', 'en', 'er', 'es'}:
                                            word = word[:-2]
                                        elif wlen > 2 and (
                                Severity: Major
                                Found in abydos/stemmer/_clef_german_plus.py - About 40 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language