tensorflow/tensorflow

View on GitHub

Showing 8,389 of 21,100 total issues

Avoid too many return statements within this function.
Open

        return b.x - a.x if a_first else a.x - b.x
Severity: Major
Found in tensorflow/dtensor/python/tpu_util.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return default_types.NamedTuple.from_type_and_attributes(
    Severity: Major
    Found in tensorflow/core/function/trace_type/trace_type_builder.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return default_types.Dict(
      Severity: Major
      Found in tensorflow/core/function/trace_type/trace_type_builder.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return custom_nest_trace_type.CustomNestTraceType(
        Severity: Major
        Found in tensorflow/core/function/trace_type/trace_type_builder.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return default_types_pb2.SerializedLiteral(
          Severity: Major
          Found in tensorflow/core/function/trace_type/default_types.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return default_types.Literal(value)
            Severity: Major
            Found in tensorflow/core/function/trace_type/trace_type_builder.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return node.resource_handle
              Severity: Major
              Found in tensorflow/core/function/capture/restore_captures.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return node.asset_path
                Severity: Major
                Found in tensorflow/core/function/capture/restore_captures.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return node
                  Severity: Major
                  Found in tensorflow/core/function/capture/restore_captures.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return fb
                    Severity: Major
                    Found in tensorflow/lite/tools/visualize.py - About 30 mins to fix

                      Method copyTo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        private void copyTo(Buffer dst) {
                          // There is no base Buffer#put() method, so we have to ugly cast.
                          if (dst instanceof ByteBuffer) {
                            ((ByteBuffer) dst).put(buffer());
                          } else if (dst instanceof FloatBuffer) {
                      Severity: Minor
                      Found in tensorflow/lite/java/src/main/java/org/tensorflow/lite/TensorImpl.java - About 25 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

                      Method throwIfDstShapeIsIncompatible has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        private void throwIfDstShapeIsIncompatible(Object dst) {
                          if (isBuffer(dst)) {
                            Buffer dstBuffer = (Buffer) dst;
                            int bytes = numBytes();
                            // Note that we allow the client to provide a ByteBuffer even for non-byte Tensors.
                      Severity: Minor
                      Found in tensorflow/lite/java/src/main/java/org/tensorflow/lite/TensorImpl.java - About 25 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

                      Method copyTo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        void copyTo(Object dst) {
                          if (dst == null) {
                            if (hasDelegateBufferHandle(nativeHandle)) {
                              return;
                            }
                      Severity: Minor
                      Found in tensorflow/lite/java/src/main/java/org/tensorflow/lite/TensorImpl.java - About 25 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

                      Method throwIfSrcShapeIsIncompatible has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        private void throwIfSrcShapeIsIncompatible(Object src) {
                          if (isBuffer(src)) {
                            Buffer srcBuffer = (Buffer) src;
                            int bytes = numBytes();
                            // Note that we allow the client to provide a ByteBuffer even for non-byte Tensors.
                      Severity: Minor
                      Found in tensorflow/lite/java/src/main/java/org/tensorflow/lite/TensorImpl.java - About 25 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

                      Method classifyByteBuffer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public OvicClassificationResult classifyByteBuffer(ByteBuffer imgData) {
                          if (tflite == null) {
                            throw new RuntimeException(TAG + ": ImageNet classifier has not been initialized; Failed.");
                          }
                          if (outputIsFloat == null) {

                      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

                      Method readCpusAllowedMask has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public static int readCpusAllowedMask() throws IOException {
                          // Determine how many CPUs there are total
                          final String pathname = "/proc/self/status";
                          final String resultPrefix = "Cpus_allowed:";
                          File file = new File(pathname);
                      Severity: Minor
                      Found in tensorflow/lite/java/ovic/demo/app/OvicBenchmarkerActivity.java - About 25 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

                      Method computeTopKLabels has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        private OvicClassificationResult computeTopKLabels() {
                          if (labelList == null) {
                            throw new RuntimeException("Label file has not been loaded.");
                          }
                          for (int i = 0; i < labelList.size(); ++i) {

                      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 testMemoryStats has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def testMemoryStats(self):
                            for device in self.backend.local_devices():
                              stats = device.memory_stats()
                              if (
                                  self.backend.platform != "tpu" or not tfrt_tpu
                      Severity: Minor
                      Found in third_party/xla/xla/python/xla_client_test.py - About 25 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 test_table_collections_untouched_eager has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def test_table_collections_untouched_eager(self, cycles, use_cpp_bindings):
                          # TODO(b/264869228) Fix LoadTest
                          if use_cpp_bindings:
                            self.skipTest("Not implemented for cpp.")
                      
                      
                      Severity: Minor
                      Found in tensorflow/python/saved_model/load_test.py - About 25 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 _expand_cmakedefines has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def _expand_cmakedefines(line, cmake_vars):
                        """Expands #cmakedefine declarations, using a dictionary 'cmake_vars'."""
                      
                        # Handles #cmakedefine lines
                        match = _CMAKE_DEFINE_REGEX.match(line)

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language