Showing 127 of 387 total issues
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
warnings = []
cutoff = params[:advance_sales_cutoff].to_i.minutes
# determine date list from EITHER the date range, or for stream-anytime, single date
if params[:showdate][:stream_anytime].blank?
Method check_sales_limits
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_sales_limits
showdates = Hash.new { 0 }
num_of_type = Hash.new { 0 }
imported_orders.reject(&:completed?).each do |i|
i.vouchers.each do |voucher|
Function click
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
,click: function(evt) {
var clickedSeat = this.settings.id; // format: ZoneName-A111 (hyphen is separator)
var seatNum = A1.seatmap.seatLabelToSeatNum(clickedSeat);
switch(this.status()) {
case 'available': // clicking on available seat selects it...
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
# :rails5: this can be simplified since Rails 5.1+ allows :included_vouchers => {} to
# pass through ANY keys in that hash
included_voucher_keys = params[:vouchertype][:included_vouchers] ? params[:vouchertype][:included_vouchers].keys : []
vouchertype_update_params =
Method initialize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize(showdate_as_date, _price, _noffered, _nsold,
name_str="%goldstar%")
@price,@noffered,@nsold = _price,_noffered.to_i,_nsold.to_i
raise(ArgumentError, "Number offered and sold must be >= 0") unless
(@noffered >= 0 && @nsold >= 0)
- 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
creation_params =
params.require(:vouchertype).
permit(:category, :name, :price, :seating_zone_id, :seating_zone, :offer_public, :season, :display_order, :fulfillment_needed, :walkup_sale_allowed, :changeable, :subscription, :comments, :account_code_id)
@vouchertype = Vouchertype.new(creation_params)
- 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 shipping_address
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def shipping_address
@mailable = @gOrderInProgress.includes_mailable_items?
@recipient = Customer.new and return if request.get?
# request is a POST: collect shipping address
# record whether we should mail to purchaser or recipient
- 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 click
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
,click: function(evt) {
var clickedSeat = this.settings.id; // format: ZoneName-A111 (hyphen is separator)
var seatNum = A1.seatmap.seatLabelToSeatNum(clickedSeat);
switch(this.status()) {
case 'available': // clicking on available seat selects it...
- 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
@order = Order.find params[:id]
items = Item.find(params[:items].keys) rescue []
if items.empty?
redirect_to(order_path(@order), :alert => 'No items selected for refund.') and return
- 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
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def inspect
if vouchertype_id.nil?
sprintf("%d (No vouchertype)", (new_record? ? object_id : id))
else
s = sprintf("%d %s", (new_record? ? object_id : id), vouchertype.name)
- 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 <=>
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def <=>(other)
sd1,vt1 = self.showdate, self.vouchertype
sd2,vt2 = other.showdate, other.vouchertype
if vt1 == vt2
# same vouchertype: order by OPENING DATE of the show for which reserved, or display order
- 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 run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
items =
Item.
joins(:order).
includes(:order,:account_code,:customer,:vouchertype, :showdate => :show).
Method add_data_rows
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_data_rows(csv)
# grab the IDs of the whole set, then find in batches to avoid instantiating lots of objects
order = self.output_options[:sort_by_zip] == '1' ?
"customers.zip, customers.last_name" :
"customers.last_name, customers.zip"
Consider simplifying this complex logical expression. Open
if (first_name.blank? || last_name.blank? || email.blank? || street.blank? || city.blank? || state.blank? || zip.blank?)
errors.add :base, "Please provide your email address for order confirmation, and your credit card billing name and address."
false
else
# this is a HACK: set created_by_admin to bypass most other validations.
Method one_line_description
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def one_line_description(opts={})
s = opts[:suppress_price] ? '' : sprintf("$%6.2f ", amount)
if reserved?
s << sprintf("%s\n %s", showdate.printable_name, name)
s << " #{seat}" unless opts[:suppress_seat]
- 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_session
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_session(u = nil, action = '')
logout_keeping_session!
@user = u || yield(params)
if @user && @user.errors.empty?
# Protects against session fixation attacks, causes request forgery
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
def generate(params = {})
shows = Report.list_of_ints_from_multiselect(params[:shows])
# do default search for OR. if it's AND, winnow the list afterward.
shows_not = Report.list_of_ints_from_multiselect(params[:shows_not])
vouchertypes = Report.list_of_ints_from_multiselect(params[:vouchertypes])
- 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 mark_fulfilled
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def mark_fulfilled
i = 0
flash[:notice] = ''
params[:voucher].each_pair do |vid,do_update|
next if do_update.to_i.zero?
- 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 revenue_by_payment_method
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def revenue_by_payment_method
# report may be by date range or by production
case params[:txn_report_by]
when 'date'
from,to = Time.range_from_params(params[:txn_report_dates])
- 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 purchasemethod_from_params
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def purchasemethod_from_params
# for a regular customer, the only options are 'credit' or 'none' (the latter only valid
# if a zero-price order)
# if Stripe successfully registered a CC purchase, 'fake' the :commit parameter (Submit
- 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"