chrislit/abydos

View on GitHub

Showing 383 of 4,191 total issues

Function stem has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def stem(self, word: str) -> str:
        """Return Snowball Norwegian stem.

        Parameters
        ----------
Severity: Minor
Found in abydos/stemmer/_snowball_norwegian.py - About 3 hrs 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 cmp_features has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def cmp_features(
    feat1: int,
    feat2: int,
    weights: Optional[
        Union[Sequence[Union[int, float]], Dict[str, Union[int, float]]]
Severity: Minor
Found in abydos/phones/_phones.py - About 3 hrs 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 24 (exceeds 5 allowed). Consider refactoring.
Open

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

        This deviates from the algorithm described in :cite:`Guth:1976` in that
        more distant matches are penalized, so that less similar terms score
Severity: Minor
Found in abydos/distance/_guth.py - About 3 hrs 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 23 (exceeds 5 allowed). Consider refactoring.
Open

    def dist_abs(self, src: str, tar: str) -> float:
        """Return the discounted Hamming distance between two strings.

        Parameters
        ----------
Severity: Minor
Found in abydos/distance/_relaxed_hamming.py - About 3 hrs 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 _cost has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def _cost(self, src: str, s_pos: int, tar: str, t_pos: int) -> float:
        if s_pos == -1:
            if t_pos > 0 and tar[t_pos - 1] == tar[t_pos]:
                return 0.0
            for letter_set in self._indel_costs:
Severity: Minor
Found in abydos/distance/_flexmetric.py - About 3 hrs 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 a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def encode(self, word: str) -> str:
        """Return the Daitch-Mokotoff Soundex code for a word.

        Parameters
        ----------
Severity: Minor
Found in abydos/phonetic/_daitch_mokotoff.py - About 3 hrs 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 stem has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def stem(self, word: str) -> str:
        """Return Snowball Danish stem.

        Parameters
        ----------
Severity: Minor
Found in abydos/stemmer/_snowball_danish.py - About 3 hrs 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 i >= len(word):
                continue
            elif skip:
                skip -= 1
                continue
Severity: Critical
Found in abydos/phonetic/_nysiis.py - About 3 hrs to fix

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

        def encode(self, fname: str) -> str:
            """Calculate the PSHP Soundex/Viewex Coding of a first name.
    
            Parameters
            ----------
    Severity: Minor
    Found in abydos/phonetic/_pshp_soundex_first.py - About 2 hrs 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 _soft_intersection has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def _soft_intersection(self) -> TCounter[str]:
            """Return the soft source, target, & intersection tokens & weights.
    
            This implements the soft intersection defined by :cite:`Russ:2014` in
            a way that can reproduce the results in the paper.
    Severity: Minor
    Found in abydos/distance/_token_distance.py - About 2 hrs 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 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def sim(self, src: str, tar: str) -> float:
            """Return the Positional Q-Gram Overlap coefficient of two strings.
    
            Parameters
            ----------
    Severity: Minor
    Found in abydos/distance/_positional_q_gram_overlap.py - About 2 hrs 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 corpus_importer has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def corpus_importer(
            self,
            corpus: Corpus,
            n_val: int = 1,
            bos: str = '_START_',
    Severity: Minor
    Found in abydos/corpus/_ngram_corpus.py - About 2 hrs 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_feature_dicts has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def ipa_to_feature_dicts(ipa: str) -> List[Dict[str, str]]:
        """Convert IPA to a feature dict list.
    
        This translates an IPA string of one or more phones to a list of dicts
        representing the features of the string.
    Severity: Minor
    Found in abydos/phones/_phones.py - About 2 hrs 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

    File _discounted_levenshtein.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # Copyright 2019-2020 by Christopher C. Little.
    # This file is part of Abydos.
    #
    # Abydos is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    Severity: Minor
    Found in abydos/distance/_discounted_levenshtein.py - About 2 hrs to fix

      File _sift4_extended.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # Copyright 2019-2020 by Christopher C. Little.
      # This file is part of Abydos.
      #
      # Abydos is free software: you can redistribute it and/or modify
      # it under the terms of the GNU General Public License as published by
      Severity: Minor
      Found in abydos/distance/_sift4_extended.py - About 2 hrs to fix

        Function stem has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def stem(self, word: str) -> str:
                """Return Paice-Husk stem.
        
                Parameters
                ----------
        Severity: Minor
        Found in abydos/stemmer/_paice_husk.py - About 2 hrs 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 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def sim(self, src: str, tar: str) -> float:
                """Return the Ratcliff-Obershelp similarity of two strings.
        
                Parameters
                ----------
        Severity: Minor
        Found in abydos/distance/_ratcliff_obershelp.py - About 2 hrs 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 tokenize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def tokenize(self, string: str) -> 'CVClusterTokenizer':
                """Tokenize the term and store it.
        
                The tokenized term is stored as an ordered list and as a Counter
                object.
        Severity: Minor
        Found in abydos/tokenizer/_cv_cluster.py - About 2 hrs 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 tokenize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def tokenize(self, string: str) -> 'VCClusterTokenizer':
                """Tokenize the term and store it.
        
                The tokenized term is stored as an ordered list and as a Counter
                object.
        Severity: Minor
        Found in abydos/tokenizer/_vc_cluster.py - About 2 hrs 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 (
                                    not rule
                                    or (
                                        (rule[0] == '^')
                                        and ((i == 0) or not src[i - 1].isalpha())
        Severity: Critical
        Found in abydos/phonetic/_phonet.py - About 2 hrs to fix
          Severity
          Category
          Status
          Source
          Language