huerlisi/bookyt

View on GitHub

Showing 34 of 54 total issues

Method footer has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

  def footer(sender, bank_account, vat_number, uid_number, vesr_included)
    height = vesr_included ? 310 : 20
    height -= 20 unless bank_account and bank_account.bank
    title_width = 45
    sender_vcard = sender.vcard
Severity: Minor
Found in app/prawn/debit_invoice_document.rb - About 7 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

Function scrollintoview has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        scrollintoview: function (options) {
            /// <summary>Scrolls the first element in the set into view by scrolling its closest scrollable parent.</summary>
            /// <param name="options" type="Object">Additional options that can configure scrolling:
            ///        duration (default: "fast") - jQuery animation speed (can be a duration string or number of milliseconds)
            ///        direction (default: "both") - select possible scrollings ("vertical" or "y", "horizontal" or "x", "both")
Severity: Major
Found in app/assets/javascripts/jquery.scrollintoview.js - About 2 hrs to fix

    Method create has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        @booking = Booking.new(params[:booking])
    
        if current_tenant.vat_obligation?
          @vat_full_booking = Booking.new(params[:vat_full_booking])
    Severity: Minor
    Found in app/controllers/expenses_controller.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

    Class Invoice has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Invoice < ActiveRecord::Base
      # Aspects
      include ApplicationHelper
    
      # Scopes
    Severity: Minor
    Found in app/models/invoice.rb - About 2 hrs to fix

      Method footer has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def footer(sender, bank_account, vat_number, uid_number, vesr_included)
          height = vesr_included ? 310 : 20
          height -= 20 unless bank_account and bank_account.bank
          title_width = 45
          sender_vcard = sender.vcard
      Severity: Minor
      Found in app/prawn/debit_invoice_document.rb - About 1 hr to fix

        Method new_vat has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def new_vat
            @booking = Booking.new(params[:booking])
            increment_booking_code
        
            # Guard to ensure all needed fields are filled in
        Severity: Minor
        Found in app/controllers/expenses_controller.rb - About 1 hr to fix

          Method new has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def new
              # Allow pre-seeding some parameters
              text = t('letters.debit_invoice.closing')
              text += "\n\n" + t('letters.debit_invoice.greetings')
              text += "\n" + current_user.person.vcard.full_name
          Severity: Minor
          Found in app/controllers/debit_invoices_controller.rb - About 1 hr to fix

            Function formatColumn has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                lib.formatColumn = function(list, symbol, precision, thousand, decimal, format) {
                    if (!list) return [];
            
                    // Build options object from second param (if object) or all params, extending defaults:
                    var opts = defaults(
            Severity: Minor
            Found in app/assets/javascripts/accounting.js - About 1 hr to fix

              Function initializeBehaviours has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function initializeBehaviours() {
                // Init settings
                initAccounting();
              
                // from cyt.js
              Severity: Minor
              Found in app/assets/javascripts/bookyt.js - About 1 hr to fix

                Function scrollable has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        scrollable: function (element, index, meta, stack) {
                            var direction = converter[typeof (meta[3]) === "string" && meta[3].toLowerCase()] || converter.both;
                            var styles = (document.defaultView && document.defaultView.getComputedStyle ? document.defaultView.getComputedStyle(element, null) : element.currentStyle);
                            var overflow = {
                                x: scrollValue[styles.overflowX.toLowerCase()] || false,
                Severity: Minor
                Found in app/assets/javascripts/jquery.scrollintoview.js - About 1 hr to fix

                  Function updateLineItemPrice has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function updateLineItemPrice(lineItem) {
                    var list = lineItem.parent();
                    var reference_code = lineItem.find(":input[name$='[reference_code]']").val();
                    var quantity = lineItem.find(":input[name$='[quantity]']").val();
                    var after_saldo_line_item = lineItem.prev().hasClass('saldo_line_item');
                  Severity: Minor
                  Found in app/assets/javascripts/bookyt.js - 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 price has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def price
                      # If a price is set, use it
                      return self[:price] unless self[:price].blank?
                  
                      # If a reference_code is given...
                  Severity: Minor
                  Found in app/models/line_item.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 overdue? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def overdue?
                      return true if state == 'booked' and due_date < Date.today
                      return true if state == 'reminded' and (reminder_due_date.nil? or reminder_due_date < Date.today)
                      return true if state == '2xreminded' and (second_reminder_due_date.nil? or second_reminder_due_date < Date.today)
                      return true if state == '3xreminded' and (third_reminder_due_date.nil? or third_reminder_due_date < Date.today)
                  Severity: Minor
                  Found in app/models/invoice.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 to_csv has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def to_csv(options={})
                      self.class.csv_columns(options).map { |curr_col|
                        curr_col = curr_col.to_s
                  
                        #Its a chain of method calls, on intermediary nil, just return nil
                  Severity: Minor
                  Found in lib/acts_as_csv.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 xbooking_parameters has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def xbooking_parameters(params = {})
                      # Prepare parameters set by template
                      booking_params = attributes.reject!{|key, value| !["title", "comments", "credit_account_id", "debit_account_id"].include?(key)}
                  
                      # Calculate amount
                  Severity: Minor
                  Found in app/models/charge_booking_template.rb - About 1 hr to fix

                    Method create has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def create
                        @booking = Booking.new(params[:booking])
                    
                        if current_tenant.vat_obligation?
                          @vat_full_booking = Booking.new(params[:vat_full_booking])
                    Severity: Minor
                    Found in app/controllers/expenses_controller.rb - About 1 hr to fix

                      Method render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def render(item_container)
                              if options[:is_subnavigation]
                                ul_class = "dropdown-menu"
                              else
                                ul_class = "nav"
                      Severity: Minor
                      Found in lib/simple_navigation/renderer/bootstrap_topbar_list.rb - About 55 mins 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 xbooking_parameters has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def xbooking_parameters(params = {})
                          # Prepare parameters set by template
                          booking_params = attributes.reject!{|key, value| !["title", "comments", "credit_account_id", "debit_account_id"].include?(key)}
                      
                          # Calculate amount
                      Severity: Minor
                      Found in app/models/charge_booking_template.rb - About 55 mins 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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def update
                          @user = User.find(params[:id])
                      
                          # Don't try to update password if not provided
                          if params[:user][:password].blank?
                      Severity: Minor
                      Found in app/controllers/users_controller.rb - About 55 mins 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 to_s has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def to_s(format = :default)
                          return "" if (title.blank? or rate_to_s.blank?)
                      
                          case format
                            when :long
                      Severity: Minor
                      Found in app/models/charge_rate.rb - About 55 mins 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

                      Severity
                      Category
                      Status
                      Source
                      Language