foodcoop-adam/foodsoft

View on GitHub

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

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

        $(document).on('click', 'a[data-remove-this]', function() {
            $($(this).data('remove-this')).remove();
            return false;
        });
    Severity: Major
    Found in app/assets/javascripts/application.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/application.js on lines 28..31

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

    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

        $(document).on('click', 'a[data-toggle-this]', function() {
            $($(this).data('toggle-this')).toggle();
            return false;
        });
    Severity: Major
    Found in app/assets/javascripts/application.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/application.js on lines 34..37

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

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

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

              if (quantity < self.quantity && quantities[i].quantity > 0)
                delta = self.quantity - quantity
                delta = (delta > quantities[i].quantity ? quantities[i].quantity : delta)
                logger.debug("Decreasing quantity by #{delta}")
                quantities[i].quantity -= delta
      Severity: Minor
      Found in app/models/group_order_article.rb and 1 other location - About 55 mins to fix
      app/models/group_order_article.rb on lines 66..72

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

      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 (tolerance < self.tolerance && quantities[i].tolerance > 0)
                delta = self.tolerance - tolerance
                delta = (delta > quantities[i].tolerance ? quantities[i].tolerance : delta)
                logger.debug("Decreasing tolerance by #{delta}")
                quantities[i].tolerance -= delta
      Severity: Minor
      Found in app/models/group_order_article.rb and 1 other location - About 55 mins to fix
      app/models/group_order_article.rb on lines 59..65

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

      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

        $(document).on('click', 'button[data-decrement]', function() {
          data_delta_update($('#'+$(this).data('decrement')), -1);
        });
      Severity: Minor
      Found in app/assets/javascripts/delta_input.js and 1 other location - About 50 mins to fix
      app/assets/javascripts/delta_input.js on lines 3..5

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

      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

        $(document).on('click', 'button[data-increment]', function() {
          data_delta_update($('#'+$(this).data('increment')), +1);
        });
      Severity: Minor
      Found in app/assets/javascripts/delta_input.js and 1 other location - About 50 mins to fix
      app/assets/javascripts/delta_input.js on lines 6..8

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

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

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

          begin
            @group_order.save_ordering!
            redirect_to group_order_url(@group_order), :notice => I18n.t('group_orders.update.notice')
          rescue ActiveRecord::StaleObjectError
            redirect_to group_orders_url, :alert => I18n.t('group_orders.update.error_stale')
      Severity: Minor
      Found in app/controllers/group_orders_controller.rb and 1 other location - About 45 mins to fix
      app/controllers/group_orders_controller.rb on lines 21..29

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

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

      Severity
      Category
      Status
      Source
      Language