foodcoops/foodsoft

View on GitHub

Showing 182 of 182 total issues

Method load_data has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def load_data
    data = {}
    data[:account_balance] = ordergroup.nil? ? BigDecimal('+Infinity') : ordergroup.account_balance
    data[:available_funds] = ordergroup.nil? ? BigDecimal('+Infinity') : ordergroup.get_available_funds(self)

Severity: Minor
Found in app/models/group_order.rb - About 5 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 Order has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

class Order < ApplicationRecord
  attr_accessor :ignore_warnings, :transport_distribution

  # Associations
  has_many :order_articles, dependent: :destroy
Severity: Minor
Found in app/models/order.rb - About 4 hrs to fix

    Method date_time_attribute has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def date_time_attribute(*attributes)
          super
    
          attributes.each do |attribute|
            validate -> { send("#{attribute}_datetime_value_valid") }
    Severity: Minor
    Found in app/lib/date_time_attribute_validate.rb - About 4 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 calculate_result has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

      def calculate_result(total = nil)
        # return memoized result unless a total is given
        return @calculate_result if total.nil? && !@calculate_result.nil?
    
        quantity = tolerance = total_quantity = 0
    Severity: Minor
    Found in app/models/group_order_article.rb - About 4 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 update_quantities has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_quantities(quantity, tolerance)
        logger.debug("GroupOrderArticle[#{id}].update_quantities(#{quantity}, #{tolerance})")
        logger.debug("Current quantity = #{self.quantity}, tolerance = #{self.tolerance}")
    
        # When quantity and tolerance are zero, we don't serve any purpose
    Severity: Minor
    Found in app/models/group_order_article.rb - About 4 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 stupidtable has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      $.fn.stupidtable = function(sortFns) {
        return this.each(function() {
          var $table = $(this);
          sortFns = sortFns || {};
    
    
    Severity: Major
    Found in app/assets/javascripts/stupidtable.js - About 3 hrs to fix

      Class User has 29 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class User < ApplicationRecord
        include CustomFields
        # TODO: acts_as_paraniod ??
      
        has_many :memberships, dependent: :destroy
      Severity: Minor
      Found in app/models/user.rb - About 3 hrs to fix

        Method add_uservoice_script has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

                def add_uservoice_script
                  return unless FoodsoftUservoice.enabled?
        
                  # include uservoice javascript
                  api_key = FoodsoftConfig[:uservoice]['api_key']
        Severity: Minor
        Found in plugins/uservoice/lib/foodsoft_uservoice.rb - About 3 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 body has 80 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def body
            order_articles_data = [[
              OrderArticle.human_attribute_name(:article),
              Article.human_attribute_name(:supplier),
              ArticlePrice.human_attribute_name(:unit_quantity),
        Severity: Major
        Found in app/documents/order_matrix.rb - About 3 hrs to fix

          File order.rb has 296 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class Order < ApplicationRecord
            attr_accessor :ignore_warnings, :transport_distribution
          
            # Associations
            has_many :order_articles, dependent: :destroy
          Severity: Minor
          Found in app/models/order.rb - About 3 hrs to fix

            Method update_order_amounts has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

              def update_order_amounts
                return unless params[:order_articles]
            
                # where to leave remainder during redistribution
                rest_to = []
            Severity: Minor
            Found in app/controllers/orders_controller.rb - About 3 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

                $el.find('a[data-decrease_quantity]').each(function() {
                  var $q = $el.find('#q_'+$(this).data('decrease_quantity'));
                  $(this).toggleClass('disabled', $q.val() <= ($q.data('min')||0));
                });
            Severity: Major
            Found in app/assets/javascripts/ordering.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/ordering.js on lines 210..213

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

            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

                $el.find('a[data-decrease_tolerance]').each(function() {
                  var $t = $el.find('#t_'+$(this).data('decrease_tolerance'));
                  $(this).toggleClass('disabled', $t.val() <= ($t.data('min')||0));
                });
            Severity: Major
            Found in app/assets/javascripts/ordering.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/ordering.js on lines 202..205

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

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

              def body
                each_ordergroup do |oa_name, oa_total, oa_id, oa_transport|
                  has_transport = !oa_transport.nil? && oa_transport > 0
                  dimrows = []
                  rows = [[
            Severity: Minor
            Found in app/documents/order_by_groups.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 create_collection has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

              def create_collection
                raise I18n.t('finance.financial_transactions.controller.create_collection.error_note_required') if params[:note].blank?
            
                type = FinancialTransactionType.find_by_id(params[:type_id])
                financial_link = nil
            Severity: Minor
            Found in app/controllers/finance/financial_transactions_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

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

              def body
                # Start rendering
                each_ordergroup do |ordergroup|
                  down_or_page 15
            
            
            Severity: Minor
            Found in plugins/current_orders/app/documents/multiple_orders_by_groups.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

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

                $el.find('a[data-increase_tolerance]').each(function() {
                  var $t = $el.find('#t_'+$(this).data('increase_tolerance'));
                  $(this).toggleClass('disabled', $t.val() >= $t.data('max'));
                });
            Severity: Major
            Found in app/assets/javascripts/ordering.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/ordering.js on lines 198..201

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

            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

                $el.find('a[data-increase_quantity]').each(function() {
                  var $q = $el.find('#q_'+$(this).data('increase_quantity'));
                  $(this).toggleClass('disabled', $q.val() >= $q.data('max'));
                });
            Severity: Major
            Found in app/assets/javascripts/ordering.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/ordering.js on lines 206..209

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

            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 body has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def body
                contact = FoodsoftConfig[:contact].symbolize_keys
            
                # From paragraph
                bounding_box [margin_box.right - 200, margin_box.top], width: 200 do
            Severity: Major
            Found in app/documents/order_fax.rb - About 2 hrs to fix

              Method body has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def body
                  # Start rendering
                  each_ordergroup do |ordergroup|
                    down_or_page 15
              
              
              Severity: Major
              Found in plugins/current_orders/app/documents/multiple_orders_by_groups.rb - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language