Showing 136 of 136 total issues
Method draw_rect_in_context
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def draw_rect_in_context(context, options)
rect = options.fetch(:rect)
radius = options.fetch(:radius, 0)
rounded_corners = options[:rounded_corners] || [:top_left, :top_right, :bottom_right, :bottom_left]
Method set_layer_options
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_layer_options(key, value)
if key == 'rounded_corners'
layer_bounds = bounds
if value[:overlap]
size = layer_bounds.size
Method draw_in_context
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def draw_in_context(context)
return if computed_options[:hidden]
size_to_fit_if_needed
set_text_position
- 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_text_options
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def set_text_options(key, value)
if key == 'content_horizontal_alignment' && value.is_a?(Symbol) && %[left right center fill].include?(value.to_s)
view.setValue class_factory("UIControlContentHorizontalAlignment_#{value.camelize}"), forKey: camelize_factory(key)
true
elsif key == 'content_vertical_alignment' && value.is_a?(Symbol) && %[top bottom center fill].include?(value.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 preload_sections_schedule_from
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def preload_sections_schedule_from(index, load_count)
service = preloader_index_service
@preloader_queue ||= []
Method load_image
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def load_image
return if @loading || image_data || !computed_options[:url]
@loading = true
refs = strong_references
Method compute_cell_style_options
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def compute_cell_style_options(style_sources, additional_suffixes)
base_styles = {common: [], specific: []}
suffixes = {common: [], specific: []}
all_styles = []
Similar blocks of code found in 2 locations. Consider refactoring. Open
if !top.nil? && !bottom.nil?
frame.origin.y = top
if options[:height_to_fit].nil? && height.nil?
height = max_height - top - bottom
end
- 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 57.
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 2 locations. Consider refactoring. Open
if !left.nil? && !right.nil?
frame.origin.x = left
if options[:height_to_fit].nil? && width.nil?
width = max_width - left - right
end
- 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 57.
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 setup_fonts
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def setup_fonts
return unless @base_config
colors = @base_config.fonts.to_hash.inject({}) do |res, (font, value)|
if [:system, :bold, :italic, :monospace].include?(value)
value = Symbol.uifont[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
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.generate(obj, parametrize = true)
if parametrize && obj.is_a?(Hash)
obj.each do |key, value|
obj[key] = value.to_s if PARAMETRIZE_CLASSES.include?(value.class)
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 compute_style_options
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def compute_style_options(*style_sources)
@styles = []
if element.cell_section?
# FIXME: sometimes cause error: undefined method `style_suffixes' for instance of BaseSection's subclass
begin
- 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_option
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def set_option(key, value)
# return if value.nil?
# ignore options
return if ignore_option?(key) || value.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
Method find_keys
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def find_keys(*arg)
if arg[0].is_a?(Hash)
options = arg[0]
if arg[1] && arg[1].is_a?(Hash)
sort_options = arg[1][:sort] || {}
- 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 prepare_for_store
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def prepare_for_store(object, options = {})
if object.is_a?(Array)
object.map { |entity| prepare_for_store(entity, options) }.compact
else
object.bag_key = self.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 inspect_hash
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def inspect_hash(hash, depth = 0)
return '{}' if hash.blank?
res = hash.map.with_index do |(key, value), i|
k = "#{' '*depth}#{i.zero? ? '{' : ' '}#{key.inspect}=>"
pair = if value.is_a?(Hash)
- 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 update_with_url
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update_with_url(url, options = {}, &block)
use_callback = block_given?
filtered_attributes = filtered_updatable_attributes(options)
attributes = attributes_to_post_data(model_name, filtered_attributes)
- 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 create_navigation_button
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_navigation_button(title, args = {}, &block)
args[:style] ||= UIBarButtonItemStylePlain
args[:action] ||= block || nil
# TODO: Find better place for this code, may be just create custom control
if title.is_a?(UIButton)
- 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 fetch_has_many_with_attributes
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch_has_many_with_attributes(key, data, sync_options = {})
# TODO: should we skip add/delete/save unless should_save?
should_save = sync_options[:save]
models_to_add = []
Method draw_in_context
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def draw_in_context(context)
return if computed_options[:hidden]
size_to_fit_if_needed
set_text_position