tensorflow/models

View on GitHub

Showing 11,634 of 11,634 total issues

Avoid deeply nested control flow statements.
Open

          if (len(qa["answers"]) != 1) and (not is_impossible):
            raise ValueError(
                "For training, each question should have exactly 1 answer.")
          if not is_impossible:
Severity: Major
Found in official/legacy/xlnet/squad_utils.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if use_batched_nms:
                  this_level_rois, this_level_roi_scores, _, _ = (
                      tf.image.combined_non_max_suppression(
                          tf.expand_dims(this_level_boxes, axis=2),
                          tf.expand_dims(this_level_scores, axis=-1),
    Severity: Major
    Found in official/legacy/detection/ops/roi_ops.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if gtm[tind, gind] > 0 and not iscrowd[gind]:
                    continue
                  # if dt matched to reg gt, and on ignore gt, stop
                  if m > -1 and gt_ig[m] == 0 and gt_ig[gind] == 1:
      Severity: Major
      Found in official/legacy/detection/evaluation/coco_evaluator.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if start_index >= feature.paragraph_len - 1:
                    continue
                  if end_index >= feature.paragraph_len - 1:
        Severity: Major
        Found in official/legacy/xlnet/squad_utils.py - About 45 mins to fix

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

            def __init__(self, min_level, max_level, num_scales, aspect_ratios,
          Severity: Minor
          Found in official/legacy/detection/dataloader/anchor.py - About 45 mins to fix

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

              def __init__(self,
            Severity: Minor
            Found in official/legacy/xlnet/squad_utils.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if end_index < start_index:
                          continue
                        length = end_index - start_index + 1
              Severity: Major
              Found in official/legacy/xlnet/squad_utils.py - About 45 mins to fix

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

                  def __init__(self, annotation_file, include_mask, need_rescale_bboxes=True):
                    """Constructs COCO evaluation class.
                
                    The class provides the interface to metrics_fn in TPUEstimator. The
                    _update_op() takes detections from each image and push them to
                Severity: Minor
                Found in official/legacy/detection/evaluation/coco_evaluator.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def __init__(self,
                               input_specs=tf_keras.layers.InputSpec(shape=[None, 640, 640, 3]),
                               min_level=3,
                               max_level=7,
                               block_specs=None,
                Severity: Minor
                Found in official/legacy/detection/modeling/architecture/spinenet.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def __init__(self,
                               min_level=3,
                               max_level=7,
                               fpn_feat_dims=256,
                               use_separable_conv=False,
                Severity: Minor
                Found in official/legacy/detection/modeling/architecture/fpn.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 end_index >= feature.paragraph_len - 1:
                            continue
                
                
                Severity: Major
                Found in official/legacy/xlnet/squad_utils.py - About 45 mins to fix

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

                    def evaluate(self):
                      """Evaluates with detections from all images with COCO API.
                  
                      Returns:
                        coco_metric: float numpy array with shape [24] representing the
                  Severity: Minor
                  Found in official/legacy/detection/evaluation/coco_evaluator.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 _build_class_net_layers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def _build_class_net_layers(self, norm_activation):
                      """Build re-usable layers for class prediction network."""
                      if self._use_separable_conv:
                        self._class_predict = tf_keras.layers.SeparableConv2D(
                            self._num_classes * self._anchors_per_location,
                  Severity: Minor
                  Found in official/legacy/detection/modeling/architecture/heads.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 find_all_best_thresh has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def find_all_best_thresh(main_eval, preds, exact_raw, f1_raw, na_probs,
                  Severity: Minor
                  Found in official/legacy/xlnet/squad_utils.py - About 45 mins to fix

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

                    def file_based_convert_examples_to_features(examples,
                    Severity: Minor
                    Found in official/legacy/xlnet/preprocess_classification_data.py - About 45 mins to fix

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

                      def _check_is_max_context(doc_spans, cur_span_index, position):
                        """Check if this is the "max context" doc span for the token."""
                      
                        # Because of the sliding window approach taken to scoring documents, a single
                        # token can appear in multiple documents. E.g.
                      Severity: Minor
                      Found in official/legacy/xlnet/squad_utils.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def __init__(self, d_model, d_inner, dropout, kernel_initializer,
                      Severity: Minor
                      Found in official/legacy/xlnet/xlnet_modeling.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                  if file_byte_budget < 0:
                                    break
                                  if correct_strip:
                        Severity: Major
                        Found in official/legacy/transformer/utils/tokenizer.py - About 45 mins to fix

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

                          def get_squad_input_data(batch_size, seq_len, q_len, strategy, is_training,
                          Severity: Minor
                          Found in official/legacy/xlnet/data_utils.py - About 45 mins to fix

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

                            def _word_span_mask(inputs, tgt_len, num_predict, min_num_words, max_num_words,
                            Severity: Minor
                            Found in official/legacy/xlnet/data_utils.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language