rs-pro/rails_admin_settings

View on GitHub
lib/rails_admin_settings/namespaced.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    def write_to_database(key, options)
      is_file = !options[:kind].nil? && (options[:kind] == 'image' || options[:kind] == 'file')
      if is_file
        options[:raw] = ''
        file = options[:value]
Severity: Minor
Found in lib/rails_admin_settings/namespaced.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 method_missing has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def method_missing(key, *args)
      key = key.to_s
      if key.end_with?('_enabled?')
        key = key[0..-10]
        v = get(key)
Severity: Minor
Found in lib/rails_admin_settings/namespaced.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 write_to_database has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def write_to_database(key, options)
      is_file = !options[:kind].nil? && (options[:kind] == 'image' || options[:kind] == 'file')
      if is_file
        options[:raw] = ''
        file = options[:value]
Severity: Minor
Found in lib/rails_admin_settings/namespaced.rb - About 1 hr to fix

    Method method_missing has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def method_missing(key, *args)
          key = key.to_s
          if key.end_with?('_enabled?')
            key = key[0..-10]
            v = get(key)
    Severity: Minor
    Found in lib/rails_admin_settings/namespaced.rb - About 1 hr to fix

      Method get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def get(key, options = {})
            load!
            key = key.to_s
            mutex.synchronize do
              @locked = true
      Severity: Minor
      Found in lib/rails_admin_settings/namespaced.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 set has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def set(key, value = nil, options = {})
            load! unless @locked
            key = key.to_s
            options.symbolize_keys!
      
      
      Severity: Minor
      Found in lib/rails_admin_settings/namespaced.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

      There are no issues that match your filters.

      Category
      Status