foodcoop-adam/foodsoft

View on GitHub

Showing 150 of 150 total issues

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

  def link_to_ordering(order, options = {}, &block)
    group_order = order.group_order(current_user.ordergroup)
    path = if options[:show] and group_order
            group_order_path(group_order)
          elsif group_order
Severity: Minor
Found in app/helpers/group_orders_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

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

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

    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

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

      def show_price_markup(id, options = {})
        list = FoodsoftConfig[:price_markup_list] or return
        id = id.price_markup_key if id.is_a? Ordergroup
        return if options[:optional] and id == FoodsoftConfig[:price_markup]
    
    
    Severity: Minor
    Found in app/helpers/shared_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

    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

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

      def body
        OrderArticle.joins(:order, :article).where(:orders => {:id => @order}).ordered.order('orders.id, articles.name').each do |order_article|
    
          rows = []
          dimrows = []
    Severity: Minor
    Found in lib/foodsoft_current_orders/app/documents/multiple_orders_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 user_for_ordergroup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.user_for_ordergroup(ordergroup)
        unless ordergroup.kind_of?(Ordergroup)
          begin
            ordergroup = Ordergroup.undeleted.find(ordergroup)
          rescue ActiveRecord::RecordNotFound
    Severity: Minor
    Found in lib/foodsoft_vokomokum/lib/foodsoft_vokomokum/export.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.create.notice')
        rescue ActiveRecord::StaleObjectError
          redirect_to group_orders_url, :alert => I18n.t('group_orders.create.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 47..55

    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

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

          order_quantities.each do |goaq|
            q = [goaq.quantity, total - total_quantity].min
            total_quantity += q
            if goaq.group_order_article_id == self.id
              logger.debug "increasing quantity by #{q}"
    Severity: Minor
    Found in app/models/group_order_article.rb and 1 other location - About 40 mins to fix
    app/models/group_order_article.rb on lines 148..155

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

    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

            order_quantities.each do |goaq|
              q = [goaq.tolerance, total - total_quantity].min
              total_quantity += q
              if goaq.group_order_article_id == self.id
                logger.debug "increasing tolerance by #{q}"
    Severity: Minor
    Found in app/models/group_order_article.rb and 1 other location - About 40 mins to fix
    app/models/group_order_article.rb on lines 135..142

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

    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 login_foodsoft has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function login_foodsoft($username, $password, $ip = '', $borwser = '', $forwarded_for = '')
    Severity: Minor
    Found in lib/foodsoft_userinfo/examples/phpbb3_auth_foodsoft.php - About 35 mins to fix

      Method update_or_create_user has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def update_or_create_user(id, email, first_name, last_name, workgroups=[])
      Severity: Minor
      Found in lib/foodsoft_vokomokum/app/controllers/vokomokum_controller.rb - About 35 mins to fix

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

              if params['sort']
                sort = case params['sort']
                when "date"  then "created_on"
                when "note"   then "note"
                when "amount" then "amount"
        Severity: Minor
        Found in app/controllers/home_controller.rb and 2 other locations - About 35 mins to fix
        app/controllers/finance/financial_transactions_controller.rb on lines 10..20
        app/controllers/finance/ordergroups_controller.rb on lines 4..14

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

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

          def search_data(query, field)
            # is_a? on ActiveRecord doesn't work http://stackoverflow.com/questions/7828666
            if query.respond_to? :offset
              limit = (params[:limit] or 10)
              offset = (params[:offset] or 0)
        Severity: Minor
        Found in app/controllers/application_controller.rb - About 35 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 order_checks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def order_checks(order)
            result = [] # array of [true/false/:warn/nil, message]
            # need articles to order
            if order.order_articles.ordered.count == 0
              result << [false, I18n.t('helpers.orders.order_checks.none_ordered', count: order.order_articles.ordered.count)]
        Severity: Minor
        Found in app/helpers/orders_helper.rb - About 35 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 sort_link_helper has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def sort_link_helper(text, key, options = {})
            # Hmtl options
            remote = options[:remote].nil? ? true : options[:remote]
            class_name = case params[:sort]
                           when key then
        Severity: Minor
        Found in app/helpers/application_helper.rb - About 35 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