From f25024fb080d1291674df387b88d24d87b0fce05 Mon Sep 17 00:00:00 2001 From: Eric Sorenson Date: Thu, 19 Mar 2026 23:43:56 -0700 Subject: [PATCH 1/3] Fix rubocop freakouts Rubocop was unhappy with the `save_api_cache!` and `load_api_cache!` methods introduced in #5042 - some were legit problems but it had spurious errors around method length and Cyclomatic Complexity, which are not worth fixing. --- test/test_helper.rb | 86 +++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 53b2984e6f74..3de102349295 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -273,6 +273,7 @@ def add_message(type, file, line_number, message) CACHE_FILE = File.expand_path("../.api-cache.json", __dir__) CACHE_TTL_SECONDS = 24 * 60 * 60 # 24 hours +# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity def load_api_cache! return unless File.exist?(CACHE_FILE) @@ -280,46 +281,44 @@ def load_api_cache! now = Time.now.to_i ttl = CACHE_TTL_SECONDS - if data["repos"] - data["repos"].each do |key, entry| - cached_at = entry["cached_at"] - next unless cached_at - next if now - cached_at.to_i > ttl - - result = entry["value"] - # Reconstruct a minimal object that responds to .full_name - cached = if result.nil? - nil - else - next unless result["full_name"] - - Struct.new(:full_name).new(result["full_name"]) - end - NewOctokit.class_variable_get(:@@repos)[key] = cached - end + data["repos"]&.each do |key, entry| + cached_at = entry["cached_at"] + next unless cached_at + next if now - cached_at.to_i > ttl + + result = entry["value"] + # Reconstruct a minimal object that responds to .full_name + cached = if result.nil? + nil + else + next unless result["full_name"] + + Struct.new(:full_name).new(result["full_name"]) + end + NewOctokit.class_variable_get(:@@repos)[key] = cached end - if data["users"] - data["users"].each do |key, entry| - cached_at = entry["cached_at"] - next unless cached_at - next if now - cached_at.to_i > ttl - - result = entry["value"] - cached = if result.nil? - nil - else - next unless result["login"] - - Struct.new(:login).new(result["login"]) - end - NewOctokit.class_variable_get(:@@users)[key] = cached - end + data["users"]&.each do |key, entry| + cached_at = entry["cached_at"] + next unless cached_at + next if now - cached_at.to_i > ttl + + result = entry["value"] + cached = if result.nil? + nil + else + next unless result["login"] + + Struct.new(:login).new(result["login"]) + end + NewOctokit.class_variable_get(:@@users)[key] = cached end -rescue JSON::ParserError, StandardError => e - warn "Failed to load API cache: #{e.message}" +rescue StandardError => error + warn "Failed to load API cache: #{error.message}" end +# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity +# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity def save_api_cache! now = Time.now.to_i repos_data = {} @@ -331,7 +330,11 @@ def save_api_cache! repos_data[key.to_s] = { "cached_at" => now, - "value" => value.nil? ? nil : { "full_name" => value.respond_to?(:full_name) ? value.full_name : value.to_s }, + "value" => if value.nil? + nil + else + { "full_name" => value.respond_to?(:full_name) ? value.full_name : value.to_s } + end, } end @@ -341,14 +344,19 @@ def save_api_cache! users_data[key.to_s] = { "cached_at" => now, - "value" => value.nil? ? nil : { "login" => value.respond_to?(:login) ? value.login : value.to_s }, + "value" => if value.nil? + nil + else + { "login" => value.respond_to?(:login) ? value.login : value.to_s } + end, } end File.write(CACHE_FILE, JSON.pretty_generate({ "repos" => repos_data, "users" => users_data })) -rescue StandardError => e - warn "Failed to save API cache: #{e.message}" +rescue StandardError => error + warn "Failed to save API cache: #{error.message}" end +# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity # Load cached API results at startup load_api_cache! From 188bdefabe902d5cd56b9dfe4a3592f907e020fa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 19:27:11 +0000 Subject: [PATCH 2/3] Initial plan From 31742ae85440dd07cca56e78a1a374b4fc9ce593 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 19:30:13 +0000 Subject: [PATCH 3/3] fix: checkout PR branch in lint workflow instead of base branch The lint.yml workflow uses pull_request_target trigger, which causes actions/checkout to check out the base branch (main) by default. This means rubocop runs against main's code, not the PR's changes. Add ref parameter to checkout the PR's head branch, with fallback to github.ref for workflow_dispatch and merge_group triggers. Co-authored-by: ahpook <56753+ahpook@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/explore/sessions/f08905db-e076-48a4-8c19-6b4acc2c537c --- .github/workflows/lint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2f8d4e69e380..4db67290b88d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,6 +14,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6.0.1 + with: + ref: ${{ github.event.pull_request.head.ref || github.ref }} - name: Setup Ruby uses: ruby/setup-ruby@v1.284.0