File _uea_lite.py
has 738 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2018-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
Function _stem_and_rule
has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring. Open
def _stem_and_rule(self, word: str) -> Tuple[str, float]:
"""Return UEA-Lite 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
Avoid too many return
statements within this function. Open
return word, 96
Avoid too many return
statements within this function. Open
return word, 91
Avoid too many return
statements within this function. Open
return word, 90.3
Avoid too many return
statements within this function. Open
return word, 92
Avoid too many return
statements within this function. Open
return word, 93
Avoid too many return
statements within this function. Open
return word[:-1], 91.1
Avoid too many return
statements within this function. Open
return word, 90.2
Avoid too many return
statements within this function. Open
return word, 90
Avoid too many return
statements within this function. Open
return word, 96
Avoid too many return
statements within this function. Open
return word, 97
Avoid too many return
statements within this function. Open
return word, 90.1
Avoid too many return
statements within this function. Open
return stemmed_word, rule_no
Refactor this function to reduce its Cognitive Complexity from 72 to the 15 allowed. Open
def _stem_and_rule(self, word: str) -> Tuple[str, float]:
- Read upRead up
- Exclude checks
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
Unnecessary else
after return
Open
if (
- Read upRead up
- Exclude checks
Used in order to highlight an unnecessary block of code following an if containing a return statement. As such, it will warn when it encounters an else following a chain of ifs, all of them containing a return statement.
Too many branches (28/12) Open
def _stem(word: str) -> Tuple[str, float]:
- Read upRead up
- Exclude checks
Used when a function or method has too many branches, making it hard to follow.
Too many statements (54/50) Open
def _stem_and_rule(self, word: str) -> Tuple[str, float]:
- Read upRead up
- Exclude checks
Used when a function or method has too many statements. You should then split it in smaller functions / methods.
Too few public methods (1/2) Open
class UEALite(_Stemmer):
- Read upRead up
- Exclude checks
Used when class has too few public methods, so be sure it's really worth it.
Too many return statements (16/6) Open
def _stem(word: str) -> Tuple[str, float]:
- Read upRead up
- Exclude checks
Used when a function or method has too many return statement, making it hard to follow.
Unnecessary else
after return
Open
if word.isdigit():
- Read upRead up
- Exclude checks
Used in order to highlight an unnecessary block of code following an if containing a return statement. As such, it will warn when it encounters an else following a chain of ifs, all of them containing a return statement.
Wrong hanging indentation before block (add 4 spaces). Open
and len(word) - 1 > self._max_acro_length
- Read upRead up
- Exclude checks
TODO and len(word) - 1 > self.maxacro_length ^ |
Wrong hanging indentation before block (add 4 spaces). Open
var: str = 'standard',
- Read upRead up
- Exclude checks
TODO var: str = 'standard', ^ |
Wrong hanging indentation before block (add 4 spaces). Open
max_acro_length: int = 8,
- Read upRead up
- Exclude checks
TODO maxacrolength: int = 8, ^ |
Wrong hanging indentation before block (add 4 spaces). Open
max_word_length: int = 20,
- Read upRead up
- Exclude checks
TODO maxwordlength: int = 20, ^ |
Wrong hanging indentation before block (add 4 spaces). Open
word[:hyphen].isalpha()
- Read upRead up
- Exclude checks
TODO word[:hyphen].isalpha() ^ |
Wrong hanging indentation before block (add 4 spaces). Open
word: str, del_len: int
- Read upRead up
- Exclude checks
TODO word: str, del_len: int ^ |
Wrong hanging indentation before block (add 4 spaces). Open
word == 'menses' and self._var == 'Adams'
- Read upRead up
- Exclude checks
TODO word == 'menses' and self._var == 'Adams' ^ |
Wrong hanging indentation before block (add 4 spaces). Open
self._var == 'Adams'
- Read upRead up
- Exclude checks
TODO self._var == 'Adams' ^ |
Variable name n
doesn't conform to snake_case naming style Open
for n in range(7, 1, -1):
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Wrong hanging indentation before block (add 4 spaces). Open
self._var == 'Adams'
- Read upRead up
- Exclude checks
TODO self._var == 'Adams' ^ |
Wrong hanging indentation before block (add 4 spaces). Open
self,
- Read upRead up
- Exclude checks
TODO self, ^ |
Wrong hanging indentation before block (add 4 spaces). Open
and len(word) > self._max_acro_length
- Read upRead up
- Exclude checks
TODO and len(word) > self.maxacro_length ^ |
Wrong hanging indentation before block (add 4 spaces). Open
and word[hyphen + 1 :].isalpha()
- Read upRead up
- Exclude checks
TODO and word[hyphen + 1 :].isalpha() ^ |
Wrong hanging indentation before block (add 4 spaces). Open
r'^[a-z](|[rl])(ing|ed)$', word
- Read upRead up
- Exclude checks
TODO r'^[a-z](|[rl])(ing|ed)$', word ^ |