foodcoops/foodsoft

View on GitHub

Showing 182 of 182 total issues

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

  def sync_from_file(file, options = {})
    all_order_numbers = []
    updated_article_pairs = []
    outlisted_articles = []
    new_articles = []
Severity: Minor
Found in app/models/supplier.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 OrderArticle has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class OrderArticle < ApplicationRecord
  include FindEachWithOrder

  attr_reader :update_global_price

Severity: Minor
Found in app/models/order_article.rb - About 2 hrs to fix

    Method date_time_attribute has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def date_time_attribute(*attributes)
          super
    
          attributes.each do |attribute|
            validate -> { send("#{attribute}_datetime_value_valid") }
    Severity: Major
    Found in app/lib/date_time_attribute_validate.rb - About 2 hrs to fix

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

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

        class Ordergroup < Group
          include CustomFields
        
          APPLE_MONTH_AGO = 6 # How many month back we will count tasks and orders sum
        
        
        Severity: Minor
        Found in app/models/ordergroup.rb - About 2 hrs to fix

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

            def convert_units(new_article = shared_article)
              return unless unit != new_article.unit
              return false if new_article.unit.include?(',')
          
              # legacy, used by foodcoops in Germany
          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 import_data! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def import_data!(data)
              return 0 if data.empty?
          
              booked = data.fetch(:transactions, {}).fetch(:booked, [])
          
          
          Severity: Minor
          Found in app/lib/bank_account_information_importer.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 16 (exceeds 5 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 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 assign_to_ordergroup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def assign_to_ordergroup
              m = BankTransactionReference.parse(reference)
              return unless m
          
              return false if m[:parts].values.sum != amount
          Severity: Minor
          Found in app/models/bank_transaction.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

          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

            Method diff has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def diff
                current = versions.latest
                old = versions.where(['page_id = ? and lock_version < ?', current.page_id,
                                      current.lock_version]).order('lock_version DESC').first
            
            
            Severity: Minor
            Found in plugins/wiki/app/models/page.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 body has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def body
                order_articles_data = [[
                  OrderArticle.human_attribute_name(:article),
                  Article.human_attribute_name(:supplier),
                  ArticlePrice.human_attribute_name(:unit_quantity),
            Severity: Minor
            Found in app/documents/order_matrix.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 import has a Cognitive Complexity of 15 (exceeds 5 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

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

              def config_input_field(form, key, options = {})
                return unless @cfg.allowed_key? :key
            
                options[:required] ||= false
                config_input_field_options form, key, options
            Severity: Minor
            Found in app/helpers/admin/configs_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 body has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def body
                each_ordergroup do |oa_name, oa_total, oa_id, oa_transport|
                  has_transport = !oa_transport.nil? && oa_transport > 0
                  dimrows = []
                  rows = [[
            Severity: Minor
            Found in app/documents/order_by_groups.rb - About 1 hr to fix

              Function unlist has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              w.List.prototype.templateEngines.unlist = function(list, settings) {
                var h = w.ListJsHelpers;
                
                // start with standard engine, override specific methods afterwards
                this.superClass = w.List.prototype.templateEngines.standard;
              Severity: Minor
              Found in app/assets/javascripts/list.unlist.js - About 1 hr to fix

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

                  def vote
                    @poll = Poll.find(params[:id])
                
                    if @poll.one_vote_per_ordergroup
                      ordergroup = current_user.ordergroup
                Severity: Minor
                Found in plugins/polls/app/controllers/polls_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 receive has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  def receive
                    @order = Order.find(params[:id])
                    if request.post?
                      Order.transaction do
                        s = update_order_amounts
                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

                Severity
                Category
                Status
                Source
                Language