File integration_test_helper.rb
has 478 lines of code (exceeds 250 allowed). Consider refactoring. Open
SKIP_SYSTEM_CONFIGURATION = true
# Standard test initialization code
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
Method new_item
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def new_item(options = nil, basket = nil, is_homepage_topic = nil, zoom_class = nil)
# because we use method missing, something like new_topic() (without any options) will return nil when
# it calls this method and because of some funkyness in ruby, setting defaults in the options above is
# replaced by nil, rather than the value so instead of setting it there, we set them here instead,
# which should provide better support
- 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 IntegrationTest
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class ActionController::IntegrationTest
include ZoomControllerHelpers
# setup basket variables for use later
@@site_basket ||= Basket.site_basket
Method new_item
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_item(options = nil, basket = nil, is_homepage_topic = nil, zoom_class = nil)
# because we use method missing, something like new_topic() (without any options) will return nil when
# it calls this method and because of some funkyness in ruby, setting defaults in the options above is
# replaced by nil, rather than the value so instead of setting it there, we set them here instead,
# which should provide better support
Method method_missing
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(method_sym, *args, &block)
method_name = method_sym.to_s
if method_name =~ /^new_(\w+)$/
# new_topic / new_audio_recording
# takes basket and a hash of values, plus an optional block
- 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 method_missing
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def method_missing(method_sym, *args, &block)
method_name = method_sym.to_s
if method_name =~ /^new_(\w+)$/
# new_topic / new_audio_recording
# takes basket and a hash of values, plus an optional block
Method body_should_contain
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def body_should_contain(text, options = {})
raise "body_should_contain method should be called after a page visit" if response.nil? || response.body.nil?
response_body = response.body.squish
unless text.kind_of?(Regexp)
text = options[:escape_chars] ? escape(text.squish) : text.squish
- 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 body_should_not_contain
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def body_should_not_contain(text, options = {})
raise "body_should_not_contain method should be called after a page visit" if response.nil? || response.body.nil?
response_body = response.body.squish
unless text.kind_of?(Regexp)
text = options[:escape_chars] ? escape(text.squish) : text.squish
- 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 body_should_contain_in_order
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def body_should_contain_in_order(text_array, divider, options = {})
raise "body_should_contain_in_order method should be called after a page visit" if response.nil? || response.body.nil?
save_and_open_page if options[:dump_response]
response_body = response.body.squish
parts = response_body.split(divider).compact.flatten
- 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 login_as
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def login_as(username, password = 'test', options = {})
options = {
:navigate_to_login => false,
:by_form => false,
:logout_first => false,
- 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 turn_on_full_moderation(basket)
visit "/#{basket.urlified_name}/baskets/edit/#{basket.id}"
select "moderator views before item approved", :from => "settings_fully_moderated"
click_button "Update"
body_should_contain "Basket was successfully updated."
- 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 28.
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
def turn_off_full_moderation(basket)
visit "/#{basket.urlified_name}/baskets/edit/#{basket.id}"
select "moderation upon being flagged", :from => "settings_fully_moderated"
click_button "Update"
body_should_contain "Basket was successfully updated."
- 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 28.
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
def unlink_relation_between(topic, zoom_class, *relation_candidate_ids)
topic = topic.id.to_s if topic.is_a?(Topic)
item_checkbox_hash = item_checkbox_hash_from(relation_candidate_ids)
post '/site/search/unlink_related', :relate_to_item => topic, :relate_to_type => 'Topic', :related_class => zoom_class, :item => item_checkbox_hash
assert_response :redirect
- 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 26.
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
def add_relation_between(topic, zoom_class, *relation_candidate_ids)
topic = topic.id.to_s if topic.is_a?(Topic)
item_checkbox_hash = item_checkbox_hash_from(relation_candidate_ids)
post '/site/search/link_related', :relate_to_item => topic, :relate_to_type => 'Topic', :related_class => zoom_class, :item => item_checkbox_hash
assert_response :redirect
- 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 26.
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