armandofox/audience1st

View on GitHub

Showing 387 of 387 total issues

Method check_purchaser_info has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def check_purchaser_info
    # walkup orders only need purchaser & recipient info to point to walkup
    #  customer, but regular orders need full purchaser & recipient info.
    if walkup?
      errors.add(:base, "Walkup order requires purchaser & recipient to be walkup customer") unless
Severity: Minor
Found in app/models/order.rb - About 2 hrs to fix

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 too many lines. [36/30]
Open

  def update
    # editing contact info may be called from various places. correctly
    # set the return-to so that form buttons can do the right thing.
    # unless admin, remove "extra contact" fields
    if @gAdminDisplay

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class Show has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class Show < ActiveRecord::Base

  REGULAR_SHOW = 'Regular Show'
  TYPES = [REGULAR_SHOW, 'Special Event', 'Class', 'Subscription']

Severity: Minor
Found in app/models/show.rb - About 2 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        $.getJSON(seatmapUrl, function(json_data) { 
          A1.seatmap.configureFrom(json_data);
          A1.seatmap.seats = $('#seatmap').seatCharts(A1.seatmap.settings);
          A1.seatmap.setupMap();
        });
    Severity: Major
    Found in app/assets/javascripts/seatmap_subscriber_reservation.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/seatmap_import.js on lines 84..89

    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 81.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        $.getJSON(uri,
                  function(json_data) {
                    A1.seatmap.configureFrom(json_data);
                    A1.seatmap.seats = $('#seatmap').seatCharts(A1.seatmap.settings);
                    A1.seatmap.setupMap();
    Severity: Major
    Found in app/assets/javascripts/seatmap_import.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/seatmap_subscriber_reservation.js on lines 50..54

    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 81.

    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

    Further Reading

    Method parse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse
          unless valid?
            return @import.errors.add(:base, 'Import is invalid')
          end
          # A Goldstar will-call is always for exactly 1 performance
    Severity: Minor
    Found in app/services/ticket_sales_import_parser/goldstar.rb - About 2 hrs to fix

    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 csv has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def csv
        csv = CSV.generate(:force_quotes => true) do |csv|
          csv << [
            'Payment Type',
            'Account Code #',
    Severity: Minor
    Found in app/services/reports/revenue_by_payment_method_report.rb - About 2 hrs to fix

    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 add_tickets_without_capacity_checks has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_tickets_without_capacity_checks(valid_voucher, number, seats=[])
        raise Order::NotPersistedError unless persisted?
        new_vouchers = VoucherInstantiator.new(valid_voucher.vouchertype, :promo_code => valid_voucher.supplied_promo_code || valid_voucher.promo_code).from_vouchertype(number)
        # reserve only if a specific showdate is indicated.  it seems like this method
        # should really take a vouchertype and showdate.
    Severity: Minor
    Found in app/models/order.rb - About 2 hrs to fix

    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

    Cyclomatic complexity for update is too high. [11/6]
    Open

      def update
        # editing contact info may be called from various places. correctly
        # set the return-to so that form buttons can do the right thing.
        # unless admin, remove "extra contact" fields
        if @gAdminDisplay

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Cyclomatic complexity for create is too high. [11/6]
    Open

      def create
        @order = Order.create(
          :walkup => true,
          :customer => Customer.walkup_customer,
          :purchaser => Customer.walkup_customer,

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Cyclomatic complexity for initialize is too high. [11/6]
    Open

      def initialize(args={})
        @start_date = (args[:start_date] || Time.current).to_date
        @end_date = (args[:end_date] || Time.current).to_date
        @start_date,@end_date = @end_date,@start_date if @start_date > @end_date
        @hour = (args[:hour] || 0).to_i
    Severity: Minor
    Found in lib/datetime_range.rb by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Method csv has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def csv
        csv = CSV.generate(:force_quotes => true) do |csv|
          csv << [
            'Payment Type',
            'Account Code #',
    Severity: Major
    Found in app/services/reports/revenue_by_payment_method_report.rb - About 2 hrs to fix

      Cyclomatic complexity for generate is too high. [10/6]
      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])

      This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

      An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

      Cyclomatic complexity for shipping_address is too high. [10/6]
      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
      Severity: Minor
      Found in app/controllers/store_controller.rb by rubocop

      This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

      An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

      Method has too many lines. [33/30]
      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
      Severity: Minor
      Found in app/controllers/store_controller.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Cyclomatic complexity for purchasemethod_from_params is too high. [9/6]
      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
      Severity: Minor
      Found in app/controllers/store_controller.rb by rubocop

      This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

      An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

      Method confirm_multiple has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def confirm_multiple
          @params = params.permit(:number, :showdate_id, :customer_id, :seats, :comments, :voucher_ids, :zone)
          the_showdate = Showdate.find_by(:id => params[:showdate_id])
          num = @params[:number].to_i
          return redirect_to(customer_path(@customer), :alert => t("#{ERR}no_showdate")) unless the_showdate
      Severity: Minor
      Found in app/controllers/vouchers_controller.rb - About 1 hr to fix

      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 finalize! has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def finalize!(sold_on_date = Time.current)
          raise Order::NotReadyError unless ready_for_purchase?
          # for credit card orders ONLY:
          #  mark order as Pending, run the card and rescue any errors, then finalize order.
          auth = nil
      Severity: Minor
      Found in app/models/order.rb - About 1 hr to fix

      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

        case 'Ts':                       // stream on demand
          saveMaxSalesDefault();
          $('#showdate_stream_anytime').val('1');
          $('.Ts').removeClass('d-none');
          $('.Tsd').removeAttr('disabled');
      Severity: Major
      Found in app/assets/javascripts/showdate.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/showdate.js on lines 27..33

      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 73.

      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

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        case 'Tl':                     // stream
          saveMaxSalesDefault();
          $('#showdate_live_stream').val('1');
          $('.Tl').removeClass('d-none');
          $('.Tld').removeAttr('disabled');
      Severity: Major
      Found in app/assets/javascripts/showdate.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/showdate.js on lines 34..40

      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 73.

      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

      Further Reading

      Severity
      Category
      Status
      Source
      Language