kalkov/rails4_client_side_validations

View on GitHub

Showing 19 of 21 total issues

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

    def can_use_for_client_side_validation?(attr, validator, force)
      if validator_turned_off?(attr, validator, force)
        result = false
      else
        # Yeah yeah, #new_record? is not part of ActiveModel :p
Severity: Minor
Found in lib/rails4_client_side_validations/active_model.rb - About 3 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 client_side_form_settings has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def client_side_form_settings(object, options, builder)
      if options[:validate]
        if options[:id]
          var_name = options[:id]
        else
Severity: Minor
Found in lib/rails4_client_side_validations/action_view/form_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

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

    def form_for(record, *args, &block)
      raise ArgumentError, "Missing block" unless block_given?
      options = args.extract_options!
      if options[:validate]

Severity: Minor
Found in lib/rails4_client_side_validations/action_view/form_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

Method client_side_validation_hash has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def client_side_validation_hash(force = nil)
      _validators.inject({}) do |attr_hash, attr|
        unless [nil, :block].include?(attr[0])

          validator_hash = attr[1].inject(Hash.new { |h,k| h[k] = []}) do |kind_hash, validator|
Severity: Minor
Found in lib/rails4_client_side_validations/active_model.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 is_unique? has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def self.is_unique?(klass, attribute, value, params)
      klass = find_topmost_superclass(klass)
      value = type_cast_value(klass, attribute, value)
      column = klass.columns_hash[attribute.to_s]
      value = column.limit ? value.to_s.mb_chars[0, column.limit] : value.to_s if column.text?
Severity: Minor
Found in lib/rails4_client_side_validations/active_record/middleware.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 client_side_hash has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def client_side_hash(model, attribute, force = nil)
      options = self.options.dup
      hash    = { :messages => { :numericality => model.errors.generate_message(attribute, :not_a_number, options) } }

      if options[:only_integer]
Severity: Minor
Found in lib/rails4_client_side_validations/active_model/numericality.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 build_validation_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def build_validation_options(method, options = {})
      if @options[:validate]
        index = @default_options[:index].present? ? "[#{@default_options[:index]}]" : ''
        name = options[:name] || "#{@object_name}#{index}[#{method}]"
        child_index = @options[:child_index] ? "(\\d+|#{Regexp.escape(@options[:child_index].to_s)})" : "\\d+"
Severity: Minor
Found in lib/rails4_client_side_validations/action_view/form_builder.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 is_unique? has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.is_unique?(klass, attribute, value, params)
      klass = find_topmost_superclass(klass)
      value = type_cast_value(klass, attribute, value)
      column = klass.columns_hash[attribute.to_s]
      value = column.limit ? value.to_s.mb_chars[0, column.limit] : value.to_s if column.text?
Severity: Minor
Found in lib/rails4_client_side_validations/active_record/middleware.rb - About 1 hr to fix

    Function exports has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function(grunt) {
      grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        shell: {
          precompile: {
    Severity: Minor
    Found in Gruntfile.js - About 1 hr to fix

      Method client_side_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def client_side_hash(model, attribute, force = nil)
            options = self.options.dup
            hash    = { :messages => {} }
            hash[:js_tokenizer] = options[:js_tokenizer] if options[:js_tokenizer]
            hash[:allow_blank]  = true if options[:allow_blank]
      Severity: Minor
      Found in lib/rails4_client_side_validations/active_model/length.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 form_for has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def form_for(record, *args, &block)
            raise ArgumentError, "Missing block" unless block_given?
            options = args.extract_options!
            if options[:validate]
      
      
      Severity: Minor
      Found in lib/rails4_client_side_validations/action_view/form_helper.rb - About 1 hr to fix

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

            def self.included(base)
              (base.field_helpers.map(&:to_s) - %w(apply_form_for_options! label check_box radio_button fields_for hidden_field)).each do |selector|
                base.class_eval <<-RUBY_EVAL
                  def #{selector}_with_rails4_client_side_validations(method, options = {})
                    build_validation_options(method, options)
        Severity: Minor
        Found in lib/rails4_client_side_validations/action_view/form_builder.rb - About 1 hr to fix

          Method grouped_collection_select_with_rails4_client_side_validations has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def grouped_collection_select_with_rails4_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
          Severity: Major
          Found in lib/rails4_client_side_validations/action_view/form_builder.rb - About 1 hr to fix

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

                def client_side_hash(model, attribute, force = nil)
                  options = self.options.dup
                  if options[:with].respond_to?(:call)
                    if force
                      options[:with] = options[:with].call(model)
            Severity: Minor
            Found in lib/rails4_client_side_validations/active_model/format.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 collection_select_with_rails4_client_side_validations has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def collection_select_with_rails4_client_side_validations(method, collection, value_method, text_method, options = {}, html_options = {})
            Severity: Minor
            Found in lib/rails4_client_side_validations/action_view/form_builder.rb - About 45 mins to fix

              Method client_side_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def client_side_hash(model, attribute, force = nil)
                    hash = {}
                    hash[:message]        = model.errors.generate_message(attribute, message_type, options.except(:scope))
                    hash[:case_sensitive] = options[:case_sensitive]
                    hash[:id]             = model.id unless model.new_record?
              Severity: Minor
              Found in lib/rails4_client_side_validations/active_record/uniqueness.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 client_side_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def client_side_hash(model, attribute, force = nil)
                    if options[:in].respond_to?(:call)
                      if force
                        options = self.options.dup
                        options[:in] = options[:in].call(model)
              Severity: Minor
              Found in lib/rails4_client_side_validations/active_model/exclusion.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

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

                  def construct_validators
                    @validators.inject({}) do |validator_hash, object_opts|
                      option_hash = object_opts[1].inject({}) do |option_hash, attr|
                        option_hash.merge!(attr[0] => attr[1][:options])
                      end
              Severity: Minor
              Found in lib/rails4_client_side_validations/action_view/form_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

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

                  def client_side_hash(model, attribute, force = nil)
                    if options[:in].respond_to?(:call)
                      if force
                        options = self.options.dup
                        options[:in] = options[:in].call(model)
              Severity: Minor
              Found in lib/rails4_client_side_validations/active_model/inclusion.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