chrislit/abydos

View on GitHub

Showing 383 of 4,191 total issues

Avoid deeply nested control flow statements.
Open

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

    Avoid deeply nested control flow statements.
    Open

                                if pos0 >= 0:
                                    while (_phonet_rules[pos0] is None) or (
                                        cast(str, _phonet_rules[pos0])[0] == char0
                                    ):
                                        if pos0 > end3:
    Severity: Major
    Found in abydos/phonetic/_phonet.py - About 45 mins to fix

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

          def sim(self, src: str, tar: str) -> float:
              """Return the BI-SIM similarity of two strings.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/distance/_bisim.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 not _is_vowel(pos + 1) and pos == 0:
                                  meta_key += 'ES'
                                  pos += 1
                              else:
                                  meta_key += 'S'
      Severity: Major
      Found in abydos/phonetic/_spanish_metaphone.py - About 45 mins to fix

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

            def _sb_ends_in_short_syllable(self, term: str) -> bool:
                """Return True iff term ends in a short syllable.
        
                (...according to the Porter2 specification.)
        
        
        Severity: Minor
        Found in abydos/stemmer/_snowball.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 _get_at(current + 2) == 'I':
                                    primary, secondary = _metaph_add('J')
                                else:
                                    primary, secondary = _metaph_add('K')
                                current += 2
        Severity: Major
        Found in abydos/phonetic/_double_metaphone.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for inst in installed:  # pragma: no branch
                                  if pack[0] == inst[0] and pack[2] <= inst[2]:
                                      if not silent:
                                          print(  # pragma: no cover  # noqa: T001
                                              '{} package already up-to-date'.format(
          Severity: Major
          Found in abydos/util/_data.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if _phonet_rules[pos] and (
                                            '<' in cast(str, _phonet_rules[pos])[1:]
                                        ):
                                            priority0 = 1
                                        else:
            Severity: Major
            Found in abydos/phonetic/_phonet.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for i in range(len(self._alpha_sis_basic[k])):
                                          newalpha += [
                                              _ + self._alpha_sis_basic[k][i] for _ in alpha
                                          ]
                                      alpha = newalpha
              Severity: Major
              Found in abydos/phonetic/_alpha_sis.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if (
                                            len(word) > 1
                                            and pos == 0
                                            and not _is_vowel(pos + 1)
                                        ):
                Severity: Major
                Found in abydos/phonetic/_spanish_metaphone.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (
                                              i == 0
                                              and i + 1 < elen
                                              and ename[i + 2 : i + 3] not in self._uc_v_set
                                          ):
                  Severity: Major
                  Found in abydos/phonetic/_metaphone.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (
                                                (current == 1) and _get_at(current - 1) == 'A'
                                            ) or _string_at((current - 1), 5, {'UCCEE', 'UCCES'}):
                                                primary, secondary = _metaph_add('KS')
                                            # 'bacci', 'bertucci', other italian
                    Severity: Major
                    Found in abydos/phonetic/_double_metaphone.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if accept:
                                                  break
                      
                      
                      Severity: Major
                      Found in abydos/stemmer/_paice_husk.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if start2 > 0:
                                                        pos = start2
                                                        start1 = start2
                                                        start2 = -1
                                                        end1 = end2
                        Severity: Major
                        Found in abydos/phonetic/_phonet.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                      if (
                                                          (len(src) > (i + matches))
                                                          and src[i + matches].isalpha()
                                                          and (src[i + matches] in rule[1:])
                                                      ):
                          Severity: Major
                          Found in abydos/phonetic/_phonet.py - About 45 mins to fix

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

                                def sim(self, src: str, tar: str) -> float:
                                    """Return the Horn-Morisita similarity of two strings.
                            
                                    Parameters
                                    ----------
                            Severity: Minor
                            Found in abydos/distance/_horn_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

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

                                def _redo_language(
                            Severity: Minor
                            Found in abydos/phonetic/_beider_morse.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if (
                                                          (current > 2)
                                                          and (_get_at(current - 1) == 'U')
                                                          and (
                                                              _string_at(
                              Severity: Major
                              Found in abydos/phonetic/_double_metaphone.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                            if (priority0 == 1) and (zeta == 0):
                                                                # rule with '<' is applied
                                                                if (
                                                                    (j > 0)
                                                                    and rule
                                Severity: Major
                                Found in abydos/phonetic/_phonet.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

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