lib/cequel/type.rb
Method cast
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def cast(value)
if value.is_a? Cassandra::Uuid then value
elsif defined?(SimpleUUID::UUID) && value.is_a?(SimpleUUID::UUID)
Cassandra::Uuid.new(value.to_i)
elsif value.is_a?(::Integer) || value.is_a?(::String)
- 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
Unnecessary utf-8 encoding comment. Open
Open
# -*- encoding : utf-8 -*-
- Exclude checks
Freeze mutable objects assigned to constants. Open
Open
BY_INTERNAL_NAME = {}
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Freeze mutable objects assigned to constants. Open
Open
BY_CQL_NAME = {}
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Add an empty line after magic comments. Open
Open
require 'singleton'
- Read upRead up
- Exclude checks
Checks for a newline after the final magic comment.
Example:
# good
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end