chrislit/abydos

View on GitHub

Showing 4,191 of 4,191 total issues

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

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

        Parameters
        ----------
Severity: Minor
Found in abydos/distance/_mlipns.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 stem has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def stem(self, word: str) -> str:
        """Return Caumanns German stem.

        Parameters
        ----------
Severity: Minor
Found in abydos/stemmer/_caumanns.py - About 1 hr to fix

    Function dist_abs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def dist_abs(self, src: str, tar: str) -> float:
            """Return the Meta-Levenshtein distance of two strings.
    
            Parameters
            ----------
    Severity: Minor
    Found in abydos/distance/_meta_levenshtein.py - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

                      if _string_at(current, 4, {'JOSE'}) or _string_at(
                          0, 4, {'SAN '}
                      ):
                          if (
                              (current == 0) and (_get_at(current + 4) == ' ')
      Severity: Major
      Found in abydos/phonetic/_double_metaphone.py - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                            if (current > 0) and not _is_vowel(current - 1):
                                primary, secondary = _metaph_add('K')
                                current += 2
                                continue
        
        
        Severity: Major
        Found in abydos/phonetic/_double_metaphone.py - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                          if (
                              (not src_len_fn and not tar_len_fn)
                              or (tar_fn and src_fn.startswith(tar_fn))
                              or (src_fn and tar_fn.startswith(src_fn))
                          ) and not roman_conflict:
          Severity: Major
          Found in abydos/distance/_synoname.py - About 1 hr to fix

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

            def _default_download_dir() -> Optional[str]:
                """Return the directory to which packages will be downloaded by default.
            
                This is mostly copied from NLTK's
                nltk.downloader.Downloader.default_download_dir
            Severity: Minor
            Found in abydos/util/_data.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 encode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def encode(self, word: str) -> str:
                    """Return the SoundexBR encoding of a word.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/phonetic/_soundex_br.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 dist has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def dist(self, src: str, tar: str) -> float:
                    """Return the INClusion Programme value of two words.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/distance/_inclusion.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 _fuzzy_intersection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def _fuzzy_intersection(self) -> TCounter[str]:
                    r"""Return the fuzzy intersection of the tokens in src and tar.
            
                    This implements the fuzzy intersection defined by :cite:`Wang:2014`.
            
            
            Severity: Minor
            Found in abydos/distance/_token_distance.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 sim has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

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

                def sim_score(self, src: str, tar: str) -> float:
                    """Return the Gotoh score of two strings.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in abydos/distance/_gotoh.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 idf has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def idf(
                    self, term: str, transform: Optional[Callable[[str], str]] = None
                ) -> float:
                    r"""Calculate the Inverse Document Frequency of a term in the corpus.
            
            
            Severity: Minor
            Found in abydos/corpus/_corpus.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 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 _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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                _GEN_EXACT_POLISH = (
                    ('B', '', '', 'a'),
                    ('F', '', '', 'e'),
                    ('P', '', '', 'o'),
                    ('E', '', '', 'e'),
                Severity: Minor
                Found in abydos/phonetic/_beider_morse_data.py and 1 other location - About 50 mins to fix
                abydos/phonetic/_beider_morse_data.py on lines 4554..4559

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 36.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                _ASH_EXACT_POLISH = (
                    ('B', '', '', 'a'),
                    ('F', '', '', 'e'),
                    ('P', '', '', 'o'),
                    ('E', '', '', 'e'),
                Severity: Minor
                Found in abydos/phonetic/_beider_morse_data.py and 1 other location - About 50 mins to fix
                abydos/phonetic/_beider_morse_data.py on lines 756..761

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 36.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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
                  Severity
                  Category
                  Status
                  Source
                  Language