somaticio/tensorflow.rb

View on GitHub

Showing 9 of 9 total issues

Method find_type has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def find_type(data)
        first_element = rank.zero? ? data : data.flatten[0]

        type, self.type_num, self.data_size = case first_element
                                              when Integer
Severity: Minor
Found in lib/tensorflow/tensor.rb - 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

Method set_attributes has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def set_attributes(cdesc, status, name, value)
        cAttrName = CString(name)
        if value.is_a?(Hash)
           value, type = value.first
        end
Severity: Major
Found in lib/tensorflow/graph.rb - About 2 hrs to fix

    Method find_type has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def find_type(data)
            first_element = rank.zero? ? data : data.flatten[0]
    
            type, self.type_num, self.data_size = case first_element
                                                  when Integer
    Severity: Minor
    Found in lib/tensorflow/tensor.rb - About 1 hr to fix

      Method shape_of has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.shape_of(value)
              if value.is_a?(Array)
                  if value.any? { |ele| ele.is_a?(Array) }
                      dim = value.group_by { |ele| ele.is_a?(Array) && shape_of(ele) }.keys
                      [value.size] + dim.first if dim.size == 1 && dim.first
      Severity: Minor
      Found in lib/tensorflow/tensor.rb - 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

      Method set_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_attributes(cdesc, status, name, value)
              cAttrName = CString(name)
              if value.is_a?(Hash)
                 value, type = value.first
              end
      Severity: Minor
      Found in lib/tensorflow/graph.rb - 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

      Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(name = nil, type = nil, attribute = nil, input = nil, inputlist = nil)
              self.name = name
              self.type = type
              self.attr = if attribute.nil?
                              {}
      Severity: Minor
      Found in lib/tensorflow/opspec.rb - 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

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(name = nil, type = nil, attribute = nil, input = nil, inputlist = nil)
      Severity: Minor
      Found in lib/tensorflow/opspec.rb - About 35 mins to fix

        Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(value, type = nil)
                self.shape = self.class.shape_of(value)
                self.rank = shape.size
                self.element_type = type.nil? ? find_type(value) : set_type(type)
                if rank > 1 && type_num == Tensorflow::TF_STRING
        Severity: Minor
        Found in lib/tensorflow/tensor.rb - 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

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

            def AddOperation(opspec)
                opspec.name = opspec.type if opspec.name.nil?
                opspec.name = opspec.type if opspec.name == ''
                cname = CString(opspec.name)
                ctype = CString(opspec.type)
        Severity: Minor
        Found in lib/tensorflow/graph.rb - 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

        Severity
        Category
        Status
        Source
        Language