app/models/setting.rb
Class Setting
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Setting < ApplicationRecord
audited :except => [:name]
extend FriendlyId
friendly_id :name
include ActiveModel::Validations
Method parse_string_value
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Open
def parse_string_value(val)
case settings_type
when "boolean"
boolean = Foreman::Cast.to_bool(val)
- Read upRead up
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 parse_string_value
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def parse_string_value(val)
case settings_type
when "boolean"
boolean = Foreman::Cast.to_bool(val)
Method value=
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def value=(v)
v = v.to_yaml unless v.nil?
# the has_attribute is for enabling DB migrations on older versions
if setting_definition&.encrypted?
# Don't re-write the attribute if the current encrypted value is identical to the new one
- Read upRead up
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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def self.set(name, description, default, full_name = nil, value = nil, options = {})