IlyaGusev/rupo

View on GitHub

Showing 117 of 117 total issues

Function __process_line has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __process_line(line: str, output_file: TextIO, sentence_splitter: SentenceSplitter,
                       morph_predictor: RNNMorphPredictor):
        sentences = sentence_splitter.split(line)
        for sentence in sentences:
            words = [token.text for token in Tokenizer.tokenize(sentence)
Severity: Minor
Found in rupo/main/morph.py - About 55 mins 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 write_markups has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def write_markups(destination_type: FileType, markups: List[Markup], path: str) -> None:
        """
        Запись разметок в файл.

        :param destination_type: тип файла.
Severity: Minor
Found in rupo/files/writer.py - About 55 mins 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 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, language: str="ru", mode: Mode=Mode.GRAPHEMES, raw_dict_path=None, trie_path=None,
Severity: Major
Found in rupo/stress/dict.py - About 50 mins to fix

    Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self,
    Severity: Major
    Found in rupo/generate/transforms.py - About 50 mins to fix

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

              self.assertNotEqual(markup.lines[0].words[0].syllables[0].stress, -1)
      Severity: Minor
      Found in rupo/metre/test_metre_classifier.py and 1 other location - About 50 mins to fix
      rupo/metre/test_metre_classifier.py on lines 139..139

      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 36.

      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

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

              self.assertEqual(markup.lines[0].words[0].syllables[1].stress, -1)
      Severity: Minor
      Found in rupo/metre/test_metre_classifier.py and 1 other location - About 50 mins to fix
      rupo/metre/test_metre_classifier.py on lines 138..138

      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 36.

      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

      Avoid deeply nested control flow statements.
      Open

                              if ch == "'" or ch == "`":
                                  if ch == "`":
                                      secondary.append(pos)
                                  else:
                                      primary.append(pos)
      Severity: Major
      Found in rupo/dict/zaliznyak.py - About 45 mins to fix

        Function add_record has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def add_record(self, metre_name, line_num, strong_errors, weak_errors, pattern, failed=False):
        Severity: Minor
        Found in rupo/metre/metre_classifier.py - About 45 mins to fix

          Function get_stress_predictor has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def get_stress_predictor(self, language="ru", stress_model_path: str=None, raw_stress_dict_path=None,
          Severity: Minor
          Found in rupo/api.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if int(phoneme[-1]) == 2:
                                        secondary.append(str(i+diphtongs_count))
                                    phonemes[i] = phoneme[:-1]
            Severity: Major
            Found in rupo/dict/cmu.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if ch == "ё":
                                          primary.append(pos)
                                  if len(primary) != 0:
              Severity: Major
              Found in rupo/dict/zaliznyak.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if int(phoneme[-1]) == 1:
                                            primary.append(str(i+diphtongs_count))
                                        if int(phoneme[-1]) == 2:
                Severity: Major
                Found in rupo/dict/cmu.py - About 45 mins to fix

                  Function __call__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __call__(self, probabilities: np.array) -> np.array:
                          if self.rhyme_position < 0 and self.stress_position == len(self.metre_pattern) - 1:
                              probabilities = np.zeros(probabilities.shape, dtype="float")
                              probabilities[self.eos_index] = 1.
                              return probabilities
                  Severity: Minor
                  Found in rupo/generate/transforms.py - About 45 mins 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 deeply nested control flow statements.
                  Open

                                          if stress_count == 1 and other_syllable.stress == -1:
                                              corrections.append(ac)
                                          else:
                                              resolutions.append(ac)
                                  number_in_pattern += 1
                  Severity: Major
                  Found in rupo/metre/metre_classifier.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            for item in j['items']:
                                                yield Markup().from_dict(item)
                                        elif source_type == FileType.RAW:
                    Severity: Major
                    Found in rupo/files/reader.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if text != "":
                                                  yield Markup().from_raw(text)
                                      else:
                      Severity: Major
                      Found in rupo/files/reader.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if syllable.number == other_syllable.number or pattern[other_number_in_pattern].lower() != "s":
                                                    continue
                                                ac = StressCorrection(line_number, w, other_syllable.number, word.text, other_syllable.vowel())
                        Severity: Major
                        Found in rupo/metre/metre_classifier.py - About 45 mins to fix

                          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def __init__(self, language="ru", stress_model_path: str=RU_STRESS_DEFAULT_MODEL, raw_stress_dict_path=None,
                          Severity: Minor
                          Found in rupo/stress/predictor.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    for elem in Reader.__xml_iter(file, 'markup'):
                                                        yield Markup().from_xml(etree.tostring(elem, encoding='utf-8', method='xml'))
                                                elif source_type == FileType.JSON:
                            Severity: Major
                            Found in rupo/files/reader.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      for line in file:
                                                          if line == "\n":
                                                              separator_count += 1
                                                          else:
                                                              text += line
                              Severity: Major
                              Found in rupo/files/reader.py - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language