beatrichartz/babylonia-rails

View on GitHub

Showing 5 of 5 total issues

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

        def validate record
          (is_active_record_4? ? attributes : attributes.first).each do |locale, attribute|
            value = record.read_attribute_for_validation :"#{attribute}_#{locale}"
            next if (value.nil? && options[:allow_nil]) || (value.blank? && options[:allow_blank])
            validate_each record, attribute, locale, value
Severity: Minor
Found in lib/babylonia/rails/validators/uniqueness_validator.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 build_relation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def build_relation klass, table, attribute, locale, value #:nodoc:
          column = klass.columns_hash[attribute.to_s]
          value  = build_yaml_dump_value klass, value, column, locale
          
          if !options[:case_sensitive] && value && column.text?
Severity: Minor
Found in lib/babylonia/rails/validators/uniqueness_validator.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 build_relation has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def build_relation klass, table, attribute, locale, value #:nodoc:
Severity: Minor
Found in lib/babylonia/rails/validators/uniqueness_validator.rb - About 35 mins to fix

    Method add_uniqueness_validation_error has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def add_uniqueness_validation_error record, options, attribute, locale, value #:nodoc:
    Severity: Minor
    Found in lib/babylonia/rails/validators/uniqueness_validator.rb - About 35 mins to fix

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

              def validate_each(record, attribute, value)
                @validators = {}
                record.available_locales.each do |locale|
                  validations = active_record_validations_array
                  validations.each do |validation|
      Severity: Minor
      Found in lib/babylonia/rails/validators/locale_validator.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