cubesystems/releaf

View on GitHub
releaf-core/lib/releaf/settings.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Class Settings has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

class Releaf::Settings < ActiveRecord::Base

  self.table_name = table_name_prefix + "settings"

  class SettingNotFound < RuntimeError; end
Severity: Minor
Found in releaf-core/lib/releaf/settings.rb - About 3 hrs to fix

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

        def merge!(var_name, hash_value)
          raise ArgumentError unless hash_value.is_a?(Hash)
    
          old_value = self[var_name] || {}
          raise TypeError, "Existing value is not a hash, can't merge!" unless old_value.is_a?(Hash)
    Severity: Minor
    Found in releaf-core/lib/releaf/settings.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

    Variable value used in void context.
    Open

          value
    Severity: Minor
    Found in releaf-core/lib/releaf/settings.rb by rubocop

    This cop checks for operators, variables and literals used in void context.

    Example:

    # bad
    
    def some_method
      some_num * 10
      do_something
    end

    Example:

    # bad
    
    def some_method(some_var)
      some_var
      do_something
    end

    Example:

    # good
    
    def some_method
      do_something
      some_num * 10
    end

    Example:

    # good
    
    def some_method(some_var)
      do_something
      some_var
    end

    Variable value used in void context.
    Open

          value
    Severity: Minor
    Found in releaf-core/lib/releaf/settings.rb by rubocop

    This cop checks for operators, variables and literals used in void context.

    Example:

    # bad
    
    def some_method
      some_num * 10
      do_something
    end

    Example:

    # bad
    
    def some_method(some_var)
      some_var
      do_something
    end

    Example:

    # good
    
    def some_method
      do_something
      some_num * 10
    end

    Example:

    # good
    
    def some_method(some_var)
      do_something
      some_var
    end

    Method Releaf::Settings.[]= is defined at both releaf-core/lib/releaf/settings.rb:90 and releaf-core/lib/releaf/settings.rb:145.
    Open

        def []=(var_name, value)
    Severity: Minor
    Found in releaf-core/lib/releaf/settings.rb by rubocop

    This cop checks for duplicated instance (or singleton) method definitions.

    Example:

    # bad
    
    def duplicated
      1
    end
    
    def duplicated
      2
    end

    Example:

    # bad
    
    def duplicated
      1
    end
    
    alias duplicated other_duplicated

    Example:

    # good
    
    def duplicated
      1
    end
    
    def other_duplicated
      2
    end

    Method Releaf::Settings.[] is defined at both releaf-core/lib/releaf/settings.rb:81 and releaf-core/lib/releaf/settings.rb:139.
    Open

        def [](var_name)
    Severity: Minor
    Found in releaf-core/lib/releaf/settings.rb by rubocop

    This cop checks for duplicated instance (or singleton) method definitions.

    Example:

    # bad
    
    def duplicated
      1
    end
    
    def duplicated
      2
    end

    Example:

    # bad
    
    def duplicated
      1
    end
    
    alias duplicated other_duplicated

    Example:

    # good
    
    def duplicated
      1
    end
    
    def other_duplicated
      2
    end

    There are no issues that match your filters.

    Category
    Status