cloudinsight/opentsdb-ruby

View on GitHub
lib/opentsdb/query_param.rb

Summary

Maintainability
A
35 mins
Test Coverage

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

    def to_query_tags
      {}.tap do |qtags|
        tags.each do |tagk, tagv|
          qtags[tagk] = tagv.to_a.compact.join('|') if tagv.is_a?(Array) || tagv.is_a?(Set)
          qtags[tagk] = '*' if tagv.nil? || tagv.empty?
Severity: Minor
Found in lib/opentsdb/query_param.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 Opentsdb::QueryParam#end_time is defined at both lib/opentsdb/query_param.rb:6 and lib/opentsdb/query_param.rb:24.
Open

    def end_time
Severity: Minor
Found in lib/opentsdb/query_param.rb by rubocop

This cop checks for duplicated instance (or singleton) method definitions.

Example:

# bad

def duplicated
  1
end

def duplicated
  2
end

Example:

# bad

def duplicated
  1
end

alias duplicated other_duplicated

Example:

# good

def duplicated
  1
end

def other_duplicated
  2
end

Method Opentsdb::QueryParam#downsample is defined at both lib/opentsdb/query_param.rb:4 and lib/opentsdb/query_param.rb:45.
Open

    def downsample
Severity: Minor
Found in lib/opentsdb/query_param.rb by rubocop

This cop checks for duplicated instance (or singleton) method definitions.

Example:

# bad

def duplicated
  1
end

def duplicated
  2
end

Example:

# bad

def duplicated
  1
end

alias duplicated other_duplicated

Example:

# good

def duplicated
  1
end

def other_duplicated
  2
end

Use Integer instead of Fixnum.
Open

      time = time.is_a?(Fixnum) ? time : time.to_i
Severity: Minor
Found in lib/opentsdb/query_param.rb by rubocop

This cop checks for using Fixnum or Bignum constant.

Example:

# bad

1.is_a?(Fixnum)
1.is_a?(Bignum)

Example:

# good

1.is_a?(Integer)

Method Opentsdb::QueryParam#start_time is defined at both lib/opentsdb/query_param.rb:6 and lib/opentsdb/query_param.rb:20.
Open

    def start_time
Severity: Minor
Found in lib/opentsdb/query_param.rb by rubocop

This cop checks for duplicated instance (or singleton) method definitions.

Example:

# bad

def duplicated
  1
end

def duplicated
  2
end

Example:

# bad

def duplicated
  1
end

alias duplicated other_duplicated

Example:

# good

def duplicated
  1
end

def other_duplicated
  2
end

There are no issues that match your filters.

Category
Status