Showing 24 of 24 total issues
Method configure
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
def configure(conf)
super
require 'kubeclient'
require 'lru_redux'
- 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 get_pod_metadata
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def get_pod_metadata(key, namespace_name, pod_name, time, batch_miss_cache)
metadata = {}
ids = @id_cache[key]
if ids.nil?
@stats.bump(:id_cache_miss)
- 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 configure
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
def configure(conf)
super
require 'kubeclient'
require 'lru_redux'
Method parse_pod_metadata
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def parse_pod_metadata(pod_object)
labels = ''
labels = syms_to_strs(pod_object[:metadata][:labels].to_h) unless (@skip_labels || @skip_pod_labels)
annotations = match_annotations(syms_to_strs(pod_object[:metadata][:annotations].to_h))
- 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
File filter_kubernetes_metadata.rb
has 293 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_relative 'kubernetes_metadata_cache_strategy'
require_relative 'kubernetes_metadata_common'
require_relative 'kubernetes_metadata_stats'
require_relative 'kubernetes_metadata_util'
require_relative 'kubernetes_metadata_watch_namespaces'
Method process_pod_watcher_notices
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def process_pod_watcher_notices(watcher)
watcher.each do |notice|
# store version we processed to not reprocess it ... do not unset when there is no version in response
version = ( # TODO: replace with &.dig once we are on ruby 2.5+
notice[:object] && notice[:object][:metadata] && notice[:object][:metadata][:resourceVersion]
- 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 get_pod_metadata
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_pod_metadata(key, namespace_name, pod_name, time, batch_miss_cache)
metadata = {}
ids = @id_cache[key]
if ids.nil?
@stats.bump(:id_cache_miss)
Method get_metadata_for_record
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def get_metadata_for_record(namespace_name, pod_name, container_name, cache_key, create_time, batch_miss_cache, docker_id)
metadata = {
'docker' => { 'container_id' => "" },
'kubernetes' => {
'container_name' => container_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"
Further reading
Method set_up_namespace_thread
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_up_namespace_thread
# Any failures / exceptions in the initial setup should raise
# Fluent:ConfigError, so that users can inspect potential errors in
# the configuration.
namespace_watcher = start_namespace_watch
Method set_up_pod_thread
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_up_pod_thread
# Any failures / exceptions in the initial setup should raise
# Fluent:ConfigError, so that users can inspect potential errors in
# the configuration.
pod_watcher = start_pod_watch
Method process_namespace_watcher_notices
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def process_namespace_watcher_notices(watcher)
watcher.each do |notice|
case notice[:type]
when 'MODIFIED'
reset_namespace_watch_retry_stats
- 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_up_pod_thread
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def set_up_pod_thread
# Any failures / exceptions in the initial setup should raise
# Fluent:ConfigError, so that users can inspect potential errors in
# the configuration.
pod_watcher = start_pod_watch
- 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_up_namespace_thread
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def set_up_namespace_thread
# Any failures / exceptions in the initial setup should raise
# Fluent:ConfigError, so that users can inspect potential errors in
# the configuration.
namespace_watcher = start_namespace_watch
- 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
Consider simplifying this complex logical expression. Open
if @lookup_from_k8s_field && record.key?('kubernetes') && record.key?('docker') &&
record['kubernetes'].respond_to?(:has_key?) && record['docker'].respond_to?(:has_key?) &&
record['kubernetes'].key?('namespace_name') &&
record['kubernetes'].key?('pod_name') &&
record['kubernetes'].key?('container_name') &&
Method parse_pod_metadata
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_pod_metadata(pod_object)
labels = ''
labels = syms_to_strs(pod_object[:metadata][:labels].to_h) unless (@skip_labels || @skip_pod_labels)
annotations = match_annotations(syms_to_strs(pod_object[:metadata][:annotations].to_h))
Method process_pod_watcher_notices
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_pod_watcher_notices(watcher)
watcher.each do |notice|
# store version we processed to not reprocess it ... do not unset when there is no version in response
version = ( # TODO: replace with &.dig once we are on ruby 2.5+
notice[:object] && notice[:object][:metadata] && notice[:object][:metadata][:resourceVersion]
Method filter
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def filter(tag, time, record)
tag_match_data = tag.match(@tag_to_kubernetes_name_regexp_compiled)
batch_miss_cache = {}
if tag_match_data
cache_key = if tag_match_data.names.include?('pod_uuid') && !tag_match_data['pod_uuid'].nil?
- 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 process_namespace_watcher_notices
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_namespace_watcher_notices(watcher)
watcher.each do |notice|
case notice[:type]
when 'MODIFIED'
reset_namespace_watch_retry_stats
Method get_metadata_for_record
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_metadata_for_record(namespace_name, pod_name, container_name, cache_key, create_time, batch_miss_cache, docker_id)
metadata = {
'docker' => { 'container_id' => "" },
'kubernetes' => {
'container_name' => container_name,
Method fetch_pod_metadata
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch_pod_metadata(namespace_name, pod_name)
log.trace("fetching pod metadata: #{namespace_name}/#{pod_name}")
options = {
resource_version: '0' # Fetch from API server cache instead of etcd quorum read
}