Showing 745 of 745 total issues
Method init_pomap
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def init_pomap(po)
po.entries.each_with_index do |entry, i|
# skip PO file header if present
# TODO: update PO-Revision-Date, Last-Provider ?
next if entry.msgid == '' && i.zero?
- 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
Complex method Translatomatic::ResourceFile::Properties#render_element (24.2) Open
def render_element(element)
if element.is_a? Comment
return '' if element.text.nil?
comments = element.text.split(/[\r\n]+/)
comments.collect do |comment|
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Translatomatic::Translation::Munging#restore_preserved_text (23.8) Open
def restore_preserved_text(tr)
preserve_regex = tr.original.preserve_regex
return true unless preserve_regex
# find parts to preserve in the original string
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Translatomatic::CLI::Translate#total_translations (23.7) Open
def total_translations(source_files, locales)
total = 0
source_files.each do |source|
property_values = source.properties.values
texts = property_values.collect { |i| build_text(i, source.locale) }
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Translatomatic::TMX::Document::units_from_texts (23.0) Open
def units_from_texts(texts)
# group texts by from_text_id
texts_by_from_id = {}
texts.each do |text|
id = text.from_text_id || text.id
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Translatomatic::Translation::Munging#remove_notranslate (22.5) Open
def remove_notranslate(tr)
return tr unless tr.original.preserve_regex
original_spacing = find_notranslate_spacing(tr.original)
result_spacing = find_notranslate_spacing(tr.result)
if original_spacing.length != result_spacing.length
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Translatomatic::CLI::Translate#translate_file (22.1) Open
def translate_file(source, locales, listener)
file_opts = conf.all(for_file: source.path)
target_locales = determine_target_locales(locales, source)
ft_options = file_opts.merge(listener: listener)
ft = Translatomatic::FileTranslator.new(ft_options)
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Translatomatic::Translator#combine_parent_substrings (21.1) Open
def combine_parent_substrings(tr_collection, parent, to_locale)
# get a list of substring translations for this parent string
list = tr_collection.sentences(parent, to_locale)
# skip if we have no substrings for this string
return if list.blank?
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Method share
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def share(collection)
return if collection.empty?
tmx = Translatomatic::TMX::Document.from_collection(collection)
available = Translatomatic::Provider.available(@options)
- 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 wrap_notranslate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def wrap_notranslate(texts)
return texts unless use_notranslate? && texts.any?(&:preserve_regex)
texts.collect do |text|
if text.preserve_regex
text.gsub(text.preserve_regex) do |i|
- 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 save_database_translations
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def save_database_translations(translations)
return unless @use_db
ActiveRecord::Base.transaction do
from = db_locale(@from_locale)
to = db_locale(@to_locale)
- 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_string
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def process_string(string)
if @max_length && @length + string.length >= @max_length
raise t('translator.string_too_long') if @batch.empty?
yield_batch { |batch| yield batch }
end
- 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 load_source_files
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def load_source_files(file)
source_files = []
files = parse_list(file, conf.get(:source_files))
files.each do |path|
raise t('file.not_found', file: path) unless File.exist?(path)
- 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 texts_to_translations
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def texts_to_translations(db_texts, texts)
db_text_map = hashify(db_texts, proc { |i| i.from_text.value })
texts.collect do |text|
next unless (db_text = db_text_map[text.to_s])
@listener.update_progress(1) if @listener
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def set(key, value)
super(key, value)
if @pomap.include?(key)
po_property = @pomap[key]
- 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 parse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse(tag, validate = true)
return nil if tag.nil?
locale = tag
unless tag.is_a?(Translatomatic::Locale)
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(options = {})
@env = options[:database_env] || DEFAULT_ENV
@db_config = database_config(@env, options)
env_config = @db_config
unless env_config[@env]
- 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 paramify
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def paramify(object)
return object if object.is_a?(Param) || object.is_a?(FileParam)
raise 'invalid multipart parameter' unless object.is_a?(Hash)
object[:filename] ? FileParam.new(object) : Param.new(object)
end
- 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 options_from_object
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.options_from_object(object)
if object.is_a?(Translatomatic::Option)
[object]
elsif object.respond_to?(:options)
options_from_object(object.options)
- 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 cast
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cast(value, type, options = {})
value = value[0] if value.is_a?(Array) && !array_type?(type)
case type
when :boolean
- 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"