huerlisi/bookyt

View on GitHub

Showing 54 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

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

                if (options.direction.x === true)
                {
                    if (rel.left < 0)
                    {
                        animOptions.scrollLeft = dim.s.scroll.left + rel.left;
Severity: Major
Found in app/assets/javascripts/jquery.scrollintoview.js and 1 other location - About 5 hrs to fix
app/assets/javascripts/jquery.scrollintoview.js on lines 127..137

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

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

                if (options.direction.y === true)
                {
                    if (rel.top < 0)
                    {
                        animOptions.scrollTop = dim.s.scroll.top + rel.top;
Severity: Major
Found in app/assets/javascripts/jquery.scrollintoview.js and 1 other location - About 5 hrs to fix
app/assets/javascripts/jquery.scrollintoview.js on lines 140..150

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

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

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

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

                          right: dim.s.rect.right - dim.s.border.right - dim.s.scrollbar.right - dim.e.rect.right - options.viewPadding.x
      Severity: Major
      Found in app/assets/javascripts/jquery.scrollintoview.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/jquery.scrollintoview.js on lines 119..119

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

      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

                          bottom: dim.s.rect.bottom - dim.s.border.bottom - dim.s.scrollbar.bottom - dim.e.rect.bottom - options.viewPadding.y,
      Severity: Major
      Found in app/assets/javascripts/jquery.scrollintoview.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/jquery.scrollintoview.js on lines 121..121

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

      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

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

                params do
                  requires :title, type: String, desc: 'Title of the booking'
                  requires :amount, type: BigDecimal, desc: 'Amount to be booked'
                  requires :value_date, type: Date, desc: 'Date of the booking'
                  requires :credit_account_code, type: String, values: -> { Account.pluck(:code) }, desc: 'Code of the credit account'
      Severity: Major
      Found in app/api/bookyt/api/bookings.rb and 1 other location - About 1 hr to fix
      app/api/bookyt/api/bookings.rb on lines 12..20

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

      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

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

              params do
                requires :title, type: String, desc: 'Title of the booking'
                requires :amount, type: BigDecimal, desc: 'Amount to be booked'
                requires :value_date, type: Date, desc: 'Date of the booking'
                requires :credit_account_code, type: String, values: -> { Account.pluck(:code) }, desc: 'Code of the credit account'
      Severity: Major
      Found in app/api/bookyt/api/bookings.rb and 1 other location - About 1 hr to fix
      app/api/bookyt/api/bookings.rb on lines 49..57

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

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

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

                toFixed: function(precision) {
                    // Apply accounting.toFixed() to matched elements and return for chaining
                    return this.each(function() {
                        $(this).text(
                            accounting.toFixed($(this).text(), precision)
        Severity: Major
        Found in app/assets/javascripts/accounting-jquery.js and 3 other locations - About 1 hr to fix
        app/assets/javascripts/accounting-jquery.js on lines 17..24
        app/assets/javascripts/accounting-jquery.js on lines 25..32
        app/assets/javascripts/accounting-jquery.js on lines 57..64

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

        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 4 locations. Consider refactoring.
        Open

                formatMoney: function(options) {
                    // Apply accounting.formatMoney() to matched elements and return for chaining
                    return this.each(function() {
                        $(this).text(
                            accounting.formatMoney($(this).text(), options)
        Severity: Major
        Found in app/assets/javascripts/accounting-jquery.js and 3 other locations - About 1 hr to fix
        app/assets/javascripts/accounting-jquery.js on lines 17..24
        app/assets/javascripts/accounting-jquery.js on lines 49..56
        app/assets/javascripts/accounting-jquery.js on lines 57..64

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

        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 4 locations. Consider refactoring.
        Open

                formatNumber: function(options) {
                    // Apply accounting.formatNumber() to matched elements and return for chaining
                    return this.each(function() {
                        $(this).text(
                            accounting.formatNumber($(this).text(), options)
        Severity: Major
        Found in app/assets/javascripts/accounting-jquery.js and 3 other locations - About 1 hr to fix
        app/assets/javascripts/accounting-jquery.js on lines 25..32
        app/assets/javascripts/accounting-jquery.js on lines 49..56
        app/assets/javascripts/accounting-jquery.js on lines 57..64

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

        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 4 locations. Consider refactoring.
        Open

                unformat: function(decimal) {
                    // Apply accounting.unformat() to matched elements and return for chaining
                    return this.each(function() {
                        $(this).text(
                            accounting.unformat($(this).text(), decimal)
        Severity: Major
        Found in app/assets/javascripts/accounting-jquery.js and 3 other locations - About 1 hr to fix
        app/assets/javascripts/accounting-jquery.js on lines 17..24
        app/assets/javascripts/accounting-jquery.js on lines 25..32
        app/assets/javascripts/accounting-jquery.js on lines 49..56

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

        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 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
                  Severity
                  Category
                  Status
                  Source
                  Language