From 9d00c02ae59be58ad3fc892dad36af2313d7b32a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 00:10:27 +0000 Subject: [PATCH 1/2] Update rubocop-rspec requirement from ~> 2.26.1 to ~> 3.0.1 Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop-rspec/releases) - [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.26.1...v3.0.1) --- updated-dependencies: - dependency-name: rubocop-rspec dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- cloudflare-rails.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudflare-rails.gemspec b/cloudflare-rails.gemspec index 5b64410..9954c54 100644 --- a/cloudflare-rails.gemspec +++ b/cloudflare-rails.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rubocop', '~> 1.64.1' spec.add_development_dependency 'rubocop-performance', '~> 1.21.0' spec.add_development_dependency 'rubocop-rails', '~> 2.25.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.26.1' + spec.add_development_dependency 'rubocop-rspec', '~> 3.0.1' spec.add_development_dependency 'webmock', '~> 3.23.1' spec.add_dependency 'actionpack', '>= 7.1.0', '< 8.1.0' From 162eab674d2b1f900ac94c569b500b2daded9794 Mon Sep 17 00:00:00 2001 From: jonathan schatz Date: Wed, 12 Jun 2024 17:16:54 -0700 Subject: [PATCH 2/2] fixes --- .rubocop_todo.yml | 63 +++++++------------ lib/cloudflare_rails.rb | 2 + lib/cloudflare_rails/check_trusted_proxies.rb | 2 + lib/cloudflare_rails/importer.rb | 8 ++- lib/cloudflare_rails/railtie.rb | 2 + lib/cloudflare_rails/remote_ip_proxies.rb | 2 + lib/cloudflare_rails/version.rb | 4 +- spec/cloudflare/rails_spec.rb | 2 + spec/spec_helper.rb | 2 + 9 files changed, 43 insertions(+), 44 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index daca142..2eab29d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-12-16 21:20:23 UTC using RuboCop version 1.59.0. +# on 2024-06-13 00:13:47 UTC using RuboCop version 1.64.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -11,7 +11,7 @@ # AllowedMethods: enums Lint/ConstantDefinitionInBlock: Exclude: - - 'spec/cloudflare/rails_spec.rb' + - "spec/cloudflare/rails_spec.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -19,13 +19,13 @@ Lint/ConstantDefinitionInBlock: # AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?, presence, present? Lint/RedundantSafeNavigation: Exclude: - - 'spec/cloudflare/rails_spec.rb' + - "spec/cloudflare/rails_spec.rb" # Offense count: 1 # Configuration parameters: AllowComments, AllowNil. Lint/SuppressedException: Exclude: - - 'lib/cloudflare_rails/check_trusted_proxies.rb' + - "lib/cloudflare_rails/check_trusted_proxies.rb" # Offense count: 1 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. @@ -43,26 +43,26 @@ Metrics/MethodLength: # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Naming/FileName: Exclude: - - 'lib/cloudflare-rails.rb' + - "lib/cloudflare-rails.rb" # Offense count: 2 # Configuration parameters: ForbiddenDelimiters. # ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Exclude: - - 'lib/cloudflare_rails/fallback_ips.rb' + - "lib/cloudflare_rails/fallback_ips.rb" # Offense count: 3 RSpec/AnyInstance: Exclude: - - 'spec/cloudflare/rails_spec.rb' + - "spec/cloudflare/rails_spec.rb" # Offense count: 1 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: - - 'spec/cloudflare/rails_spec.rb' + - "spec/cloudflare/rails_spec.rb" # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -70,19 +70,12 @@ RSpec/ContextWording: # DisallowedExamples: works RSpec/ExampleWording: Exclude: - - 'spec/cloudflare/rails_spec.rb' - -# Offense count: 1 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/FilePath: - Exclude: - - 'spec/cloudflare/rails_spec.rb' + - "spec/cloudflare/rails_spec.rb" # Offense count: 1 RSpec/LeakyConstantDeclaration: Exclude: - - 'spec/cloudflare/rails_spec.rb' + - "spec/cloudflare/rails_spec.rb" # Offense count: 5 RSpec/MultipleExpectations: @@ -98,7 +91,7 @@ RSpec/MultipleMemoizedHelpers: # SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - - 'spec/cloudflare/rails_spec.rb' + - "spec/cloudflare/rails_spec.rb" # Offense count: 16 # Configuration parameters: AllowedGroups. @@ -110,19 +103,19 @@ RSpec/NestedGroups: # Include: **/*_spec.rb RSpec/SpecFilePathFormat: Exclude: - - 'spec/cloudflare/rails_spec.rb' + - "spec/cloudflare/rails_spec.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/ApplicationController: Exclude: - - 'spec/cloudflare/rails_spec.rb' + - "spec/cloudflare/rails_spec.rb" # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/CompactBlank: Exclude: - - 'lib/cloudflare_rails/importer.rb' + - "lib/cloudflare_rails/importer.rb" # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -130,14 +123,14 @@ Rails/CompactBlank: # Include: **/Rakefile, **/*.rake Rails/RakeEnvironment: Exclude: - - 'Rakefile' + - "Rakefile" # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowOnConstant, AllowOnSelfClass. Style/CaseEquality: Exclude: - - 'lib/cloudflare_rails/check_trusted_proxies.rb' + - "lib/cloudflare_rails/check_trusted_proxies.rb" # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -147,32 +140,22 @@ Style/CaseEquality: Style/FormatStringToken: EnforcedStyle: unannotated -# Offense count: 15 +# Offense count: 13 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Exclude: - - 'Appraisals' - - 'Gemfile' - - 'Rakefile' - - 'cloudflare-rails.gemspec' - - 'gemfiles/rails_6.1.gemfile' - - 'gemfiles/rails_7.0.gemfile' - - 'gemfiles/rails_7.1.gemfile' - - 'lib/cloudflare_rails.rb' - - 'lib/cloudflare_rails/check_trusted_proxies.rb' - - 'lib/cloudflare_rails/importer.rb' - - 'lib/cloudflare_rails/railtie.rb' - - 'lib/cloudflare_rails/remote_ip_proxies.rb' - - 'lib/cloudflare_rails/version.rb' - - 'spec/cloudflare/rails_spec.rb' - - 'spec/spec_helper.rb' + - "Appraisals" + - "Gemfile" + - "Rakefile" + - "cloudflare-rails.gemspec" + - "gemfiles/rails_7.1.gemfile" # Offense count: 1 Style/MultilineBlockChain: Exclude: - - 'lib/cloudflare_rails/railtie.rb' + - "lib/cloudflare_rails/railtie.rb" # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). diff --git a/lib/cloudflare_rails.rb b/lib/cloudflare_rails.rb index a785a77..09f1ef2 100644 --- a/lib/cloudflare_rails.rb +++ b/lib/cloudflare_rails.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'zeitwerk' loader = Zeitwerk::Loader.for_gem loader.ignore("#{__dir__}/cloudflare-rails.rb") diff --git a/lib/cloudflare_rails/check_trusted_proxies.rb b/lib/cloudflare_rails/check_trusted_proxies.rb index fa46390..8ed753b 100644 --- a/lib/cloudflare_rails/check_trusted_proxies.rb +++ b/lib/cloudflare_rails/check_trusted_proxies.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module CloudflareRails # patch rack::request::helpers to use our cloudflare ips - this way request.ip is # correct inside of rack and rails diff --git a/lib/cloudflare_rails/importer.rb b/lib/cloudflare_rails/importer.rb index f54c619..1e9ef46 100644 --- a/lib/cloudflare_rails/importer.rb +++ b/lib/cloudflare_rails/importer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'net/http' require 'uri' @@ -19,9 +21,9 @@ def initialize(response) end end - BASE_URL = 'https://www.cloudflare.com'.freeze - IPS_V4_URL = '/ips-v4/'.freeze - IPS_V6_URL = '/ips-v6/'.freeze + BASE_URL = 'https://www.cloudflare.com' + IPS_V4_URL = '/ips-v4/' + IPS_V6_URL = '/ips-v6/' class << self def ips_v6 diff --git a/lib/cloudflare_rails/railtie.rb b/lib/cloudflare_rails/railtie.rb index 714cf7a..3f18b17 100644 --- a/lib/cloudflare_rails/railtie.rb +++ b/lib/cloudflare_rails/railtie.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'active_support/core_ext/integer/time' module CloudflareRails diff --git a/lib/cloudflare_rails/remote_ip_proxies.rb b/lib/cloudflare_rails/remote_ip_proxies.rb index a72ee72..024434c 100644 --- a/lib/cloudflare_rails/remote_ip_proxies.rb +++ b/lib/cloudflare_rails/remote_ip_proxies.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module CloudflareRails # patch ActionDispatch::RemoteIP to use our cloudflare ips - this way # request.remote_ip is correct inside of rails diff --git a/lib/cloudflare_rails/version.rb b/lib/cloudflare_rails/version.rb index 855f967..ab02471 100644 --- a/lib/cloudflare_rails/version.rb +++ b/lib/cloudflare_rails/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module CloudflareRails - VERSION = '6.0.0'.freeze + VERSION = '6.0.0' end diff --git a/spec/cloudflare/rails_spec.rb b/spec/cloudflare/rails_spec.rb index 12f50d3..925935b 100644 --- a/spec/cloudflare/rails_spec.rb +++ b/spec/cloudflare/rails_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe CloudflareRails do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 97aa0f6..3eb85ca 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV['RAILS_ENV'] ||= 'test' require 'bundler/setup'