chrislit/abydos

View on GitHub

Showing 4,191 of 4,191 total issues

Avoid too many return statements within this function.
Open

        return 0
Severity: Major
Found in abydos/distance/_mra.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return cast(float, d_mat[src_len, tar_len])
    Severity: Major
    Found in abydos/distance/_editex.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return cast(float, d_mat[src_len, tar_len])
      Severity: Major
      Found in abydos/distance/_levenshtein.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return cast(float, d_mat[src_len, tar_len])
        Severity: Major
        Found in abydos/distance/_phonetic_edit_distance.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return cast(
          Severity: Major
          Found in abydos/distance/_tversky.py - About 30 mins to fix

            Function package_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def package_path(resource_name: str) -> str:
                """Given a resource name, returns the path to the package."""
                for path in data_path:
                    for subdir in DATA_SUBDIRS:
                        check_path = os.path.join(path, subdir, resource_name)
            Severity: Minor
            Found in abydos/util/_data.py - About 25 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 _ncr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def _ncr(n: float, r: float) -> float:
                r"""Return n Choose r.
            
                Cf. https://en.wikipedia.org/wiki/Combination
            
            
            Severity: Minor
            Found in abydos/util/_ncr.py - About 25 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 _normalize_lang_attrs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _normalize_lang_attrs(self, text: str, strip: bool) -> str:
                    """Remove embedded bracketed attributes.
            
                    This (potentially) bitwise-ands bracketed attributes together and adds
                    to the end.
            Severity: Minor
            Found in abydos/phonetic/_beider_morse.py - About 25 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 dist_abs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def dist_abs(self, src: str, tar: str) -> float:
                    """Return the Shapira & Storer I edit distance between two strings.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/distance/_shapira_storer_i.py - About 25 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 fingerprint_int has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def fingerprint_int(self, word: str) -> int:
                    """Return the count fingerprint.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/fingerprint/_count.py - About 25 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 _tokenize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _tokenize(
                    self, src: Union[str, TCounter[str]], tar: Union[str, TCounter[str]]
                ) -> '_TokenDistance':
                    """Return the Q-Grams in src & tar.
            
            
            Severity: Minor
            Found in abydos/distance/_token_distance.py - About 25 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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(
                    self,
                    variant: int = 1,
                    doubles: bool = True,
                    vowels: Optional[Union[Iterable[str], str]] = None,
            Severity: Minor
            Found in abydos/fingerprint/_consonant.py - About 25 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 sim has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def sim(self, src: str, tar: str) -> float:
                    """Return the BLEU similarity of two strings.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/distance/_bleu.py - About 25 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 dist_abs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def dist_abs(self, src: str, tar: str) -> float:
                    """Return the Ozbay metric.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/distance/_ozbay.py - About 25 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 dist_abs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def dist_abs(self, src: str, tar: str) -> float:
                    """Return Millar's binomial deviance dissimilarity of two strings.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/distance/_millar.py - About 25 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 sim has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def sim(self, src: str, tar: str) -> float:
                    """Return the Tversky index of two strings.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/distance/_tversky.py - About 25 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 encode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def encode(self, text: str) -> str:
                    r"""Perform encoding of run-length-encoding (RLE).
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/compression/_rle.py - About 25 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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(
                    self,
                    nltk_tokenizer: Optional[object] = None,
                    scaler: Optional[Union[str, Callable[[float], float]]] = None,
                ) -> None:
            Severity: Minor
            Found in abydos/tokenizer/_nltk.py - About 25 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

            Refactor this function to reduce its Cognitive Complexity from 22 to the 15 allowed.
            Open

                def stem(self, word: str) -> str:
            Severity: Critical
            Found in abydos/stemmer/_snowball_danish.py by sonar-python

            Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

            See

            Either remove or fill this block of code.
            Open

                            pass
            Severity: Major
            Found in abydos/stemmer/_porter.py by sonar-python

            Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.

            Noncompliant Code Example

            for i in range(3):
                pass
            

            Exceptions

            When a block contains a comment, this block is not considered to be empty.

            Severity
            Category
            Status
            Source
            Language