foodcoops/foodsoft

View on GitHub

Showing 134 of 182 total issues

Method update_quantities has 56 lines of code (exceeds 25 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: Major
Found in app/models/group_order_article.rb - About 2 hrs to fix

    Class Ordergroup has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Ordergroup < Group
      include CustomFields
    
      APPLE_MONTH_AGO = 6 # How many month back we will count tasks and orders sum
    
    
    Severity: Minor
    Found in app/models/ordergroup.rb - About 2 hrs to fix

      Method import_data! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def import_data!(data)
          return 0 if data.empty?
      
          booked = data.fetch(:transactions, {}).fetch(:booked, [])
      
      
      Severity: Minor
      Found in app/lib/bank_account_information_importer.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 assign_to_ordergroup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def assign_to_ordergroup
          m = BankTransactionReference.parse(reference)
          return unless m
      
          return false if m[:parts].values.sum != amount
      Severity: Minor
      Found in app/models/bank_transaction.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 sum has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def sum(type = :gross)
          total = 0
          if %i[net gross fc].include?(type)
            for oa in order_articles.ordered.includes(:article, :article_price)
              quantity = oa.units * oa.price.unit_quantity
      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 convert_units has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def convert_units(new_article = shared_article)
          return unless unit != new_article.unit
          return false if new_article.unit.include?(',')
      
          # legacy, used by foodcoops in Germany
      Severity: Minor
      Found in app/models/article.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

      Function update has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function update(item, quantity, tolerance) {
          // set modification flag
          modified = true
      
          // update hidden input fields
      Severity: Major
      Found in app/assets/javascripts/ordering.js - About 2 hrs to fix

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

          def config_input_field(form, key, options = {})
            return unless @cfg.allowed_key? :key
        
            options[:required] ||= false
            config_input_field_options form, key, options
        Severity: Minor
        Found in app/helpers/admin/configs_helper.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 body has a Cognitive Complexity of 15 (exceeds 5 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: Minor
        Found in app/documents/order_matrix.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 diff has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def diff
            current = versions.latest
            old = versions.where(['page_id = ? and lock_version < ?', current.page_id,
                                  current.lock_version]).order('lock_version DESC').first
        
        
        Severity: Minor
        Found in plugins/wiki/app/models/page.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 import has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def import
            @bank_account = BankAccount.find(params[:id])
            importer = @bank_account.find_connector
        
            if importer
        Severity: Minor
        Found in app/controllers/finance/bank_accounts_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 body has 46 lines of code (exceeds 25 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 1 hr to fix

          Function unlist has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          w.List.prototype.templateEngines.unlist = function(list, settings) {
            var h = w.ListJsHelpers;
            
            // start with standard engine, override specific methods afterwards
            this.superClass = w.List.prototype.templateEngines.standard;
          Severity: Minor
          Found in app/assets/javascripts/list.unlist.js - About 1 hr to fix

            Method vote has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def vote
                @poll = Poll.find(params[:id])
            
                if @poll.one_vote_per_ordergroup
                  ordergroup = current_user.ordergroup
            Severity: Minor
            Found in plugins/polls/app/controllers/polls_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 parse_recurring_selects! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def parse_recurring_selects!(config)
                return unless config
            
                for k in %i[pickup boxfill ends] do
                  if config[k]
            Severity: Minor
            Found in app/controllers/admin/configs_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 receive has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def receive
                @order = Order.find(params[:id])
                if request.post?
                  Order.transaction do
                    s = update_order_amounts
            Severity: Minor
            Found in app/controllers/orders_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

            Function update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            function update(item, quantity, tolerance) {
                // set modification flag
                modified = true
            
                // update hidden input fields
            Severity: Minor
            Found in app/assets/javascripts/ordering.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 calculate_result has 42 lines of code (exceeds 25 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 1 hr to fix

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

                def body
                  each_order_article do |order_article|
                    down_or_page
              
                    rows = []
              Severity: Minor
              Found in plugins/current_orders/app/documents/multiple_orders_by_articles.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 user_can_vote? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def user_can_vote?(user)
                  Ordergroup.custom_fields.each do |field|
                    name = field[:name]
                    next unless required_ordergroup_custom_fields.include? name
                    return false if user.ordergroup.nil? || user.ordergroup.settings.custom_fields[name].blank?
              Severity: Minor
              Found in plugins/polls/app/models/poll.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

              Severity
              Category
              Status
              Source
              Language