Class Logger
has 46 methods (exceeds 20 allowed). Consider refactoring. Wontfix
class Logger
include Severity
# The time that the device was last flushed.
attr_reader :last_flushed_at
File logger.rb
has 327 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Lumberjack
# Logger is a thread safe logging object. It has a compatible API with the Ruby
# standard library Logger class, the Log4r gem, and ActiveSupport::BufferedLogger.
#
# === Example
Method add_entry
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def add_entry(severity, message, progname = nil, tags = nil)
begin
severity = Severity.label_to_level(severity) unless severity.is_a?(Integer)
return true unless device && severity && severity >= level
- 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 create_flusher_thread
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Wontfix
def create_flusher_thread(flush_seconds) # :nodoc:
if flush_seconds > 0
begin
logger = self
Thread.new do
- 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 call_add_entry
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def call_add_entry(severity, message_or_progname_or_tags, progname_or_tags, &block) # :nodoc:
message = nil
progname = nil
tags = nil
if block
- 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 add_entry
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_entry(severity, message, progname = nil, tags = nil)
begin
severity = Severity.label_to_level(severity) unless severity.is_a?(Integer)
return true unless device && severity && severity >= level
Method open_device
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Wontfix
def open_device(device, options) # :nodoc:
if device.nil?
nil
elsif device.is_a?(Device)
device
- 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_thread_local_value
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Wontfix
def set_thread_local_value(name, value) # :nodoc:
values = Thread.current[name]
unless values
values = {}
Thread.current[name] = values
- 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 tag
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def tag(tags, &block)
tags = Tags.stringify_keys(tags)
thread_tags = thread_local_value(:lumberjack_logger_tags)
if block
merged_tags = (thread_tags ? thread_tags.merge(tags) : tags.dup)
- 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"