IlyaGusev/rnnmorph

View on GitHub
rnnmorph/batch_generator.py

Summary

Maintainability
C
1 day
Test Coverage

Function __iter__ has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def __iter__(self):
        """
        Получение очередного батча.

        :return: индексы словоформ, грамматические векторы, ответы-индексы.
Severity: Minor
Found in rnnmorph/batch_generator.py - About 3 hrs 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 get_sample has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def get_sample(sentence: List[str],
                   language: str,
                   converter,
                   morph: MorphAnalyzer,
                   grammeme_vectorizer: GrammemeVectorizer,
Severity: Minor
Found in rnnmorph/batch_generator.py - About 2 hrs 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 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, language: str,
Severity: Major
Found in rnnmorph/batch_generator.py - About 1 hr to fix

    Function get_sample has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def get_sample(sentence: List[str],
    Severity: Major
    Found in rnnmorph/batch_generator.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                              for index, bucket in enumerate(self.buckets):
                                  if self.bucket_borders[index][0] <= len(last_sentence) < self.bucket_borders[index][1]:
                                      bucket.append(last_sentence)
                                  if len(bucket) >= self.batch_size:
                                      yield self.__to_tensor(bucket)
      Severity: Major
      Found in rnnmorph/batch_generator.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if i not in self.indices:
                                    last_sentence = []
                                    i += 1
                                    continue
                                for index, bucket in enumerate(self.buckets):
        Severity: Major
        Found in rnnmorph/batch_generator.py - About 45 mins to fix

          Function __to_tensor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def __to_tensor(self, sentences: List[List[WordForm]]) -> Tuple[List, List]:
                  """
                  Преобразование предложений в признаки и ответы.
          
                  :param sentences: предложения (с разобранными словоформами).
          Severity: Minor
          Found in rnnmorph/batch_generator.py - About 35 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

          There are no issues that match your filters.

          Category
          Status