File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed
Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,6 @@ Metrics/PerceivedComplexity:
2121 Max : 10
2222Metrics/AbcSize :
2323 Max : 29
24+ Style/MethodMissing :
25+ Exclude :
26+ - ' libraries/process_env_var.rb'
Original file line number Diff line number Diff line change 210210 throw :stop
211211 end
212212
213- if ( data_dir = file ( "/proc/#{ etcd_process . pids . first } /environ" ) . content . split ( "\0 " ) . select { |i | i [ /^ETCD_DATA_DIR/ ] } . first . split ( '=' ) . last )
213+ if ( data_dir = file ( "/proc/#{ etcd_process . pids . first } /environ" ) . content . split ( "\0 " ) . select { |i | i [ /^ETCD_DATA_DIR/ ] } . first . to_s . split ( '=' , 2 ) . last . to_s )
214214 throw :stop
215215 end
216216 end
245245 throw :stop
246246 end
247247
248- if ( data_dir = file ( "/proc/#{ etcd_process . pids . first } /environ" ) . content . split ( "\0 " ) . select { |i | i [ /^ETCD_DATA_DIR/ ] } . first . split ( '=' ) . last )
248+ if ( data_dir = file ( "/proc/#{ etcd_process . pids . first } /environ" ) . content . split ( "\0 " ) . select { |i | i [ /^ETCD_DATA_DIR/ ] } . first . to_s . split ( '=' , 2 ) . last . to_s )
249249 throw :stop
250250 end
251251 end
Original file line number Diff line number Diff line change @@ -29,25 +29,25 @@ def initialize(process)
2929 end
3030
3131 def method_missing ( name )
32- read_params [ name . to_s ]
32+ read_params [ name . to_s ] || ''
3333 end
3434
3535 def read_params
3636 return @params if defined? ( @params )
3737
38- proc_environ = inspec . file ( "/proc/#{ @process . pids . first } /environ" )
39- unless file . file?
38+ @file = inspec . file ( "/proc/#{ @process . pids . first } /environ" )
39+ unless @ file. file?
4040 skip_resource "Can't find environ file for #{ @process } "
4141 return @params = { }
4242 end
4343
44- environ_content = proc_environ . content
45- if content . empty? && !file . empty?
44+ @content = @file . content
45+ if @ content. empty? && !@ file. empty?
4646 skip_resource "Can't read environ file for #{ @process } "
4747 return @params = { }
4848 end
4949
50- @params = environ_content . split ( "\0 " ) . map { |i | i . split ( '=' ) } . to_h
50+ @params = @content . split ( "\0 " ) . map { |i | i . split ( '=' , 2 ) } . to_h
5151 end
5252
5353 def to_s
You can’t perform that action at this time.
0 commit comments