tensorflow/models

View on GitHub
research/seq_flow_lite/trainer.py

Summary

Maintainability
A
3 hrs
Test Coverage

Function model_fn_builder has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def model_fn_builder(runner_config):
  """Returns `model_fn` closure for TPUEstimator."""

  rel_module_path = "" # empty base dir
  model = importlib.import_module(rel_module_path + runner_config["name"])
Severity: Minor
Found in research/seq_flow_lite/trainer.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 main has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def main(_):
  runner_config = load_runner_config()

  if FLAGS.output_dir:
    tf.gfile.MakeDirs(FLAGS.output_dir)
Severity: Minor
Found in research/seq_flow_lite/trainer.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

Function create_model has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def create_model(model, model_config, features, mode, model_name):
Severity: Minor
Found in research/seq_flow_lite/trainer.py - About 35 mins to fix

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

    def create_model(model, model_config, features, mode, model_name):
      """Creates a sequence labeling model."""
      keras_model = model.Encoder(model_config, mode)
      if any(model in model_name for model in ["pqrnn", "prado"]):
        logits = keras_model(features["projection"], features["seq_length"])
    Severity: Minor
    Found in research/seq_flow_lite/trainer.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