foodcoop-adam/foodsoft

View on GitHub

Showing 131 of 150 total issues

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

  def sum(type = :gross)
    total = 0
    if type == :net || type == :gross || type == :fc
      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 1 hr to fix

    Function addData has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function addData(orderArticleId, itemPrice, itemUnit, itemSubtotal, itemQuantityOthers, itemToleranceOthers, allocated, available) {
    Severity: Major
    Found in app/assets/javascripts/ordering.js - About 1 hr to fix

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

        def update
          @page = Page.find(params[:id])
          @page.attributes = params[:page].merge({:user => current_user})
      
          if params[:preview]
      Severity: Minor
      Found in lib/foodsoft_wiki/app/controllers/pages_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 enabled? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.enabled?(what)
          case what
          when :signup
            if not FoodsoftConfig[:use_signup].nil?
              FoodsoftConfig[:use_signup]
      Severity: Minor
      Found in lib/foodsoft_signup/lib/foodsoft_signup.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

      Function update has a Cognitive Complexity of 9 (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 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
          @task = Task.find(params[:id])
          was_periodic = @task.periodic?
          @task.attributes=(params[:task])
          if @task.errors.empty? && @task.save
      Severity: Minor
      Found in app/controllers/tasks_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 ordergroup= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def ordergroup=(attributes)
          if attributes[:id].blank? or attributes[:id] == 'new'
            # dissociate the existing ordergroup
            #   deleting the association doesn't work, as it sets the association's group to zero
            ordergroup.user_ids = ordergroup.user_ids.reject {|i| i==self.id} if ordergroup
      Severity: Minor
      Found in app/models/user.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 link_to_wikipage_by_permalink has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def link_to_wikipage_by_permalink(permalink, text = nil)
          unless permalink.blank?
            page = Page.find_by_permalink(permalink)
            if page.nil?
              if text.nil?
      Severity: Minor
      Found in lib/foodsoft_wiki/app/helpers/pages_helper.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 verify has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def verify(message)
          r = super(message)
          raise InvalidMessage unless r.is_a?(Array) and r.length >= 2 and r.length <= 3
          raise InvalidScope unless r[0] == FoodsoftConfig.scope
          raise InvalidPrefix unless r[1] == @_prefix
      Severity: Minor
      Found in lib/token_verifier.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 result has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def result
          result = params[:authResult].downcase
      
          unless Adyen::Form.redirect_signature_check(params, FoodsoftConfig[:adyen]['hmac_key'])
            logger.error "foodsoft_adyen result: invalid signature!"
      Severity: Minor
      Found in lib/foodsoft_adyen/app/controllers/payments/adyen_hpp_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 body has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def body
          @order.order_articles.ordered.each do |order_article|
            rows = []
            dimrows = []
            for goa in order_article.group_order_articles.ordered
      Severity: Minor
      Found in app/documents/order_by_articles.rb - About 45 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 finished_order has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.finished_order(args)
          order_id = args.first
          Order.find(order_id).group_orders.each do |group_order|
            group_order.ordergroup.users.each do |user|
              begin
      Severity: Minor
      Found in app/workers/user_notifier.rb - About 45 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 group_order_article_edit_result has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def group_order_article_edit_result(goa, options={})
          result = goa.result * (options[:multiplier] || 1)
          unless goa.group_order.order.finished? and current_user.role_finance? and options[:edit] != false
            result
          else
      Severity: Minor
      Found in app/helpers/group_order_articles_helper.rb - About 45 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

      Avoid deeply nested control flow statements.
      Open

                case type
                  when :groups
                    total += goa.result * goa.order_article.price.fc_price(goa.group_order.ordergroup)
                  when :groups_without_markup
                    total += goa.result * goa.order_article.price.gross_price(goa.group_order.ordergroup)
      Severity: Major
      Found in app/models/order.rb - About 45 mins to fix

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

          def close!(user)
            raise I18n.t('orders.model.error_closed') if closed?
            transaction_note = I18n.t('orders.model.notice_close', :name => name,
                                      :ends => ends.strftime(I18n.t('date.formats.default')))
        
        
        Severity: Minor
        Found in app/models/order.rb - About 45 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 authenticate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def authenticate(role = 'any')
            # Attempt to retrieve authenticated user from controller instance or session...
            if !current_user
              # No user at all: redirect to login page.
              logout
        Severity: Minor
        Found in app/controllers/application_controller.rb - About 45 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 starts_and_ends_before_pickup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def starts_and_ends_before_pickup
            return unless pickup
            if ends
              errors.add(:pickup, I18n.t('orders.model.error_ends_before_pickup')) if pickup <= ends
            elsif starts
        Severity: Minor
        Found in app/models/order.rb - About 45 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 find_match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.find_match(category)
            return if category.blank? or category.length < 3
            c = nil
            ## exact match - not needed, will be returned by next query as well
            #c ||= ArticleCategory.where(name: category).first
        Severity: Minor
        Found in app/models/article_category.rb - About 45 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 notify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def notify
            notification = AdyenNotification.log(params)
            logger.debug 'foodsoft_adyen: notify'
            if notification.successful_authorisation?
              data = decode_notification_data(notification.merchant_reference)

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

        function data_delta_update(el, direction) {
          var id = $(el).attr('id');
        
          var min = $(el).data('min');
          var max = $(el).data('max');
        Severity: Minor
        Found in app/assets/javascripts/delta_input.js - About 45 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