chrislit/abydos

View on GitHub

Showing 383 of 4,191 total issues

Function hmean has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def hmean(nums: Sequence[float]) -> float:
    r"""Return harmonic mean.

    The harmonic mean is defined as

Severity: Minor
Found in abydos/stats/_mean.py - About 1 hr 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 _encode_next has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _encode_next(self, word: str) -> Tuple[str, str]:
        if word[:3] == 'STI' and word[3:4] in {'E', 'Ä'}:
            code = '*'
            remainder = word[3:]
        elif word[:3] in self._transforms[3]:
Severity: Minor
Found in abydos/phonetic/_waahlin.py - About 1 hr 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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(
        self,
        max_offset: int = 5,
        max_distance: int = 0,
        tokenizer: Optional[_Tokenizer] = None,
Severity: Minor
Found in abydos/distance/_sift4_extended.py - About 1 hr 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 fingerprint_int has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def fingerprint_int(self, word: str) -> int:
        """Return the occurrence halved fingerprint.

        Based on the occurrence halved fingerprint from :cite:`Cislak:2017`.

Severity: Minor
Found in abydos/fingerprint/_occurrence_halved.py - About 1 hr 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 sim has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def sim(self, src: str, tar: str) -> float:
        """Return the Monge-Elkan similarity of two strings.

        Parameters
        ----------
Severity: Minor
Found in abydos/distance/_monge_elkan.py - About 1 hr 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 sim has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def sim(self, src: str, tar: str) -> float:
        r"""Return the Soft Cosine similarity of two strings.

        Parameters
        ----------
Severity: Minor
Found in abydos/distance/_soft_cosine.py - About 1 hr 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

Consider simplifying this complex logical expression.
Open

        if word[:3] == 'STI' and word[3:4] in {'E', 'Ä'}:
            code = '*'
            remainder = word[3:]
        elif word[:3] in self._transforms[3]:
            code = self._transforms[3][word[:3]]
Severity: Critical
Found in abydos/phonetic/_waahlin.py - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

                    if pos >= 0:
                        # check rules for this char
                        while (_phonet_rules[pos] is None) or (
                            cast(str, _phonet_rules[pos])[0] == char
                        ):
    Severity: Critical
    Found in abydos/phonetic/_phonet.py - About 1 hr to fix

      Function _apply_rule_if_compat has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _apply_rule_if_compat(
              self, phonetic: str, target: str, language_arg: int
          ) -> Optional[str]:
              """Apply a phonetic regex if compatible.
      
      
      Severity: Minor
      Found in abydos/phonetic/_beider_morse.py - About 1 hr 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 a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(
              self,
              language_arg: Union[str, int] = 0,
              name_mode: str = 'gen',
              match_mode: str = 'approx',
      Severity: Minor
      Found in abydos/phonetic/_beider_morse.py - About 1 hr 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 _sb_r1 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _sb_r1(
              self, term: str, r1_prefixes: Optional[Iterable[str]] = None
          ) -> int:
              """Return the R1 region, as defined in the Porter2 specification.
      
      
      Severity: Minor
      Found in abydos/stemmer/_snowball.py - About 1 hr 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 lcsstr has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def lcsstr(self, src: str, tar: str) -> str:
              """Return the longest common substring of two strings.
      
              Longest common substring (LCSstr).
      
      
      Severity: Minor
      Found in abydos/distance/_lcsstr.py - About 1 hr 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 dist_abs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def dist_abs(self, src: str, tar: str) -> float:
              """Return the FlexMetric distance of two strings.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/distance/_flexmetric.py - About 1 hr 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 fingerprint has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def fingerprint(self, word: str) -> str:
              """Return the skeleton key.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/fingerprint/_skeleton_key.py - About 1 hr 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_estimates has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_estimates(self, src: str, tar: str) -> Tuple[float, float]:
              """Get the estimates U-hat & V-hat used for Chao's measures.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/distance/_chao_jaccard.py - About 1 hr 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 _scale_and_counterize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _scale_and_counterize(self) -> None:
              """Scale the tokens and store them in a defaultdict.
      
              .. versionadded:: 0.6.0
      
      
      Severity: Minor
      Found in abydos/tokenizer/_tokenizer.py - About 1 hr 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 decode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def decode(self, code: str) -> str:
              r"""Return a word decoded from BWT form.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/compression/_bwt.py - About 1 hr 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_feature has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_feature(vector: List[int], feature: str) -> List[Union[int, float]]:
          """Get a feature vector.
      
          This returns a list of ints, equal in length to the vector input,
              representing presence/absence/neutrality with respect to a particular
      Severity: Minor
      Found in abydos/phones/_phones.py - About 1 hr 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 encode has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def encode(self, lname: str) -> str:
              """Calculate the PSHP Soundex/Viewex Coding of a last name.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/phonetic/_pshp_soundex_last.py - About 1 hr to fix

        Function encode has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def encode(self, word: str) -> str:
                """Return the Dolby Code of a name.
        
                Parameters
                ----------
        Severity: Minor
        Found in abydos/phonetic/_dolby.py - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language