Showing 209 of 209 total issues
Method resolve_weak_types
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
def resolve_weak_types
run_count = @runs.size
previous_level = @base_embedding
run_count.times do |run_idx|
- 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 emit
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
def emit(obj, level)
case obj
when Array
if (obj.length == 0)
'[]'
- 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 compute_explicit_levels
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def compute_explicit_levels
current_embedding = @base_embedding
# The directional override is a Character directionality
# constant. -1 means there is no override.
- 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 resolve_neutral_types
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def resolve_neutral_types
# This implements rules N1 and N2.
run_count = get_run_count
previous_level = @base_embedding
- 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 Locale
has 42 methods (exceeds 20 allowed). Consider refactoring. Open
class Locale
class << self
# http://unicode.org/reports/tr35/tr35-9.html#Likely_Subtags
#
Method divide_up_dictionary_range
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def divide_up_dictionary_range(cursor, end_pos, &block)
return to_enum(__method__, cursor, end_pos) unless block_given?
input_length = end_pos - cursor.position
best_snlp = Array.new(input_length + 1) { LARGE_NUMBER }
- 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 mark_best_candidate
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def mark_best_candidate(cursor, end_pos, state)
# if there was more than one, see which one can take us forward the most words
found_best = false
# if we're already at the end of the range, we're done
- 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 bidi.rb
has 345 lines of code (exceeds 250 allowed). Consider refactoring. Open
module TwitterCldr
module Shared
class Bidi
attr_reader :types, :levels, :string_arr
Method format_display_name
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def format_display_name(date, type, fmt, dst = TZInfo::Timezone.default_dst, &block)
date_int = date.strftime('%s').to_i
period = tz.period_for_local(date, dst, &block)
flavor = if type == :generic
- 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
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def process(str, rule_set)
# markers depend on what rule set we are using
buf = str.unpack("U*")
name = 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"
Further reading
Class RangeSet
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class RangeSet
include Enumerable
attr_reader :ranges
Method format_tokens
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def format_tokens(tokens, format, hour, min, sec)
''.tap do |result|
tokens.each do |token|
case token.type
when :plaintext
- 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_test_data
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def generate_test_data(transforms)
transforms.each_with_object([]) do |transform_id_str, ret|
forward_id = transform_id.parse(transform_id_str)
[forward_id, forward_id.reverse].each do |id|
- 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 CodePoint
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class CodePoint
DECOMPOSITION_REGEX = /^(?:<(.+)>\s+)?(.+)?$/
MAX_CODE_POINT = 1_112_111
attr_reader :fields
File yaml.rb
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
module TwitterCldr
module Utils
class YAML
Class LocalizedString
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class LocalizedString < LocalizedObject
include Enumerable
# Uses wrapped string object as a format specification and returns the result of applying it to +args+ (see
# standard String#% method documentation for interpolation syntax).
File date_time_formatter.rb
has 304 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'tzinfo'
module TwitterCldr
module Formatters
class DateTimeFormatter < Formatter
Method emit
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
def emit(obj, level)
case obj
when Array
if (obj.length == 0)
'[]'
Class UnicodeRegexParser
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class UnicodeRegexParser < Parser
autoload :Component, "twitter_cldr/parsers/unicode_regex/component"
autoload :CharacterClass, "twitter_cldr/parsers/unicode_regex/character_class"
autoload :CharacterRange, "twitter_cldr/parsers/unicode_regex/character_range"
Similar blocks of code found in 2 locations. Consider refactoring. Open
class UnitsImporter < Importer
requirement :cldr, Versions.cldr_version
output_path 'locales'
locales TwitterCldr.supported_locales
- 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 112.
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