foodcoops/foodsoft

View on GitHub

Showing 134 of 182 total issues

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 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 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 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 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 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

        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

          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 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 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 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 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

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

                    Method sync_from_file has 28 lines of code (exceeds 25 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 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 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

                        Severity
                        Category
                        Status
                        Source
                        Language