kalkov/rails4_client_side_validations

View on GitHub
lib/rails4_client_side_validations/action_view/form_builder.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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 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 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

        There are no issues that match your filters.

        Category
        Status