chrislit/abydos

View on GitHub

Showing 4,191 of 4,191 total issues

Either merge this branch with the identical one on line "694" or change one of the implementations.
Open

                return _fmt_retval(self._match_type_dict['substitution'])
Severity: Major
Found in abydos/distance/_synoname.py by sonar-python

Having two branches in the same if structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

Noncompliant Code Example

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_thing()  # Noncompliant; duplicates first condition
else:
    do_the_rest()

b = 4 if a > 12 else 4

Compliant Solution

if (0 <= a < 10) or (20 <= a < 50):
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
else:
    do_the_rest()

b = 4

or

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_third_thing()
else:
    do_the_rest()

b = 8 if a > 12 else 4

Refactor this function to reduce its Cognitive Complexity from 122 to the 15 allowed.
Open

    def sim_type(
Severity: Critical
Found in abydos/distance/_synoname.py by sonar-python

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

Method "__init__" has 10 parameters, which is greater than the 7 authorized.
Open

        self,
        max_offset: int = 5,
        max_distance: int = 0,
        tokenizer: Optional[_Tokenizer] = None,
        token_matcher: Optional[Callable[[str, str], bool]] = None,

A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

Noncompliant Code Example

With a maximum number of 4 parameters:

def do_something(param1, param2, param3, param4, param5):
    ...

Compliant Solution

def do_something(param1, param2, param3, param4):
    ...

Rename field "corpus"
Open

        self.corpus = []  # type: List[List[List[str]]]
Severity: Major
Found in abydos/corpus/_corpus.py by sonar-python

It's confusing to have a class member with the same name (case differences aside) as its enclosing class. This is particularly so when you consider the common practice of naming a class instance for the class itself.

Best practice dictates that any field or member with the same name as the enclosing class be renamed to be more descriptive of the particular aspect of the class it represents or holds.

Noncompliant Code Example

class Foo:
  foo = ''

  def getFoo(self):
    ...

foo = Foo()
foo.getFoo() # what does this return?

Compliant Solution

class Foo:
  name = ''

  def getName(self):
    ...

foo = Foo()
foo.getName()

Refactor this function to reduce its Cognitive Complexity from 22 to the 15 allowed.
Open

    def corpus_importer(
Severity: Critical
Found in abydos/corpus/_ngram_corpus.py by sonar-python

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

Consider using enumerate instead of iterating with range and len
Open

            for j in range(len(nums)):
Severity: Info
Found in abydos/stats/_mean.py by pylint

Emitted when code that iterates with range and len is encountered. Such code can be simplified by using the enumerate builtin.

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

                self._tp == other[0]
Severity: Info
Found in abydos/stats/_confusion_table.py by pylint

TODO self._tp == other[0] ^ |

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

            and word[-1] == word[-2]
Severity: Info
Found in abydos/stemmer/_snowball_danish.py by pylint

TODO and word[-1] == word[-2] ^ |

Method could be a function
Open

    def stem(self, word: str) -> str:
Severity: Info
Found in abydos/stemmer/_stemmer.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

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

TODO 'bb', ^ |

Merge this if statement with the enclosing one.
Open

            if ca_ratio >= self._char_approx_min:
Severity: Major
Found in abydos/distance/_synoname.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Merge this if statement with the enclosing one.
Open

                if not ying[0].isdigit():
Severity: Major
Found in abydos/distance/_strcmp95.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed.
Open

def ipa_to_feature_dicts(ipa: str) -> List[Dict[str, str]]:
Severity: Critical
Found in abydos/phones/_phones.py by sonar-python

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

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

    metric: Optional[Callable[[str, str], float]] = None,
Severity: Info
Found in abydos/stats/_pairwise.py by pylint

TODO metric: Optional[Callable[[str, str], float]] = None, ^ |

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

                self._tp == other['tp']
Severity: Info
Found in abydos/stats/_confusion_table.py by pylint

TODO self._tp == other['tp'] ^ |

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

                and self._fp == other['fp']
Severity: Info
Found in abydos/stats/_confusion_table.py by pylint

TODO and self._fp == other['fp'] ^ |

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

                and self._fn == other['fn']
Severity: Info
Found in abydos/stats/_confusion_table.py by pylint

TODO and self._fn == other['fn'] ^ |

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

            'erede',
Severity: Info
Found in abydos/stemmer/_snowball_danish.py by pylint

TODO 'erede', ^ |

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

            'heder',
Severity: Info
Found in abydos/stemmer/_snowball_danish.py by pylint

TODO 'heder', ^ |

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

            len(word[r1_start:]) >= 1
Severity: Info
Found in abydos/stemmer/_snowball_danish.py by pylint

TODO len(word[r1_start:]) >= 1 ^ |

Severity
Category
Status
Source
Language