Showing 6 of 6 total issues
File enumerated.rb
has 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
module PowerEnum::Enumerated
extend ActiveSupport::Concern
# Class level methods injected into ActiveRecord.
module ClassMethods
Method has_enumerated
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def has_enumerated(part_id, options = {})
options.assert_valid_keys( :class_name,
:foreign_key,
:on_lookup_failure,
:permit_empty_name,
Method create_enum
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_enum(enum_name, options = {}, &block)
enum_table_name = enum_name.pluralize
name_column = options[:name_column] || :name
generate_description = !!options[:description]
generate_active = !!options[:active]
- 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 validate_enum
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_enum(enum_class, item)
case item
when String, Symbol, Fixnum
enum_class[item].present?
when Hash
- 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 define_enum_writer
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def define_enum_writer(attribute_name, class_name, foreign_key, failure_handler, allow_empty_name) #:nodoc:
Method define
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def define(*args, &block)
options = args.extract_options!
args.compact!
args.flatten!
args.each do |class_name|
- 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"