rs-pro/rails_admin_settings

View on GitHub
lib/rails_admin_settings.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method track_history! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def track_history!
      return false unless Settings.table_exists?

      if mongoid?
        if ::Mongoid.const_defined?('History')
Severity: Minor
Found in lib/rails_admin_settings.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 process_defaults has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def process_defaults(namespace, vals, verbose = false)
      vals.symbolize_keys!
      n = Settings.ns(namespace)
      vals.each_pair do |key, val|
        val.symbolize_keys!
Severity: Minor
Found in lib/rails_admin_settings.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 migrate! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def migrate!
      if RailsAdminSettings.mongoid?
        RailsAdminSettings::Setting.where(:ns.exists => false).update_all(ns: 'main')
        RailsAdminSettings::Setting.all.each do |s|
          s.kind = s.read_attribute(:type) if !s.read_attribute(:type).blank? && s.kind != s.read_attribute(:type)
Severity: Minor
Found in lib/rails_admin_settings.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 apply_defaults! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def apply_defaults!(file, verbose = false)
      if File.file?(file)
        puts "[settings] Loading from #{file}" if verbose
        if defined?(Psych) && Psych.respond_to?(:safe_load)
          yaml = Psych.safe_load(File.read(file))
Severity: Minor
Found in lib/rails_admin_settings.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

There are no issues that match your filters.

Category
Status