chrislit/abydos

View on GitHub

Showing 383 of 4,191 total issues

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

    def sim(self, src: str, tar: str) -> float:
        """Return Cao's CY similarity (CYs) of two strings.

        Parameters
        ----------
Severity: Minor
Found in abydos/distance/_cao.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 ipa_to_features has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def ipa_to_features(ipa: str) -> List[int]:
    """Convert IPA to features.

    This translates an IPA string of one or more phones to a list of ints
    representing the features of the string.
Severity: Minor
Found in abydos/phones/_phones.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 _phonetic has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _phonetic(
Severity: Major
Found in abydos/phonetic/_beider_morse.py - About 50 mins to fix

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

        def __init__(
    Severity: Major
    Found in abydos/distance/_generalized_fleiss.py - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if os.path.isdir(os.path.join(check_path, package)):
                              with open(
                                  os.path.join(check_path, package + '.xml')
                              ) as xml:
                                  file = xml.read()
      Severity: Major
      Found in abydos/util/_data.py - About 45 mins to fix

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

            def _expand_alternates(self, phonetic: str) -> str:
                r"""Expand phonetic alternates separated by \|s.
        
                Parameters
                ----------
        Severity: Minor
        Found in abydos/phonetic/_beider_morse.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 current > 0:
                                    if _string_at(0, 2, {'MC'}):
                                        # e.g., "McHugh"
                                        primary, secondary = _metaph_add('K')
                                    else:
        Severity: Major
        Found in abydos/phonetic/_double_metaphone.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if k <= 0:
                                          # add hash value for all letters
                                          if phonet_hash_1[j, 0] < 0:
                                              phonet_hash_1[j, 0] = i
          
          
          Severity: Major
          Found in abydos/phonetic/_phonet.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if (
                                            (matches > 1)
                                            and src[i + matches : i + matches + 1]
                                            and (priority0 != ord('-'))
                                        ):
            Severity: Major
            Found in abydos/phonetic/_phonet.py - About 45 mins to fix

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

                  def _language(self, name: str, name_mode: str) -> int:
                      """Return the best guess language ID for the word and language choices.
              
                      Parameters
                      ----------
              Severity: Minor
              Found in abydos/phonetic/_beider_morse.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 word[pos + 1 : pos + 2] == 'C':
                                          meta_key += 'X'
                                          pos += 2
                                      # special case 'cesar', 'cien', 'cid', 'conciencia'
                                      elif word[pos + 1 : pos + 2] in {'E', 'I'}:
              Severity: Major
              Found in abydos/phonetic/_spanish_metaphone.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if not search(right, phoneticx[i + pattern_length :]):
                                            continue
                
                                    # check that left context is satisfied
                                    if lcontext != '':
                Severity: Major
                Found in abydos/phonetic/_beider_morse.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if _string_at(
                                              (current + 3),
                                              2,
                                              {'OO', 'ER', 'EN', 'UY', 'ED', 'EM'},
                                          ):
                  Severity: Major
                  Found in abydos/phonetic/_double_metaphone.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if not search(left, phoneticx[:i]):
                                                continue
                    
                                        # check for incompatible attributes
                                        candidate = self._apply_rule_if_compat(
                    Severity: Major
                    Found in abydos/phonetic/_beider_morse.py - About 45 mins to fix

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

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

                        Avoid deeply nested control flow statements.
                        Open

                                                if phonetic[i] == ']':
                                                    i += 1
                                                    phonetic2 += phonetic[attrib_start:i]
                                                    break
                                                i += 1
                        Severity: Major
                        Found in abydos/phonetic/_beider_morse.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if char == self._vowel_char:
                                                      if vowels:
                                                          code += char
                                                          vowels -= 1
                                                  else:
                          Severity: Major
                          Found in abydos/phonetic/_dolby.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if word[pos + 2 : pos + 3] in self._uc_vy_set:
                                                        code += 'C'
                                                    else:  # CHR, CHL, etc.
                                                        code += 'K'
                                                else:
                            Severity: Major
                            Found in abydos/phonetic/_henry_early.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if word[pos + 1 : pos + 2] in {'E', 'I'}:
                                                          meta_key += 'J'
                                                          pos += 2
                                                      # base case
                                                      else:
                              Severity: Major
                              Found in abydos/phonetic/_spanish_metaphone.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if _is_vowel(pos + 1):
                                                            meta_key += word[pos + 1]
                                                            pos += 2
                                                        else:
                                                            meta_key += 'H'
                                Severity: Major
                                Found in abydos/phonetic/_spanish_metaphone.py - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language