foodcoops/foodsoft

View on GitHub

Showing 182 of 182 total issues

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

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

          def sync_all
            updated_article_pairs = []
            outlisted_articles = []
            new_articles = []
            existing_articles = Set.new
        Severity: Minor
        Found in app/models/supplier.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 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 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 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 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

                    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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                          $(document).on('click', 'a[data-remove-this]', function() {
                              $($(this).data('remove-this')).remove();
                              return false;
                          });
                      Severity: Major
                      Found in app/assets/javascripts/application_legacy.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/application_legacy.js on lines 31..34

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 55.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      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

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            $(document).on('click', 'a[data-toggle-this]', function() {
                                $($(this).data('toggle-this')).toggle();
                                return false;
                            });
                        Severity: Major
                        Found in app/assets/javascripts/application_legacy.js and 1 other location - About 1 hr to fix
                        app/assets/javascripts/application_legacy.js on lines 37..40

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 55.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        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

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              def navigation(primary, context)
                                return unless FoodsoftPolls.enabled?
                                return if primary[:foodcoop].nil?
                          
                                sub_nav = primary[:foodcoop].sub_navigation
                          Severity: Minor
                          Found in plugins/polls/lib/foodsoft_polls/engine.rb and 1 other location - About 1 hr to fix
                          plugins/documents/lib/foodsoft_documents/engine.rb on lines 3..13

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 47.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language