Updated

app/lib / cloud_front_remote_ip.rb

A
24 lines of codes
2 methods
3.4 complexity/method
2 churn
6.85 complexity
0 duplications
class CloudFrontRemoteIp < ActionDispatch::RemoteIp
  1. CloudFrontRemoteIp assumes too much for instance variable '@app'
  2. CloudFrontRemoteIp has no descriptive comment
HTTP_X_AMZ_CF_ID = 'HTTP_X_AMZ_CF_ID'.freeze REMOTE_IP = 'action_dispatch.remote_ip'.freeze def call(env) env[REMOTE_IP] = CloudFrontGetIp.new(env, self) @app.call(env) end class CloudFrontGetIp < GetIp
  1. CloudFrontRemoteIp::CloudFrontGetIp assumes too much for instance variable '@env'
  2. CloudFrontRemoteIp::CloudFrontGetIp has no descriptive comment
protected def filter_proxies(ips) # If the request is coming from CloudFront we # can safely remove the rightmost ip address # filtering out the VPC ip address if @env.key?(HTTP_X_AMZ_CF_ID) super(ips)[1..-1] else super(ips) end end end end