Class Siblings
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Siblings < Nodes # rubocop:disable Metrics/ClassLength
include ::I18n::Tasks::SplitKey
include ::I18n::Tasks::PluralKeys
attr_reader :parent, :key_to_node
Method mv_key!
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def mv_key!(from_pattern, to_pattern, root: false, retain: false) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
moved_forest = Siblings.new
moved_nodes = []
old_key_to_new_key = {}
nodes do |node|
- 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
File siblings.rb
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'set'
require 'i18n/tasks/split_key'
require 'i18n/tasks/data/tree/nodes'
module I18n::Tasks::Data::Tree
Method merge_node!
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def merge_node!(node, on_leaves_merge: nil) # rubocop:disable Metrics/AbcSize
if key_to_node.key?(node.key)
our = key_to_node[node.key]
return if our == node
- 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 set
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def set(full_key, node)
fail 'value should be a I18n::Tasks::Data::Tree::Node' unless node.is_a?(Node)
key_part, rest = split_key(full_key, 2)
child = key_to_node[key_part]
- 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 mv_key!
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mv_key!(from_pattern, to_pattern, root: false, retain: false) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
moved_forest = Siblings.new
moved_nodes = []
old_key_to_new_key = {}
nodes do |node|
Method from_key_attr
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def from_key_attr(key_attrs, opts = {}, &block)
build_forest(opts) do |forest|
key_attrs.each do |(full_key, attr)|
fail "Invalid key #{full_key.inspect}" if full_key.end_with?('.')
- 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
TODO found Open
# TODO: support nested references better
- Exclude checks