Showing 8 of 8 total issues
Method has_flags
has 189 lines of code (exceeds 25 allowed). Consider refactoring. Open
def has_flags(*args)
flag_hash, opts = parse_flag_options(*args)
opts =
{
named_scopes: true,
File flag_shih_tzu.rb
has 470 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "flag_shih_tzu/validators"
module FlagShihTzu
# taken from ActiveRecord::ConnectionAdapters::Column
TRUE_VALUES = [true, 1, "1", "t", "T", "true", "TRUE"]
Method has_flags
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def has_flags(*args)
flag_hash, opts = parse_flag_options(*args)
opts =
{
named_scopes: true,
- 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 check_flag_column
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def check_flag_column(colmn, custom_table_name = table_name)
# If you aren't using ActiveRecord (eg. you are outside rails)
# then do not fail here
# If you are using ActiveRecord then you only want to check for the
# table if the table exists so it won't fail pre-migration
- 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 check_flag_column
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_flag_column(colmn, custom_table_name = table_name)
# If you aren't using ActiveRecord (eg. you are outside rails)
# then do not fail here
# If you are using ActiveRecord then you only want to check for the
# table if the table exists so it won't fail pre-migration
Method sql_condition_for_flag
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def sql_condition_for_flag(flag, colmn, enabled = true, custom_table_name = table_name)
check_flag(flag, colmn)
if flag_options[colmn][:flag_query_mode] == :bit_operator
# use & bit operator directly in the SQL query.
- 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 update_flag!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_flag!(flag, value, update_instance = false)
truthy = FlagShihTzu::TRUE_VALUES.include?(value)
sql = self.class.set_flag_sql(flag.to_sym, truthy)
if update_instance
if truthy
- 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 included
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.included(base)
base.extend(ClassMethods)
base.class_attribute :flag_options unless defined?(base.flag_options)
base.class_attribute :flag_mapping unless defined?(base.flag_mapping)
base.class_attribute :flag_columns unless defined?(base.flag_columns)
- 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"