foodcoop-adam/foodsoft

View on GitHub

Showing 131 of 150 total issues

Method body has a Cognitive Complexity of 46 (exceeds 5 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: Minor
Found in app/documents/order_fax.rb - About 7 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 38 (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 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

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

  def load_data
    data = {}
    data[:available_funds] = ordergroup.get_available_funds(self)

    # load prices and other stuff....
Severity: Minor
Found in app/models/group_order.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 body has 115 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 4 hrs to fix

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

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

      Method calculate_result has a Cognitive Complexity of 25 (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? and not @calculate_result.nil?
      
          quantity = tolerance = total_quantity = 0
      Severity: Minor
      Found in app/models/group_order_article.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

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

      class Order < ActiveRecord::Base
        attr_accessor :ignore_warnings
      
        # Associations
        has_many :order_articles, :dependent => :destroy
      Severity: Minor
      Found in app/models/order.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 lib/foodsoft_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 sync_all has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

          def sync_all
            updated_articles = Array.new
            outlisted_articles = Array.new
            new_articles = Array.new
            for article in articles.undeleted
        Severity: Minor
        Found in app/models/supplier.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

        Class ApplicationController has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class ApplicationController < ActionController::Base
          include Foodsoft::ControllerExtensions::Locale
          include Foodsoft::ControllerExtensions::ExceptionHandler
          helper_method :available_locales
        
        
        Severity: Minor
        Found in app/controllers/application_controller.rb - About 2 hrs to fix

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

            def convert_units
              if unit != shared_article.unit
                # legacy, used by foodcoops in Germany
                if shared_article.unit == "KI" and unit == "ST" # 'KI' means a box, with a different amount of items in it
                  # try to match the size out of its name, e.g. "banana 10-12 St" => 10
          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

          Method ensure_file_format has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.ensure_file_format(file, opts={})
              # catch original filename from uploaded files (see `Http::UploadedFile`)
              if file.respond_to?(:tempfile)
                filename = file.original_filename
                file = file.tempfile
          Severity: Minor
          Found in lib/foodsoft_file.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 config_input has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def config_input(form, key, options = {}, &block)
              return unless @cfg.allowed_key? key
              options[:label] ||= config_input_label(form, key)
              options[:required] ||= false
              options[:input_html] ||= {}
          Severity: Minor
          Found in app/helpers/admin/configs_helper.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 17 (exceeds 5 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 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 signup has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def signup
              @user = User.new(params[:user])
              if request.post?
                begin
                  # XXX code-duplication from LoginController#accept_invitation
          Severity: Minor
          Found in lib/foodsoft_signup/app/controllers/signup_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 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def body
              order_articles = @order.order_articles.ordered
          
              text I18n.t('documents.order_matrix.heading'), style: :bold
              move_down 5
          Severity: Minor
          Found in app/documents/order_matrix.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

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

          class User < ActiveRecord::Base
            include RailsSettings::Extend
            #TODO: acts_as_paraniod ??
            
            has_many :memberships, :dependent => :destroy
          Severity: Minor
          Found in app/models/user.rb - About 2 hrs to fix

            Method update_quantities has 53 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

              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
                Severity
                Category
                Status
                Source
                Language