foodcoops/foodsoft

View on GitHub

Showing 134 of 182 total issues

Method ordergroup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def ordergroup
    @user = @current_user
    @ordergroup = @user.ordergroup

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

  def self.parse(file, options = {})
    SpreadsheetFile.parse file, options do |row, row_index|
      next if row[2].blank?

      article = { order_number: row[1],
Severity: Minor
Found in app/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 init_dates has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def init_dates
    self.starts ||= Time.now
    if FoodsoftConfig[:order_schedule]
      # try to be smart when picking a reference day
      last = begin
Severity: Minor
Found in app/models/order.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_synchronized has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def update_synchronized
    @outlisted_articles = Article.find(params[:outlisted_articles].try(:keys) || [])
    @updated_articles = Article.find(params[:articles].try(:keys) || [])
    @updated_articles.map { |a| a.assign_attributes(params[:articles][a.id.to_s]) }
    @new_articles = (params[:new_articles] || []).map { |a| @supplier.articles.build(a) }
Severity: Minor
Found in app/controllers/articles_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 index has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    sort = if params['sort']
             case params['sort']
             when 'name' then 'articles.name'
             when 'unit' then 'articles.unit'
Severity: Minor
Found in app/controllers/articles_controller.rb - About 1 hr to fix

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

      def sum(type = :gross)
        total = 0
        if %i[net gross fc].include?(type)
          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

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

        def received(data)
          mail = Mail.new data
      
          mail_part = get_mail_part(mail)
          raise 'No valid content could be found' if mail_part.nil?
      Severity: Minor
      Found in plugins/messages/app/mail_receivers/messages_mail_receiver.rb - About 1 hr to fix

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

          def index
            sort = if params['sort']
                     case params['sort']
                     when 'date' then 'date'
                     when 'amount' then 'amount'
        Severity: Minor
        Found in app/controllers/finance/bank_transactions_controller.rb - About 1 hr to fix

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

            def index
              sort = if params['sort']
                       case params['sort']
                       when 'date' then 'created_on'
                       when 'note'   then 'note'
          Severity: Minor
          Found in app/controllers/finance/financial_transactions_controller.rb - About 1 hr to fix

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

              def unequal_attributes(new_article, options = {})
                # try to convert different units when desired
                if options[:convert_units] == false
                  new_price = nil
                  new_unit_quantity = nil
            Severity: Minor
            Found in app/models/article.rb - About 1 hr to fix

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

                def import
                  @bank_account = BankAccount.find(params[:id])
                  importer = @bank_account.find_connector
              
                  if importer
              Severity: Minor
              Found in app/controllers/finance/bank_accounts_controller.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

                  Consider simplifying this complex logical expression.
                  Open

                      unless (delta_q == 0 && delta_t >= 0) ||
                             (delta_mis < 0 && delta_box >= 0 && delta_t >= 0) ||
                             (delta_q > 0 && delta_q == -delta_t)
                        raise ActiveRecord::RecordNotSaved.new("Change not acceptable in boxfill phase for '#{article.name}', sorry.",
                                                               self)
                  Severity: Major
                  Found in app/models/order_article.rb - 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 plugins/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

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

                      def perform(order)
                        order.group_orders.each do |group_order|
                          next unless group_order.ordergroup
                    
                          group_order.ordergroup.users.each do |user|
                    Severity: Minor
                    Found in app/jobs/notify_finished_order_job.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) && r.length >= 2 && r.length <= 3
                        raise InvalidScope unless r[0] == FoodsoftConfig.scope
                        raise InvalidPrefix unless r[1] == @_prefix
                    Severity: Minor
                    Found in app/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 perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def perform(order)
                        order.group_orders.each do |group_order|
                          next unless group_order.ordergroup
                    
                          group_order.ordergroup.users.each do |user|
                    Severity: Minor
                    Found in app/jobs/notify_received_order_job.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 9 (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 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 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def body
                        each_order_article do |order_article|
                          dimrows = []
                          rows = [[
                            GroupOrder.human_attribute_name(:ordergroup),
                    Severity: Minor
                    Found in app/documents/order_by_articles.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

                    Severity
                    Category
                    Status
                    Source
                    Language