Showing 51 of 51 total issues
File table.rb
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
module ProMotion
module Table
include ProMotion::Styling
include ProMotion::Table::Searchable
include ProMotion::Table::Refreshable
Method set_remote_image
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def set_remote_image
return unless data_cell[:remote_image] && (sd_web_image? || jm_image_cache?)
self.imageView.image = remote_placeholder
- 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 table_data
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
def table_data
@data ||= [{
title: "Your Account",
cells: [
{ title: "Increment", action: :increment_counter_by, arguments: {number: 3} },
Method set_attribute
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def set_attribute(element, k, v)
return unless element
if !element.is_a?(CALayer) && v.is_a?(Hash) && element.respond_to?("#{k}=")
element.send("#{k}=", v)
- 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 open_screen
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def open_screen(screen, args = {})
args = { animated: true }.merge(args)
# Apply properties to instance
screen = set_up_screen_for_open(screen, args)
- 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 search
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def search(search_string)
@filtered = true
@search_string = search_string
self.filtered_data = []
- 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_tab_bar_item
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create_tab_bar_item(tab={})
if tab[:system_icon]
mp("`system_icon:` no longer supported. Use `system_item:` instead.", force_color: :yellow)
tab[:system_item] ||= tab[:system_icon]
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 set_remote_image
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_remote_image
return unless data_cell[:remote_image] && (sd_web_image? || jm_image_cache?)
self.imageView.image = remote_placeholder
Method webView
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def webView(view, decidePolicyForNavigationAction: navigationAction, decisionHandler: decisionHandler)
request = navigationAction.request
nav_type = navigationAction.navigationType
if %w(http https).include?(request.URL.scheme)
- 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 collection_data
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def collection_data
cells = (1..10).to_a.map do |i|
(1..10).to_a.map do |o|
{
cell_identifier: :custom_cell,
Method tableView
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def tableView(_, heightForHeaderInSection: index)
section = promotion_table_data.section(index)
if section[:title_view] || section[:title].to_s.length > 0
if section[:title_view_height]
section[:title_view_height]
- 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 tableView
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def tableView(_, heightForFooterInSection: index)
section = promotion_table_data.section(index)
if section[:footer_view] || section[:footer].to_s.length > 0
if section[:footer_view_height]
section[:footer_view_height]
- 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 close_screen
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def close_screen(args = {})
args ||= {}
args = { sender: args } unless args.is_a?(Hash)
args[:animated] = true unless args.has_key?(:animated)
- 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 get_searchable_params
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_searchable_params
params = self.class.get_searchable_params.dup
# support camelCase params
params[:search_results_updater] ||= params[:searchResultsUpdater]
- 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 map_bar_button_system_item
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def map_bar_button_system_item(symbol)
mp("Nav bar button stytem item `:page_curl` has been deprecated.", force_color: :yellow) if symbol == :page_curl
{
done: UIBarButtonSystemItemDone,
cancel: UIBarButtonSystemItemCancel,
Method webView
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def webView(in_web, shouldStartLoadWithRequest:in_request, navigationType:in_type)
if %w(http https).include?(in_request.URL.scheme)
if self.external_links == true && in_type == UIWebViewNavigationTypeLinkClicked
if defined?(OpenInChromeController)
open_in_chrome in_request
- 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 bar_button_item
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def bar_button_item(button_type, args)
return mp("`system_icon:` no longer supported. Use `system_item:` instead.", force_color: :yellow) if args[:system_icon]
return button_type if button_type.is_a?(UIBarButtonItem)
if args[:system_item]
mp("Nav bar button specified both `system_item:` and `title:`. Title will be ignored.", force_color: :yellow) if args[:title]
- 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 row_height
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def row_height(height, args={})
if height == :auto
if UIDevice.currentDevice.systemVersion.to_f < 8.0
height = args[:estimated] || 44.0
mp "Using `row_height :auto` is not supported in iOS 7 apps. Setting to #{height}.", force_color: :yellow
- 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 ensure_wrapper_controller_in_place
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def ensure_wrapper_controller_in_place(screen, args={})
unless args[:close_all] || args[:modal] || args[:in_detail] || args[:in_master]
screen.navigationController ||= self.navigationController if screen.respond_to?("navigationController=")
screen.tab_bar ||= self.tab_bar if screen.respond_to?("tab_bar=")
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def tableView(_, heightForHeaderInSection: index)
section = promotion_table_data.section(index)
if section[:title_view] || section[:title].to_s.length > 0
if section[:title_view_height]
section[:title_view_height]
- 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 43.
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