chrislit/abydos

View on GitHub

Showing 4,191 of 4,191 total issues

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

Severity: Major
Found in abydos/corpus/__init__.py and 1 other location - About 1 hr to fix
abydos/compression/__init__.py on lines 0..54

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 42.

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

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 _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 _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 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 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 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 _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 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 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 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

      Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in abydos/distance/_aline.py - About 1 hr to fix

        Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in abydos/distance/_sift4_extended.py - About 1 hr to fix

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

              def encode(self, word: str) -> str:
                  """Return the Roger Root code for a word.
          
                  Parameters
                  ----------
          Severity: Minor
          Found in abydos/phonetic/_roger_root.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def stem(self, word: str) -> str:
                  """Return 'CLEF German stemmer plus' stem.
          
                  Parameters
                  ----------
          Severity: Minor
          Found in abydos/stemmer/_clef_german_plus.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 _apply_rule has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def _apply_rule(
                  self,
                  word: str,
                  rule: Tuple[bool, int, Optional[str], bool],
                  intact: bool,
          Severity: Minor
          Found in abydos/stemmer/_paice_husk.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def encode(self, word: str) -> str:
                  """Return Reth-Schek Phonetik code for a word.
          
                  Parameters
                  ----------
          Severity: Minor
          Found in abydos/phonetic/_reth_schek.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_score has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

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

          Severity
          Category
          Status
          Source
          Language