foodcoop-adam/foodsoft

View on GitHub

Showing 131 of 150 total issues

Function delay has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

window.List.prototype.plugins.delay = function(locals, options) {
  var list = this;
  
  this.searchTimeout = undefined;
  
Severity: Minor
Found in app/assets/javascripts/list.delay.js - About 1 hr to fix

    Method update_order_amounts has 33 lines of code (exceeds 25 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 1 hr to fix

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

        def update_article_and_price!(order_article_attributes, article_attributes, price_attributes = nil)
          OrderArticle.transaction do
            # Updates self
            self.update_attributes!(order_article_attributes)
      
      
      Severity: Minor
      Found in app/models/order_article.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 units_history_line has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def units_history_line(order_article, order=nil, options={})
          order ||= order_article.order
          if order.open?
            nil
          else
      Severity: Minor
      Found in app/helpers/orders_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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          # turn recurring rules into something palatable
          if p = params[:config][:order_schedule]
            for k in [:pickup, :ends] do
              if p[k] and p[k][:recurr]
      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 finish has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def finish
          @order = Order.find params[:id]
          @order_info = params[:order_info] || {}
          @order_info[:sender_name] ||= @current_user.name
          @order_info[:order_contact_name] ||= @current_user.name
      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

      Method parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.parse(file, opts={})
          articles, outlisted_articles = Array.new, Array.new
          row_index = 2
          data = read_file file, opts
          col_sep = csv_guess_col_sep data
      Severity: Minor
      Found in lib/foodsoft_file.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 ensure_file_format has 30 lines of code (exceeds 25 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 1 hr to fix

        Method show has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def show
            @order= Order.find(params[:id])
            @view = (params[:view] or 'default').gsub(/[^-_a-zA-Z0-9]/, '')
            @partial = case @view
                         when 'default'  then 'articles'
        Severity: Minor
        Found in app/controllers/orders_controller.rb - About 1 hr to fix

          Method parse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.parse(file, opts={})
              articles, outlisted_articles = Array.new, Array.new
              row_index = 2
              data = read_file file, opts
              col_sep = csv_guess_col_sep data
          Severity: Minor
          Found in lib/foodsoft_file.rb - About 1 hr to fix

            Function reset has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            window.List.prototype.plugins.reset = function(locals, options) {
              var list = this;
              
              var init = {
                start: function(options) {
            Severity: Minor
            Found in app/assets/javascripts/list.reset.js - About 1 hr to fix

              Method export has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.export(article_data, search_path=[])
                  begin
                    src = check_export article_data, search_path
                  rescue OrderdocException => e
                    return {error: e.message}
              Severity: Minor
              Found in lib/foodsoft_orderdoc/lib/foodsoft_orderdoc/export_helper.rb - About 1 hr to fix

                Method update_synchronized has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def update_synchronized
                    begin
                      Article.transaction do
                        # delete articles
                        if params[:outlisted_articles]
                Severity: Minor
                Found in app/controllers/articles_controller.rb - About 1 hr to fix

                  Function autologin_foodsoft has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function autologin_foodsoft()
                  {
                    global $db;
                  
                    $foodsoftUser = get_foodsoft_user();
                  Severity: Minor
                  Found in lib/foodsoft_userinfo/examples/phpbb3_auth_foodsoft.php - 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 shared_article_changed? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def shared_article_changed?(supplier = self.supplier)
                      # skip early if the timestamp hasn't changed
                      shared_article = self.shared_article(supplier)
                      unless shared_article.nil? or self.shared_updated_on == shared_article.updated_on
                        
                  Severity: Minor
                  Found in app/models/article.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 []= has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def []=(key, value)
                        key = key.to_sym
                        return false unless allowed_key?(key)
                        value = normalize_value value
                        # then update database
                  Severity: Minor
                  Found in lib/foodsoft_config.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 ordergroup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def ordergroup
                      @user = @current_user
                      @ordergroup = @user.ordergroup
                  
                      unless @ordergroup.nil?
                  Severity: Minor
                  Found in app/controllers/home_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 shared_article_changed? has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def shared_article_changed?(supplier = self.supplier)
                      # skip early if the timestamp hasn't changed
                      shared_article = self.shared_article(supplier)
                      unless shared_article.nil? or self.shared_updated_on == shared_article.updated_on
                        
                  Severity: Minor
                  Found in app/models/article.rb - About 1 hr to fix

                    Method notify has 27 lines of code (exceeds 25 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)

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

                        def create
                          authenticate_membership_or_admin params[:invite][:group_id]
                          # admins may send invites to multiple email addresses at once
                          emails = params[:invite][:email]
                          emails = emails.split(/\s*(,|\s)\s*/).reject{|e| e.blank? or e==','} if @current_user.role_admin?
                      Severity: Minor
                      Found in app/controllers/invites_controller.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language