Showing 64 of 67 total issues
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
Class Node
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Node # rubocop:disable Metrics/ClassLength
include Enumerable
include Traversal
attr_accessor :value
Class Terminal
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Terminal < Base # rubocop:disable Metrics/ClassLength
def missing_keys(forest = task.missing_keys)
forest = collapse_missing_tree! forest
if forest.present?
print_title missing_title(forest)
Method extract_literal_or_array_of_literals
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def extract_literal_or_array_of_literals(s)
literals = []
braces_stack = []
acc = []
consume_literal = proc do
- 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 split_key
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def split_key(key, max = Float::INFINITY)
return [key] if max == 1
parts = []
current_parenthesis_end_char = nil
- 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
Class CLI
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class I18n::Tasks::CLI
include ::I18n::Tasks::Logging
def self.start(argv)
new.start(argv)
Method scan_file
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def scan_file(path)
keys = []
text = read_file(path)
text.scan(@pattern) do |match|
src_pos = Regexp.last_match.offset(0).first
- 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 extract_string
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def extract_string(node, array_join_with: nil, array_flatten: false, array_reject_blank: false) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
return if node.nil?
if %i[sym str int].include?(node.type)
node.children[0].to_s
- 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 inconsistent_interpolations
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def inconsistent_interpolations(locales: nil, base_locale: nil) # rubocop:disable Metrics/AbcSize
locales ||= self.locales
base_locale ||= self.base_locale
result = empty_forest
variable_regex = I18n::Tasks::Interpolations.variable_regex
- 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 to_regexp_string
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def to_regexp_string # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
chars = smoosh(@pattern.chars)
curlies = 0
escaping = false
- 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 process_references
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def process_references(usages,
data_refs = merge_reference_trees(data_forest.select_keys { |_, node| node.reference? }))
fail ArgumentError, 'usages must be a Data::Tree::Instance' unless usages.is_a?(Data::Tree::Siblings)
fail ArgumentError, 'all_references must be a Data::Tree::Instance' unless data_refs.is_a?(Data::Tree::Siblings)
- 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 extract_array_as_string
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def extract_array_as_string(node, array_join_with:, array_flatten: false, array_reject_blank: false)
children_strings = node.children.map do |child|
if %i[sym str int true false].include?(child.type)
extract_string child
else
- 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_each_value!
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_each_value!(val_pattern, key_pattern = nil, &value_proc) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
value_proc ||= proc do |node|
node_value = node.value
next node_value if node.reference?
Method to_regexp_string
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_regexp_string # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
chars = smoosh(@pattern.chars)
curlies = 0
escaping = false
Method process_options
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def process_options(node:, key:)
return [key, nil] if node&.type != :hash
scope_node = extract_hash_pair(node, 'scope')
- 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 route
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def route(locale, forest, &block) # rubocop:disable Metrics/AbcSize
return to_enum(:route, locale, forest) unless block
out = Hash.new { |hash, key| hash[key] = Set.new }
not_found = Set.new
- 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"