keita/structx

View on GitHub

Showing 5 of 5 total issues

Method []= has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def []=(idx, val)
    case idx
    when Integer
      if size > idx && -size <= idx
        if not(immutable?)
Severity: Minor
Found in lib/structx.rb - About 2 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 inspect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def inspect
    name = self.class.inspect[0] == "#" ? "" : " " + self.class.inspect
    values = (@value || []).map do |key, val|
      k = (key.to_s[0] == "@" ? ":" : "") + key.to_s
      v = (self == val ? "#<struct %s:...>" % val : val.inspect)
Severity: Minor
Found in lib/structx.rb - About 55 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 [] has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def [](idx)
    case idx
    when Integer
      size > idx && -size <= idx ? values[idx] : (raise IndexError.new(idx))
    when Symbol, String
Severity: Minor
Found in lib/structx.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 __build_default_value__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def __build_default_value__(val, data)
    return val unless val.kind_of?(Proc)

    if val.arity == 1
      val.call(self)
Severity: Minor
Found in lib/structx.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

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

    def new(*args)
      # create an instance
      return orig_new(*args) if @__member__ and @__member__.keys.size > 0

      # create subclass
Severity: Minor
Found in lib/structx.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