foodcoops/foodsoft

View on GitHub

Showing 182 of 182 total issues

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

  def parse_recurring_selects!(config)
    return unless config

    for k in %i[pickup boxfill ends] do
      if config[k]
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 calculate_result has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def calculate_result(total = nil)
    # return memoized result unless a total is given
    return @calculate_result if total.nil? && !@calculate_result.nil?

    quantity = tolerance = total_quantity = 0
Severity: Minor
Found in app/models/group_order_article.rb - About 1 hr to fix

    Method user_can_vote? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def user_can_vote?(user)
        Ordergroup.custom_fields.each do |field|
          name = field[:name]
          next unless required_ordergroup_custom_fields.include? name
          return false if user.ordergroup.nil? || user.ordergroup.settings.custom_fields[name].blank?
    Severity: Minor
    Found in plugins/polls/app/models/poll.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 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def body
        each_order_article do |order_article|
          down_or_page
    
          rows = []
    Severity: Minor
    Found in plugins/current_orders/app/documents/multiple_orders_by_articles.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_all has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_all
        invalid_articles = false
    
        Article.transaction do
          if params[:articles].present?
    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 body has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def body
        each_order_article do |order_article|
          down_or_page
    
          rows = []
    Severity: Minor
    Found in plugins/current_orders/app/documents/multiple_orders_by_articles.rb - About 1 hr to fix

      Method update_order_amounts has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def update_order_amounts
          return unless params[:order_articles]
      
          # where to leave remainder during redistribution
          rest_to = []
      Severity: Minor
      Found in app/controllers/orders_controller.rb - About 1 hr to fix

        Method show has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def show
            if params[:permalink]
              @page = Page.find_by_permalink(params[:permalink])
            elsif params[:id]
              page = Page.find_by_id(params[:id])
        Severity: Minor
        Found in plugins/wiki/app/controllers/pages_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 ordered_quantities_different_from_group_orders? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def ordered_quantities_different_from_group_orders?(ordered_mark = '!', billed_mark = '?', received_mark = '?')
            if !units_received.nil?
              (units_received * price.unit_quantity) == group_orders_sum[:quantity] ? false : received_mark
            elsif !units_billed.nil?
              (units_billed * price.unit_quantity) == group_orders_sum[:quantity] ? false : billed_mark
        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 show_user has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def show_user(user = @current_user, options = {})
            if user.nil?
              '?'
            elsif FoodsoftConfig[:use_nick]
              if options[:full] && options[:markup]
        Severity: Minor
        Found in app/helpers/application_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 create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @document = Document.new name: params[:document][:name]
            @document.parent = Document.find_by_id(params[:document][:parent_id])
            data = params[:document][:data]
            if data
        Severity: Minor
        Found in plugins/documents/app/controllers/documents_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 create_collection has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create_collection
            raise I18n.t('finance.financial_transactions.controller.create_collection.error_note_required') if params[:note].blank?
        
            type = FinancialTransactionType.find_by_id(params[:type_id])
            financial_link = nil
        Severity: Minor
        Found in app/controllers/finance/financial_transactions_controller.rb - About 1 hr to fix

          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 initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def initialize(options = {})
                options[:font_size] ||= FoodsoftConfig[:pdf_font_size].try(:to_f) || 12
                options[:page_size] ||= FoodsoftConfig[:pdf_page_size] || 'A4'
                options[:skip_page_creation] = true
                @options = options
            Severity: Minor
            Found in app/lib/render_pdf.rb - About 1 hr to fix

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

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

                  def units_history_line(order_article, options = {})
                    if order_article.order.open?
                      nil
                    else
                      units_info = []
                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
                    @task = Task.find(params[:id])
                    task_group = @task.periodic_task_group
                    was_periodic = @task.periodic?
                    prev_due_date = @task.due_date
                Severity: Minor
                Found in app/controllers/tasks_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 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
                      update!(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 change has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def change
                    create_table :polls do |t|
                      t.integer :created_by_user_id, null: false
                      t.string :name, null: false
                      t.text :description
                Severity: Minor
                Found in plugins/polls/db/migrate/20181110000000_create_polls.rb - About 1 hr to fix

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

                    def show
                      @items = @financial_link.bank_transactions.map do |bt|
                        {
                          date: bt.date,
                          type: t('activerecord.models.bank_transaction'),
                  Severity: Minor
                  Found in app/controllers/finance/financial_links_controller.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language