tensorflow/models

View on GitHub
research/adversarial_text/data/document_generators.py

Summary

Maintainability
D
1 day
Test Coverage

Function rt_documents has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def rt_documents(dataset='train',
                 include_unlabeled=True,
                 include_validation=False):
  # pylint:disable=line-too-long
  """Generates Documents for the Rotten Tomatoes dataset.
Severity: Minor
Found in research/adversarial_text/data/document_generators.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 tokens has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def tokens(doc):
  """Given a Document, produces character or word tokens.

  Tokens can be either characters, or word-level tokens (unigrams and/or
  bigrams).
Severity: Minor
Found in research/adversarial_text/data/document_generators.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

File document_generators.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2017 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Minor
Found in research/adversarial_text/data/document_generators.py - About 2 hrs to fix

    Function imdb_documents has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def imdb_documents(dataset='train',
                       include_unlabeled=False,
                       include_validation=False):
      """Generates Documents for IMDB dataset.
    
    
    Severity: Minor
    Found in research/adversarial_text/data/document_generators.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 rcv1_documents has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def rcv1_documents(dataset='train',
                       include_unlabeled=True,
                       include_validation=False):
      # pylint:disable=line-too-long
      """Generates Documents for Reuters Corpus (rcv1) dataset.
    Severity: Minor
    Found in research/adversarial_text/data/document_generators.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 documents has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def documents(dataset='train',
                  include_unlabeled=False,
                  include_validation=False):
      """Generates Documents based on FLAGS.dataset.
    
    
    Severity: Minor
    Found in research/adversarial_text/data/document_generators.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 content.startswith('review/text'):
                yield Document(
                    content=content,
                    is_validation=False,
                    is_test=False,
    Severity: Major
    Found in research/adversarial_text/data/document_generators.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (is_test and dataset != 'test') or (is_validation and
                                                       not include_validation):
                  continue
      
      
      Severity: Major
      Found in research/adversarial_text/data/document_generators.py - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status