diff --git a/.rubocop.yml b/.rubocop.yml index c21c088e8c..fa7d04f8c6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,6 +51,9 @@ Layout/SpaceInsideArrayLiteralBrackets: Layout/SpaceInsidePercentLiteralDelimiters: Enabled: false +Metrics/ClassLength: + Max: 200 + Metrics/ModuleLength: Enabled: false diff --git a/lib/mongo/server/app_metadata/environment.rb b/lib/mongo/server/app_metadata/environment.rb index a558b4e9fa..029257faec 100644 --- a/lib/mongo/server/app_metadata/environment.rb +++ b/lib/mongo/server/app_metadata/environment.rb @@ -44,7 +44,7 @@ class ValueTooLong < Mongo::Error; end # The name and location of the .dockerenv file that will signal the # presence of Docker. - DOCKERENV_PATH = '/.dockerenv'.freeze + DOCKERENV_PATH = '/.dockerenv' # This value is not explicitly specified in the spec, only implied to be # less than 512. @@ -223,11 +223,11 @@ def detect_container runtime = docker_present? && 'docker' orchestrator = kubernetes_present? && 'kubernetes' - if runtime || orchestrator - fields[:container] = {} - fields[:container][:runtime] = runtime if runtime - fields[:container][:orchestrator] = orchestrator if orchestrator - end + return unless runtime || orchestrator + + fields[:container] = {} + fields[:container][:runtime] = runtime if runtime + fields[:container][:orchestrator] = orchestrator if orchestrator end # Checks for the existence of a .dockerenv in the root directory. @@ -244,7 +244,7 @@ def dockerenv_path # Checks for the presence of a non-empty KUBERNETES_SERVICE_HOST # environment variable. def kubernetes_present? - ENV['KUBERNETES_SERVICE_HOST'].to_s.length > 0 + !ENV['KUBERNETES_SERVICE_HOST'].to_s.empty? end # Determines whether the named environment variable exists, and (if diff --git a/spec/mongo/server/app_metadata/environment_spec.rb b/spec/mongo/server/app_metadata/environment_spec.rb index a6319d247f..0b0b844b59 100644 --- a/spec/mongo/server/app_metadata/environment_spec.rb +++ b/spec/mongo/server/app_metadata/environment_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true +# rubocop:todo all require 'spec_helper' require 'fileutils'