Showing 209 of 209 total issues
Method symbols
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def symbols
doc.xpath('//ldml/numbers/symbols').each_with_object({}) do |symbols_node, symbols_result|
number_system = if ns_node = symbols_node.attribute('numberSystem')
ns_node.value
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 format
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def format(number, options = {})
rule_group_name, rule_set_name = *if options[:rule_group].nil? && options[:rule_set].nil?
[DEFAULT_SPELLOUT_OPTIONS[:rule_group], DEFAULT_SPELLOUT_OPTIONS[:rule_set]]
else
[options[:rule_group], options[:rule_set]]
- 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 traverse_finding_best_fit
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def traverse_finding_best_fit(path_pattern, path, hash = resource)
if path_pattern.empty?
result = traverse_following_aliases(path, hash)
return result if result.is_a?(String)
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 parse
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse(number_text, options = {})
options[:strict] = true unless options.include?(:strict)
group, decimal = separators(options[:strict])
tokens = tokenize(number_text, group, decimal)
- 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 calculate_unit
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def calculate_unit(seconds, options = {})
approximate = options[:approximate]
approximate = false if approximate.nil?
multiplier = approximate ? APPROXIMATE_MULTIPLIER : 1
- 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 run_conformance_tests_with_icu
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_conformance_tests_with_icu(conformance_file, test_lines)
boundary_type = case File.basename(conformance_file)
when 'WordBreakTest.txt'
:word
when 'SentenceBreakTest.txt'
Method evaluate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def evaluate(node)
case node
when UnaryOperator, BinaryOperator
case node.operator
when :negate
Method preprocess
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def preprocess(tokens)
result = []
i = 0
while i < tokens.size
Method fractional_rule_for
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fractional_rule_for(number)
# the obvious way to do this (multiply the value being formatted
# by each rule's base value until you get an integral result)
# doesn't work because of rounding error. This method is more
# accurate
Method import_dictionary
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_dictionary(path, locale)
options = {}
rules = []
File.foreach(path).with_index do |line, idx|
Method reorder_visually!
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reorder_visually!
raise "No string given!" unless @string_arr
# Do this explicitly so we can also find the maximum depth at the
# same time.
Similar blocks of code found in 3 locations. Consider refactoring. Open
module Resources
module Properties
class PropListImporter < PropertyImporter
DATA_FILE = 'ucd/PropList.txt'
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 47.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
module Resources
module Properties
class EmojiImporter < PropertyImporter
DATA_FILE = 'ucd/emoji/emoji-data.txt'
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 47.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
module Resources
module Properties
class DerivedCorePropertiesImporter < PropertyImporter
DATA_FILE = 'ucd/DerivedCoreProperties.txt'
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 47.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method is_printable?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def is_printable?(ucs_code)
# YAML 1.1 / 4.1.1.
(
[0x09, 0x0a, 0x0d, 0x85].include?(ucs_code) ||
(ucs_code <= 0x7e && ucs_code >= 0x20) ||
- 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 find_matching_rule_at
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def find_matching_rule_at(cursor)
indexed_match = find_matching_indexed_rule_at(cursor)
blank_key_match = find_matching_blank_key_rule_at(cursor)
if indexed_match
- 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 string_type
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def string_type(str)
if str.respond_to?(:encoding) && (!str.valid_encoding? || str.encoding == Encoding::ASCII_8BIT)
return false, false, false, false
end
(ucs_codes = str.unpack('U*')) rescue (
- 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 yaml_escape
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def yaml_escape(str)
# YAML 1.1 / 4.1.6.
str.gsub(/[^a-zA-Z0-9]/u) do |c|
ucs_code, = (c.unpack('U') rescue [??])
case
- 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 lookup_code_point
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def lookup_code_point(code_point)
{}.tap do |properties|
each_property_pair do |property_name, property_value|
code_points = code_points_for_property(
property_name, property_value
- 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 generate_replacement
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def generate_replacement(number, rule, token)
if rule_set_name = token.rule_set_reference
RuleFormatter.format(
number,
rule_group.rule_set_for(rule_set_name),
- 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"