somaticio/tensorflow.rb

View on GitHub
lib/tensorflow/tensor.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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 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 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

    There are no issues that match your filters.

    Category
    Status