chrislit/abydos

View on GitHub
abydos/stemmer/_uea_lite.py

Summary

Maintainability
F
3 days
Test Coverage

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
Severity: Major
Found in abydos/stemmer/_uea_lite.py - About 1 day to fix

    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
            ----------
    Severity: Minor
    Found in abydos/stemmer/_uea_lite.py - About 1 day 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

    Avoid too many return statements within this function.
    Open

                            return word, 96
    Severity: Major
    Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                          return word, 91
      Severity: Major
      Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return word, 90.3
        Severity: Major
        Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return word, 92
          Severity: Major
          Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                                return word, 93
            Severity: Major
            Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return word[:-1], 91.1
              Severity: Major
              Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                        return word, 90.2
                Severity: Major
                Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                      return word, 90
                  Severity: Major
                  Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                            return word, 96
                    Severity: Major
                    Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                          return word, 97
                      Severity: Major
                      Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                                return word, 90.1
                        Severity: Major
                        Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return stemmed_word, rule_no
                          Severity: Major
                          Found in abydos/stemmer/_uea_lite.py - About 30 mins to fix

                            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]:
                            Severity: Critical
                            Found in abydos/stemmer/_uea_lite.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

                            Unnecessary else after return
                            Open

                                                if (
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            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]:
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            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]:
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            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):
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            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]:
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            Used when a function or method has too many return statement, making it hard to follow.

                            Unnecessary else after return
                            Open

                                        if word.isdigit():
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            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
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO and len(word) - 1 > self.maxacro_length ^ |

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

                                    var: str = 'standard',
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO var: str = 'standard', ^ |

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

                                    max_acro_length: int = 8,
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO maxacrolength: int = 8, ^ |

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

                                    max_word_length: int = 20,
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO maxwordlength: int = 20, ^ |

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

                                                    word[:hyphen].isalpha()
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO word[:hyphen].isalpha() ^ |

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

                                        word: str, del_len: int
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO word: str, del_len: int ^ |

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

                                            word == 'menses' and self._var == 'Adams'
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO word == 'menses' and self._var == 'Adams' ^ |

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

                                                    self._var == 'Adams'
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO self._var == 'Adams' ^ |

                            Variable name n doesn't conform to snake_case naming style
                            Open

                                        for n in range(7, 1, -1):
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            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'
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO self._var == 'Adams' ^ |

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

                                    self,
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO self, ^ |

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

                                                    and len(word) > self._max_acro_length
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO and len(word) > self.maxacro_length ^ |

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

                                                    and word[hyphen + 1 :].isalpha()
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO and word[hyphen + 1 :].isalpha() ^ |

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

                                                r'^[a-z](|[rl])(ing|ed)$', word
                            Severity: Info
                            Found in abydos/stemmer/_uea_lite.py by pylint

                            TODO r'^[a-z](|[rl])(ing|ed)$', word ^ |

                            There are no issues that match your filters.

                            Category
                            Status