Showing 346 of 346 total issues
Function initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialize : function() {
jQuery('#submit_add_to_cart').click( function() {
if (jQuery('#cart_item_variant_id').val() == '' ) { // Select to see if variant is selected in hidden field
alert('Please click on a specific item to add.');
} else
Function search_field_scale
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Chosen.prototype.search_field_scale = function() {
var dd_top, div, h, style, style_block, styles, w, _i, _len;
if (this.is_multiple) {
h = 0;
w = 0;
Function renderPreview
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renderPreview() {
var phtml;
if (options.previewParser && typeof options.previewParser === 'function') {
var data = options.previewParser( $$.val() );
writeInPreview( localize(data, 1) );
Function magicMarkups
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function magicMarkups(string) {
if (string) {
string = string.toString();
string = string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,
function(x, a) {
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
@order = session_admin_order
@order.ip_address = request.remote_ip
@credit_card ||= ActiveMerchant::Billing::CreditCard.new(cc_params)
Similar blocks of code found in 2 locations. Consider refactoring. Open
Chosen.prototype.result_clear_highlight = function() {
if (this.result_highlight) {
this.result_highlight.removeClass("highlighted");
}
return this.result_highlight = null;
- 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
Chosen.prototype.clear_backstroke = function() {
if (this.pending_backstroke) {
this.pending_backstroke.removeClass("search-choice-focus");
}
return this.pending_backstroke = null;
- 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 ensure_available
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ensure_available
if active? && deleted_at_changed?
self.errors.add(:base, 'There must be active variants.') if active_variants.blank?
self.errors.add(:base, 'Variants must have inventory.') unless active_variants.any?{|v| v.is_available? }
self.deleted_at = deleted_at_was if active_variants.blank? || !active_variants.any?{|v| v.is_available? }
- 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
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create
@referring_user = User.find_by_email(params[:referring_user_email])
@referral = Referral.new(allowed_params)
@referral.referral_type_id = ReferralType::ADMIN_WEB_FORM_ID
@referral.skip_validate_has_not_signed_up_yet = true
- 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_invoice
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create_invoice(credit_card, charge_amount, args, credited_amount = 0.0)
transaction do
new_invoice = create_invoice_transaction(credit_card, charge_amount, args, credited_amount)
if new_invoice.succeeded?
remove_user_store_credits
- 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
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update
@variant = Variant.find(params[:id])
### the reason will effect accounting
# if the item is refunded by the supplier the accounting will be reflected
if params[:refund].present? && params[:variant][:qty_to_add].present?
- 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
class << self
def send!(variant_ids)
Notifier.out_of_stock_message(out_of_stock_user_ids(variant_ids), Array(variant_ids)).deliver_later
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 50.
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
class << self
def send!(variant_ids)
Notifier.low_stock_message(low_stock_user_ids(variant_ids), Array(variant_ids)).deliver_later
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 50.
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
Function keydown_checker
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Chosen.prototype.keydown_checker = function(evt) {
var stroke, _ref;
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
if (stroke !== 8 && this.pending_backstroke) {
Function initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialize : function(invoiceId, order_id) {
var captureTag = jQuery(Hadean.Fulfillment.captureInvoiceButton + invoiceId );
var capturePartTag = jQuery(Hadean.Fulfillment.capturePartInvoiceButton + invoiceId);
var cancelTag = jQuery(Hadean.Fulfillment.cancelInvoiceButton + invoiceId);
Function indexOf
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this == null) {
throw new TypeError();
}
Function clean
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
jQuery.clean = function( elems, context, fragment, scripts ) {
// Set context per 1.8 logic
context = context || document;
context = !context.nodeType && context[0] || context;
context = context.ownerDocument || context;
Function fieldValue
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fieldValue = function(el, successful) {
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
if (typeof successful == 'undefined') successful = true;
if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
Function add_option
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
if (option.nodeName === "OPTION") {
if (option.text !== "") {
if (group_position != null) {
this.parsed[group_position].children += 1;
Consider simplifying this complex logical expression. Open
} else if (region.hasClass(self.settings.active_class) && self.is_accordion(section) || !settings.one_up && (self.small(section) || self.is_vertical_nav(section) || self.is_horizontal_nav(section) || self.is_accordion(section))) {
region.removeClass(self.settings.active_class);
region.trigger('closed.fndtn.section');
}