rs-pro/rails_admin_settings

View on GitHub

Showing 25 of 25 total issues

Method included has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    def self.included(base)
      if base.respond_to?(:rails_admin)
        base.rails_admin do
          navigation_label I18n.t('admin.settings.label')
          list do
Severity: Minor
Found in lib/rails_admin_settings/rails_admin_config.rb - About 6 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 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 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 included has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.included(base)
      if base.respond_to?(:rails_admin)
        base.rails_admin do
          navigation_label I18n.t('admin.settings.label')
          list do
Severity: Major
Found in lib/rails_admin_settings/rails_admin_config.rb - About 2 hrs to fix

    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 extract_with_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

            def extract_with_file(io, options)
              require "open3"
    
              return nil if io.eof? # file command returns "application/x-empty" for empty files
    
    
    Severity: Minor
    Found in lib/rails_admin_settings/determine_mime_type.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 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 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 included has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.included(base)
              # carrierwave
              if base.respond_to?(:mount_uploader)
                # puts "[rails_admin_settings] CarrierWave detected"
                # base.field(:file, type: String)
        Severity: Minor
        Found in lib/rails_admin_settings/uploads.rb - About 1 hr to fix

          Method included has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.included(base)
                # carrierwave
                if base.respond_to?(:mount_uploader)
                  # puts "[rails_admin_settings] CarrierWave detected"
                  # base.field(:file, type: String)
          Severity: Minor
          Found in lib/rails_admin_settings/uploads.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 value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def value
                if upload_kind?
                  unless defined?(Shrine)
                    if file?
                      file.url
          Severity: Minor
          Found in lib/rails_admin_settings/processing.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 processed_value has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def processed_value
                if text_kind?
                  process_text
                elsif integer_kind?
                  raw.to_i
          Severity: Minor
          Found in lib/rails_admin_settings/processing.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 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 default_value has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def default_value
                if html_kind?
                  ''.html_safe
                elsif text_kind?
                  ''
          Severity: Minor
          Found in lib/rails_admin_settings/processing.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 kinds has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.kinds
              [
                'string',
                'text',
                'integer',
          Severity: Minor
          Found in lib/rails_admin_settings/kinds.rb - About 1 hr to fix

            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 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 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

            Severity
            Category
            Status
            Source
            Language