lib/opentsdb/query_param.rb
Method to_query_tags
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
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?
- Read upRead up
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
Open
def end_time
- Read upRead up
- Exclude checks
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
Open
def downsample
- Read upRead up
- Exclude checks
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
Open
time = time.is_a?(Fixnum) ? time : time.to_i
- Read upRead up
- Exclude checks
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
Open
def start_time
- Read upRead up
- Exclude checks
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