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 configure
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
def configure(conf)
super
require 'kubeclient'
require 'lru_redux'
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 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
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 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 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
}
Method get_metadata_for_record
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_metadata_for_record(namespace_name, pod_name, container_name, cache_key, create_time, batch_miss_cache, docker_id)