foodcoop-adam/foodsoft

View on GitHub

Showing 150 of 150 total issues

Method body has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def body
    order_articles = @order.order_articles.ordered

    text I18n.t('documents.order_matrix.heading'), style: :bold
    move_down 5
Severity: Minor
Found in app/documents/order_matrix.rb - About 1 hr 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
        
        if old
    Severity: Minor
    Found in lib/foodsoft_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 article_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.article_data(order)
        article_data = order.order_articles.ordered.includes(:article).map do |oa|
          shared_article = oa.article.shared_article
          units_to_order = oa.units_to_order
          unit_quantity = oa.price.unit_quantity
    Severity: Minor
    Found in lib/foodsoft_orderdoc/lib/foodsoft_orderdoc.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 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_synchronized
        begin
          Article.transaction do
            # delete articles
            if params[:outlisted_articles]
    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 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def body
        # Start rendering
        Ordergroup.joins(:orders).where(:orders => {:id => @order}).select('distinct(groups.id) AS id, groups.name AS name').reorder(:name).each do |ordergroup|
    
          total = 0

      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

        Method config_input_field has a Cognitive Complexity of 14 (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
            config_input_tooltip_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 update_all has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_all
            invalid_articles = false
        
            begin
              Article.transaction do
        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 autologin_foodsoft has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function autologin_foodsoft()
        {
          global $db;
        
          $foodsoftUser = get_foodsoft_user();
        Severity: Minor
        Found in lib/foodsoft_userinfo/examples/phpbb3_auth_foodsoft.php - About 1 hr to fix

          Method calculate_result has 41 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? and not @calculate_result.nil?
          
              quantity = tolerance = total_quantity = 0
          Severity: Minor
          Found in app/models/group_order_article.rb - About 1 hr to fix

            Method sync_all has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def sync_all
                updated_articles = Array.new
                outlisted_articles = Array.new
                new_articles = Array.new
                for article in articles.undeleted
            Severity: Minor
            Found in app/models/supplier.rb - About 1 hr to fix

              Method body has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def body
                  OrderArticle.joins(:order, :article).where(:orders => {:id => @order}).ordered.order('orders.id, articles.name').each do |order_article|
              
                    rows = []
                    dimrows = []

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

                  def order_send_emails
                    return unless FoodsoftConfig[:send_order_on_finish]
                    return unless supplier.order_send_email or FoodsoftConfig[:send_order_on_finish] == 'cc_only'
                    to = FoodsoftConfig[:send_order_on_finish_cc] || []
                    to.map! do |a|
                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 approval_msg has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.approval_msg(c, expand=true)
                    doexpand = lambda {|t,opts| expand ? c.class.helpers.expand_text(t,opts) : t}
                    if s = FoodsoftConfig[:ordergroup_approval_payment]
                      link = c.class.helpers.link_to(I18n.t('foodsoft_signup.payment.msg_link'), payment_link(c))
                      msg = if FoodsoftConfig[:ordergroup_approval_msg]
                Severity: Minor
                Found in lib/foodsoft_signup/lib/foodsoft_signup/hooks.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 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  def ordered_quantities_different_from_group_orders?(ordered_mark="!", billed_mark="?", received_mark="?")
                    if not units_received.nil?
                      ((units_received * price.unit_quantity) == group_orders_sum[:quantity]) ? false : received_mark
                    elsif not 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 body has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def body
                    # Start rendering
                    @order.group_orders.ordered.each do |group_order|
                      total = 0
                      rows = []
                Severity: Minor
                Found in app/documents/order_by_groups.rb - About 1 hr to fix

                  Method included has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def self.included(base) # :nodoc:
                        base.class_eval do
                  
                          # debit membership on ordergroup creation
                          after_create :debit_membership!, :if => proc { FoodsoftSignup.enabled? :membership_fee }
                  Severity: Minor
                  Found in lib/foodsoft_signup/lib/foodsoft_signup/membership_fee.rb - About 1 hr to fix

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

                            def add_financial_transaction!(amount, note, user)
                              result = self.foodsoft_signup_orig_add_financial_transaction!(amount, note, user)
                              if FoodsoftSignup.enabled? :approval and FoodsoftSignup.enabled? :membership_fee
                                if not self.approved? and (diff = amount - FoodsoftConfig[:membership_fee].to_f) > -1e-4
                                  transaction do
                    Severity: Minor
                    Found in lib/foodsoft_signup/lib/foodsoft_signup/membership_fee.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 lib/foodsoft_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] and 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

                    Severity
                    Category
                    Status
                    Source
                    Language