rs-pro/rails_admin_settings

View on GitHub
lib/rails_admin_settings/validation.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method add_phone_validator has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def add_phone_validator(base)
        base.validate if: :phone_kind? do
          require_russian_phone do
            errors.add(:raw, I18n.t('admin.settings.phone_invalid')) unless raw.blank? || RussianPhone::Number.new(raw).valid?
          end
Severity: Minor
Found in lib/rails_admin_settings/validation.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 add_url_validator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def add_url_validator(base)
        base.before_validation if: :url_kind? do
          require_addressable do
            self.raw = Addressable::URI.heuristic_parse(self.raw) unless self.raw.blank?
          end
Severity: Minor
Found in lib/rails_admin_settings/validation.rb - About 45 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 add_yaml_validator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def add_yaml_validator(base)
        base.validate if: :yaml_kind? do
          require_safe_yaml do
            unless raw.blank?
              begin
Severity: Minor
Found in lib/rails_admin_settings/validation.rb - About 45 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 add_json_validator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def add_json_validator(base)
        base.validate if: :json_kind? do
          unless raw.blank?
            begin
              JSON.load(raw)
Severity: Minor
Found in lib/rails_admin_settings/validation.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

There are no issues that match your filters.

Category
Status