dobtco/procure-io

View on GitHub

Showing 46 of 67 total issues

Function length has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      length: function(element, options) {
        var CHECKS, blankOptions, check, fn, message, operator, tokenized_length, tokenizer;
        tokenizer = options.js_tokenizer || "split('')";
        tokenized_length = new Function('element', "return (element.val()." + tokenizer + " || '').length")(element);
        CHECKS = {
Severity: Minor
Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

    Method display_value has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def display_value
        case response_field.field_type
        when "price"
          "$#{value}"
        when "date"
    Severity: Minor
    Found in app/models/response.rb - About 1 hr to fix

      Method notification_preference_choices has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.notification_preference_choices
          {
            teams: {
              added_to_team: [:added_to_organization_team, :added_to_vendor_team],
              added_your_team_to_project: true
      Severity: Minor
      Found in app/models/user.rb - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

            if (event_type.in?(Event.event_types.only(:your_bid_awarded, :bid_awarded).values) &&
                data[:bid][:award_message]) ||
        
               # Your bid is dismissed and you're allowed to see the dismissal message
               (event_type == Event.event_types[:your_bid_dismissed] &&
        Severity: Major
        Found in app/models/event.rb - About 1 hr to fix

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

            def active_page?(action, class_to_add = "active")
              pieces = action.split(/\#|\?/)
              is_active_page = true
          
              pieces.each_with_index do |piece, index|
          Severity: Minor
          Found in app/helpers/application_helper.rb - About 55 mins 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 save_responses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def save_responses(responsable, response_fields)
              response_fields.each do |response_field|
                next unless params[:response_fields] && (response_field_params = params[:response_fields][response_field.id.to_s])
          
                response = responsable.responses.where(response_field_id: response_field.id).first_or_initialize(user_id: current_user.id)
          Severity: Minor
          Found in app/helpers/save_responses_helper.rb - About 55 mins 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 has_searcher has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def has_searcher(args = {})
                send(:include, PgSearch)
          
                if args[:starting_query]
                  define_singleton_method :searcher_starting_query do
          Severity: Minor
          Found in lib/searcher.rb - About 55 mins 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_i18n_interpolation_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def calculate_i18n_interpolation_data
              return_hash = {}
          
              attrs = [
                "user.display_name", "bid.vendor.name", "project.title", "vendor.name",
          Severity: Minor
          Found in app/models/event.rb - About 55 mins 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 active_user_sidebar_section? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def active_user_sidebar_section?(type, obj = nil)
              is_active_section = case type
              when :user
                active_page?('home#dashboard') ||
                active_page?('notifications#index') ||
          Severity: Minor
          Found in app/helpers/application_helper.rb - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                            if ($(this).data('notLocallyUnique')) {
                              return $(this).removeData('notLocallyUnique').data('changed', true);
                            }
          Severity: Major
          Found in app/assets/javascripts/rails.validations.js - About 45 mins to fix

            Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def initialize(user)
                can :read, Project do |project|
                  project.posted_at
                end
            
            
            Severity: Minor
            Found in app/models/ability.rb - About 45 mins 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 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                @user = user_from_params
            
                if @user.save
                  sign_in @user
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 45 mins 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 has_additional_text? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def has_additional_text?
                   # Bid is awarded and has an award message
                if (event_type.in?(Event.event_types.only(:your_bid_awarded, :bid_awarded).values) &&
                    data[:bid][:award_message]) ||
            
            
            Severity: Minor
            Found in app/models/event.rb - About 35 mins 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 add_params_to_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.add_params_to_query(query, params, args = {})
                if params[:q] && !params[:q].blank?
                  query = query.full_search(params[:q])
                end
            
            
            Severity: Minor
            Found in app/models/form_template.rb - About 35 mins 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

            Avoid too many return statements within this function.
            Open

                        return;
            Severity: Major
            Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                        return options.message;
              Severity: Major
              Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return options.messages[check];
                Severity: Major
                Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                            return options.messages.odd;
                  Severity: Major
                  Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                              return options.messages.even;
                    Severity: Major
                    Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

                      Method extra_user_links has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def extra_user_links(opts = {})
                          links = []
                      
                          links << link_to(I18n.t('g.sign_in'), sign_in_path) unless opts[:without] == "sign_in"
                          links << link_to(I18n.t('g.sign_up'), sign_up_path) unless opts[:without] == "sign_up"
                      Severity: Minor
                      Found in app/helpers/application_helper.rb - About 25 mins 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