molawson/forminate

View on GitHub

Showing 3 of 3 total issues

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

    def _can_use_for_client_side_validation?(model, attr, validator, force)
      if validator_turned_off?(attr, validator, force)
        result = false
      else
        result = ((model.respond_to?(:new_record?) && validator.options[:on] == (model.new_record? ? :create : :update)) || validator.options[:on].nil?)
Severity: Minor
Found in lib/forminate/client_side_validations.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_validation_hash has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def client_side_validation_hash(force = nil)
      hash = super
      assoc_hash = association_validators.reduce({}) do |assoc_hash, (attr, validators)|
        unless [nil, :block].include?(attr)

Severity: Minor
Found in lib/forminate/client_side_validations.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 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def client_side_validation_hash(force = nil)
      hash = super
      assoc_hash = association_validators.reduce({}) do |assoc_hash, (attr, validators)|
        unless [nil, :block].include?(attr)

Severity: Minor
Found in lib/forminate/client_side_validations.rb - About 1 hr to fix
    Severity
    Category
    Status
    Source
    Language