From cfa4cab338f4d32f9f0a3279c4428426b870ca5d Mon Sep 17 00:00:00 2001 From: Mridang Agarwalla Date: Tue, 22 Apr 2025 15:23:37 +0300 Subject: [PATCH 1/2] Used the warnings library to fix all the useless method-redeclaration warnings --- Gemfile | 1 + Gemfile.lock | 5 ++++- lib/patch.rb | 10 ++++++++-- lib/zitadel_client.rb | 3 +++ sig/lib/warning/warning.rbs | 3 +++ spec/spec_helper.rb | 8 +++++++- test/test_helper.rb | 9 ++++++++- 7 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 sig/lib/warning/warning.rbs diff --git a/Gemfile b/Gemfile index 7bedc3bb..d3de2b6e 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gemspec gem 'oauth2' gem 'typhoeus' +gem 'warning' gem 'zeitwerk' group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 382a1fa2..02a97316 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,7 +49,8 @@ GEM logger faraday-net_http (3.4.0) net-http (>= 0.5.0) - ffi (1.17.1) + ffi (1.17.1-arm64-darwin) + ffi (1.17.1-x86_64-linux-gnu) fileutils (1.7.3) hashie (5.0.0) i18n (1.14.7) @@ -167,6 +168,7 @@ GEM unicode-display_width (2.6.0) uri (1.0.3) version_gem (1.1.7) + warning (1.5.0) zeitwerk (2.6.18) PLATFORMS @@ -190,6 +192,7 @@ DEPENDENCIES steep testcontainers typhoeus + warning zeitwerk zitadel-client! diff --git a/lib/patch.rb b/lib/patch.rb index da72025f..e1b40cc3 100644 --- a/lib/patch.rb +++ b/lib/patch.rb @@ -2,10 +2,11 @@ module OAuth2 module Strategy - # noinspection RbsMissingTypeSignature - class Assertion < Base + # rubocop:disable Style/Documentation + module AssertionPatch private + # noinspection RbsMissingTypeSignature def build_assertion(claims, opts) raise ArgumentError, 'encoding_opts must include :algorithm and :key' unless opts.is_a?(Hash) && opts.key?(:algorithm) && opts.key?(:key) @@ -14,5 +15,10 @@ def build_assertion(claims, opts) JWT.encode(claims, opts[:key], opts[:algorithm], headers) end end + # rubocop:enable Style/Documentation + + class Assertion < Base + prepend AssertionPatch + end end end diff --git a/lib/zitadel_client.rb b/lib/zitadel_client.rb index 531bf9a0..85793f35 100644 --- a/lib/zitadel_client.rb +++ b/lib/zitadel_client.rb @@ -2,8 +2,11 @@ require 'zeitwerk' require 'oauth2' +require 'warning' require_relative 'patch' +Warning.ignore(:method_redefined, __dir__) + # Main entrypoint for the ZitadelClient Ruby SDK. # # This module encapsulates all functionality for authenticating with and accessing diff --git a/sig/lib/warning/warning.rbs b/sig/lib/warning/warning.rbs new file mode 100644 index 00000000..2ee46119 --- /dev/null +++ b/sig/lib/warning/warning.rbs @@ -0,0 +1,3 @@ +module Warning + def self.ignore: (Regexp | Symbol | Array[Symbol], String?) -> void +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6f1d2d9b..9995b7b4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,11 +17,17 @@ # Override the HTMLFormatter so that it writes its report inside build/coverage/html module SimpleCov module Formatter - class HTMLFormatter + # rubocop:disable Style/Documentation + module HTMLFormatterPatch def output_path File.join(SimpleCov.coverage_path, 'html') end end + # rubocop:enable Style/Documentation + + class HTMLFormatter + prepend HTMLFormatterPatch + end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 6f1d2d9b..49ea3d1b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'warning' require 'dotenv' require 'simplecov' require 'simplecov-lcov' @@ -17,11 +18,17 @@ # Override the HTMLFormatter so that it writes its report inside build/coverage/html module SimpleCov module Formatter - class HTMLFormatter + # rubocop:disable Style/Documentation + module HTMLFormatterPatch def output_path File.join(SimpleCov.coverage_path, 'html') end end + # rubocop:enable Style/Documentation + + class HTMLFormatter + prepend HTMLFormatterPatch + end end end From fb62339e2242aa41c3efe479bd8d5e0e0ed6b6cb Mon Sep 17 00:00:00 2001 From: Mridang Agarwalla Date: Tue, 22 Apr 2025 15:27:37 +0300 Subject: [PATCH 2/2] Updated the lockfile to ensure that FFI is installable on GHA --- Gemfile.lock | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 02a97316..d7f6fde9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,8 +49,7 @@ GEM logger faraday-net_http (3.4.0) net-http (>= 0.5.0) - ffi (1.17.1-arm64-darwin) - ffi (1.17.1-x86_64-linux-gnu) + ffi (1.17.1) fileutils (1.7.3) hashie (5.0.0) i18n (1.14.7)