ledermann/rails-settings

View on GitHub

Showing 4 of 4 total issues

Method included has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.included(base)
      base.class_eval do
        has_many :setting_objects,
                 as: :target,
                 autosave: true,
Severity: Minor
Found in lib/rails-settings/base.rb - About 1 hr to fix

    Method initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(*args, &block)
          options = args.extract_options!
          klass = args.shift
          keys = args
    
    
    Severity: Minor
    Found in lib/rails-settings/configuration.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 settings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def settings(var)
              raise ArgumentError unless var.is_a?(Symbol)
              unless self.class.default_settings[var]
                raise ArgumentError.new("Unknown key: #{var}")
              end
    Severity: Minor
    Found in lib/rails-settings/base.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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def method_missing(method_name, *args, &block)
          if block_given?
            super
          else
            if attribute_names.include?(method_name.to_s.sub('=', ''))
    Severity: Minor
    Found in lib/rails-settings/setting_object.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