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
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`.
Cyclomatic complexity is too high in method stem. (10) Open
def stem(self, word: str) -> str:
"""Return Lovins stem.
Parameters
----------
- Read upRead up
- Exclude checks
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. |
Function stem
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def stem(self, word: str) -> str:
"""Return Lovins stem.
Parameters
----------
- Read upRead up
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
----------
- Read upRead up
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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):
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
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',
- Read upRead up
- Exclude checks
TODO 'ss', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
'pp',
- Read upRead up
- Exclude checks
TODO 'pp', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
'gg',
- Read upRead up
- Exclude checks
TODO 'gg', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
'tt',
- Read upRead up
- Exclude checks
TODO 'tt', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
'll',
- Read upRead up
- Exclude checks
TODO 'll', ^ |
Too many lines in module (1248/1000) Open
# Copyright 2014-2020 by Christopher C. Little.
- Read upRead up
- Exclude checks
Used when a module has too many lines, reducing its readability.
Wrong hanging indentation before block (add 4 spaces). Open
'mm',
- Read upRead up
- Exclude checks
TODO 'mm', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
'rr',
- Read upRead up
- Exclude checks
TODO 'rr', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
and len(word) - suffix_len >= 2
- Read upRead up
- Exclude checks
TODO and len(word) - suffix_len >= 2 ^ |
Wrong hanging indentation before block (add 4 spaces). Open
'dd',
- Read upRead up
- Exclude checks
TODO 'dd', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
'nn',
- Read upRead up
- Exclude checks
TODO 'nn', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
ending in self._suffix
- Read upRead up
- Exclude checks
TODO ending in self._suffix ^ |
Wrong hanging indentation before block (add 4 spaces). Open
and (
- Read upRead up
- Exclude checks
TODO and ( ^ |
Wrong hanging indentation before block (add 4 spaces). Open
'bb',
- Read upRead up
- Exclude checks
TODO 'bb', ^ |