chrislit/abydos

View on GitHub

Showing 4,191 of 4,191 total issues

Consider simplifying this complex logical expression.
Open

            if (
                lokal_ordet[0:1] in self._mjuka_vokaler
                or lokal_ordet[0:1] in self._harde_vokaler
            ):
                lokal_ordet = '$' + lokal_ordet[1:]
Severity: Critical
Found in abydos/phonetic/_sfinx_bis.py - About 1 hr to fix

    Function sim_type has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def sim_type(
            self,
            src: Union[str, Tuple[str, str, str]],
            tar: Union[str, Tuple[str, str, str]],
            force_numeric: bool = False,
    Severity: Minor
    Found in abydos/distance/_synoname.py - About 1 hr to fix

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

      def pairwise_similarity_statistics(
          src_collection: Union[Sequence[str], Set[str]],
          tar_collection: Union[Sequence[str], Set[str]],
          metric: Optional[Callable[[str, str], float]] = None,
          mean_func: Callable[[Sequence[float]], float] = amean,
      Severity: Minor
      Found in abydos/stats/_pairwise.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 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 stem has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

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

          def lcsseq(self, src: str, tar: str) -> str:
              """Return the longest common subsequence of two strings.
      
              Based on the dynamic programming algorithm from
              http://rosettacode.org/wiki/Longest_common_subsequence
      Severity: Minor
      Found in abydos/distance/_lcsseq.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 fingerprint_int has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def fingerprint_int(self, word: str) -> int:
              """Return the position fingerprint.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/fingerprint/_position.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 tokenize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def tokenize(self, string: str) -> 'SAPSTokenizer':
              """Tokenize the term and store it.
      
              The tokenized term is stored as an ordered list and as a Counter
              object.
      Severity: Minor
      Found in abydos/tokenizer/_saps.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 encode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def encode(self, word: str) -> str:
              """Return the Fuzzy Soundex code for a word.
      
              Parameters
              ----------
      Severity: Minor
      Found in abydos/phonetic/_fuzzy_soundex.py - About 1 hr to fix

        Function alignments has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def alignments(
                self, src: str, tar: str, score_only: bool = False
            ) -> Union[float, List[Tuple[float, str, str]]]:
                """Return the ALINE alignments of two strings.
        
        
        Severity: Minor
        Found in abydos/distance/_aline.py - About 1 hr to fix

          Function _encode_next has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def _encode_next(self, word: str) -> Tuple[str, str]:
                  if word[:3] == 'STI' and word[3:4] in {'E', 'Ä'}:
                      code = '*'
                      remainder = word[3:]
                  elif word[:3] in self._transforms[3]:
          Severity: Minor
          Found in abydos/phonetic/_waahlin.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 mean_pairwise_similarity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def mean_pairwise_similarity(
              collection: Union[str, Sequence[str], Set[str]],
              metric: Optional[Callable[[str, str], float]] = None,
              mean_func: Callable[[Sequence[float]], float] = hmean,
              symmetric: bool = False,
          Severity: Minor
          Found in abydos/stats/_pairwise.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 hmean has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def hmean(nums: Sequence[float]) -> float:
              r"""Return harmonic mean.
          
              The harmonic mean is defined as
          
          
          Severity: Minor
          Found in abydos/stats/_mean.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 fingerprint_int has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def fingerprint_int(self, word: str) -> int:
                  """Return the occurrence halved fingerprint.
          
                  Based on the occurrence halved fingerprint from :cite:`Cislak:2017`.
          
          
          Severity: Minor
          Found in abydos/fingerprint/_occurrence_halved.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 sim has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def sim(self, src: str, tar: str) -> float:
                  """Return the Monge-Elkan similarity of two strings.
          
                  Parameters
                  ----------
          Severity: Minor
          Found in abydos/distance/_monge_elkan.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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(
                  self,
                  max_offset: int = 5,
                  max_distance: int = 0,
                  tokenizer: Optional[_Tokenizer] = None,
          Severity: Minor
          Found in abydos/distance/_sift4_extended.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 sim has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def sim(self, src: str, tar: str) -> float:
                  r"""Return the Soft Cosine similarity of two strings.
          
                  Parameters
                  ----------
          Severity: Minor
          Found in abydos/distance/_soft_cosine.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

          Consider simplifying this complex logical expression.
          Open

                  if word[:3] == 'STI' and word[3:4] in {'E', 'Ä'}:
                      code = '*'
                      remainder = word[3:]
                  elif word[:3] in self._transforms[3]:
                      code = self._transforms[3][word[:3]]
          Severity: Critical
          Found in abydos/phonetic/_waahlin.py - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                            if pos >= 0:
                                # check rules for this char
                                while (_phonet_rules[pos] is None) or (
                                    cast(str, _phonet_rules[pos])[0] == char
                                ):
            Severity: Critical
            Found in abydos/phonetic/_phonet.py - About 1 hr to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              Severity: Major
              Found in abydos/compression/__init__.py and 1 other location - About 1 hr to fix
              abydos/corpus/__init__.py on lines 0..64

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 42.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language