dobtco/procure-io

View on GitHub

Showing 46 of 67 total issues

File rails.validations.js has 622 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function() {
  var $, validateElement, validateForm, validatorsFor,
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  $ = jQuery;
Severity: Major
Found in app/assets/javascripts/rails.validations.js - About 1 day to fix

    Consider simplifying this complex logical expression.
    Open

        return false if !response_field.field_options["required"] || # field is not required
                        (response && response.upload?) || # file has been uploaded
                        (value && !value.blank? && !value.is_a?(Hash)) || # value isn't blank (ignore hashes)
                        (response_field.field_type.in?(ResponseField::OPTIONS_FIELDS) && (response_field.field_options["options"] || []).empty?) ||
                        response_field.field_type == "checkboxes" && value && value.reject{|k, v| !v}.length > 0 || # required checkboxes have at least one checkbox checked
    Severity: Critical
    Found in lib/responsable_validator.rb - About 6 hrs to fix

      Method add_params_to_query has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.add_params_to_query(query, params, args = {})
          if args[:vendor_searching]
            if !params[:q].blank?
              query = query.full_search_vendor(params[:q])
            end
      Severity: Minor
      Found in app/models/bid.rb - About 5 hrs 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

      Class User has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class User < ActiveRecord::Base
        include Clearance::User
      
        attr_accessor :is_inviting
        attr_accessor :is_admining
      Severity: Minor
      Found in app/models/user.rb - About 3 hrs to fix

        Function input has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            input: function(input) {
              var $form, $input, binding, event, form, _ref;
              $input = $(input);
              form = input.form;
              $form = $(form);
        Severity: Major
        Found in app/assets/javascripts/rails.validations.js - About 2 hrs to fix

          Method serialized has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def serialized(*args)
              obj = args[0]
              is_collection = obj.respond_to?(:each)
          
              if args[1].is_a?(Hash)
          Severity: Minor
          Found in app/helpers/serialization_helper.rb - About 2 hrs 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

          Function uniqueness has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                uniqueness: function(element, options) {
                  var data, key, message, name, scope_value, scoped_element, scoped_name, _ref;
                  message = ClientSideValidations.validators.local.presence(element, options);
                  if (message) {
                    if (options.allow_blank === true) {
          Severity: Major
          Found in app/assets/javascripts/rails.validations.js - About 2 hrs to fix

            Method calculate_sortable_value has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              def calculate_sortable_value
                self.sortable_value = case response_field.field_type
                when "date"
                  ['year', 'month', 'day'].each { |x| return 0 unless value[x] && !value[x].blank? }
                  DateTime.new(value['year'].to_i, value['month'].to_i, value['day'].to_i).to_i rescue 0
            Severity: Minor
            Found in app/models/response.rb - About 2 hrs 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 initialize has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def initialize(user)
                can :read, Project do |project|
                  project.posted_at
                end
            
            
            Severity: Major
            Found in app/models/ability.rb - About 2 hrs to fix

              Method add_params_to_query has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.add_params_to_query(query, params, args = {})
                  if args[:vendor_searching]
                    if !params[:q].blank?
                      query = query.full_search_vendor(params[:q])
                    end
              Severity: Minor
              Found in app/models/bid.rb - About 1 hr to fix

                Function numericality has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      numericality: function(element, options) {
                        var CHECKS, check, check_value, fn, form, operator, val;
                        val = jQuery.trim(element.val());
                        if (!ClientSideValidations.patterns.numericality.test(val)) {
                          if (options.allow_blank === true && this.presence(element, {
                Severity: Minor
                Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

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

                    def required_field(response_field, response, value)
                      return false if !response_field.field_options["required"] || # field is not required
                                      (response && response.upload?) || # file has been uploaded
                                      (value && !value.blank? && !value.is_a?(Hash)) || # value isn't blank (ignore hashes)
                                      (response_field.field_type.in?(ResponseField::OPTIONS_FIELDS) && (response_field.field_options["options"] || []).empty?) ||
                  Severity: Minor
                  Found in lib/responsable_validator.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

                  Function form has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      form: function(form) {
                        var $form, binding, event, _ref;
                        $form = $(form);
                        form.ClientSideValidations = {
                          settings: window.ClientSideValidations.forms[$form.attr('id')],
                  Severity: Minor
                  Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

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

                      def import
                        @csv.each do |row|
                          row = transform_row(row)
                    
                          if @params[:associate_vendor_account]
                    Severity: Minor
                    Found in lib/csv_bid_importer.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 serialized has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def serialized(*args)
                        obj = args[0]
                        is_collection = obj.respond_to?(:each)
                    
                        if args[1].is_a?(Hash)
                    Severity: Minor
                    Found in app/helpers/serialization_helper.rb - About 1 hr to fix

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

                        def self.add_params_to_query(query, params, args = {})
                          if !params[:q].blank?
                            query = query.full_search(params[:q])
                          end
                      
                      
                      Severity: Minor
                      Found in app/models/project.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 add_params_to_query has a Cognitive Complexity of 11 (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/team.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

                      Function inclusion has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            inclusion: function(element, options) {
                              var lower, message, option, upper, _ref;
                              message = this.presence(element, options);
                              if (message) {
                                if (options.allow_blank === true) {
                      Severity: Minor
                      Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

                        Function exclusion has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              exclusion: function(element, options) {
                                var lower, message, option, upper, _ref;
                                message = this.presence(element, options);
                                if (message) {
                                  if (options.allow_blank === true) {
                        Severity: Minor
                        Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

                          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
                            Severity
                            Category
                            Status
                            Source
                            Language