Showing 203 of 346 total issues
Function preview
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function preview() {
if (!previewWindow || previewWindow.closed) {
if (options.previewInWindow) {
previewWindow = window.open('', 'preview', options.previewInWindow);
$(window).unload(function() {
Function jq_param_sub
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function jq_param_sub( is_fragment, get_func, url, params, merge_mode ) {
var result,
qs,
matches,
url_params,
Function cookie
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
var config = $.cookie = function (key, value, options) {
// write
if (value !== undefined) {
options = $.extend({}, config.defaults, options);
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)
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
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');
}
Method create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create
session_cart.save if session_cart.new_record?
qty = params[:cart_item][:quantity].to_i
if cart_item = session_cart.add_variant(params[:cart_item][:variant_id], most_likely_user, qty)
flash[:notice] = [I18n.t('out_of_stock_notice'), I18n.t('item_saved_for_later')].compact.join(' ') unless cart_item.shopping_cart_item?
- 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"