chrislit/abydos

View on GitHub
abydos/stemmer/_lovins.py

Summary

Maintainability
F
3 days
Test Coverage

File _lovins.py has 1006 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2014-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: Major
Found in abydos/stemmer/_lovins.py - About 2 days to fix

    Lovins has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Lovins(_Stemmer):
        """Lovins stemmer.
    
        The Lovins stemmer is described in Julie Beth Lovins's article
        :cite:`Lovins:1968`.
    Severity: Minor
    Found in abydos/stemmer/_lovins.py - About 4 hrs to fix

      Cyclomatic complexity is too high in method stem. (10)
      Open

          def stem(self, word: str) -> str:
              """Return Lovins stem.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/stemmer/_lovins.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

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

          def stem(self, word: str) -> str:
              """Return Lovins stem.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/stemmer/_lovins.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 _cond_n has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _cond_n(self, word: str, suffix_len: int) -> bool:
              """Return Lovins' condition N.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/stemmer/_lovins.py - About 35 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

      Method could be a function
      Open

          def _cond_f(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_cc(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_w(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_g(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_m(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_o(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_q(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _recode30(self, stem: str) -> str:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _recode32(self, stem: str) -> str:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_c(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_j(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_e(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Too few public methods (1/2)
      Open

      class Lovins(_Stemmer):
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when class has too few public methods, so be sure it's really worth it.

      Method could be a function
      Open

          def _cond_p(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_v(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _recode9(self, stem: str) -> str:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_b(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_n(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_u(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _recode28(self, stem: str) -> str:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_r(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_bb(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_s(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_x(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_y(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_i(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_h(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _recode24(self, stem: str) -> str:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_l(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_t(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_d(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_k(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_z(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Method could be a function
      Open

          def _cond_aa(self, word: str, suffix_len: int) -> bool:
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a method doesn't use its bound instance, and so could be written as a function.

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'ss',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'ss', ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'pp',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'pp', ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'gg',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'gg', ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'tt',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'tt', ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'll',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'll', ^ |

      Too many lines in module (1248/1000)
      Open

      # Copyright 2014-2020 by Christopher C. Little.
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      Used when a module has too many lines, reducing its readability.

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'mm',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'mm', ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'rr',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'rr', ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                      and len(word) - suffix_len >= 2
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO and len(word) - suffix_len >= 2 ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'dd',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'dd', ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'nn',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'nn', ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                      ending in self._suffix
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO ending in self._suffix ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                      and (
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO and ( ^ |

      Wrong hanging indentation before block (add 4 spaces).
      Open

                  'bb',
      Severity: Info
      Found in abydos/stemmer/_lovins.py by pylint

      TODO 'bb', ^ |

      There are no issues that match your filters.

      Category
      Status