From cc3e5ad436d9a7ec719bbc846878e300908d7491 Mon Sep 17 00:00:00 2001 From: Brandon Trautmann <8343465+btrautmann@users.noreply.github.com> Date: Fri, 6 Feb 2026 16:47:50 -0500 Subject: [PATCH 1/3] fix: use find instead of first when locating YAML keys with line numbers --- lib/claws/workflow.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/claws/workflow.rb b/lib/claws/workflow.rb index dba31d8..fec89c7 100644 --- a/lib/claws/workflow.rb +++ b/lib/claws/workflow.rb @@ -123,7 +123,7 @@ def normalize_permissions(input) # rubocop:disable Metrics/AbcSize, Metrics/Cycl def extract_normalized_on(workflow) if workflow["on"].is_a? String - line_number = workflow.keys.first { |k| k == "on" }.line + line_number = workflow.keys.find { |k| k == "on" }.line @on = workflow["on"] = [workflow["on"]] set_attr_line_number(:@on, line_number) else @@ -211,7 +211,7 @@ def set_attr_line_number(key, line) end def copy_key_with_line(blob, src, dst) - line = blob.keys.first { |k| k.to_sym == src.to_sym }.line + line = blob.keys.find { |k| k.to_sym == src.to_sym }.line new_key = String.new(dst).tap { |x| x.instance_eval { |_x| define_singleton_method(:line, -> { line }) } } # freezing it keeps ruby from making a copy w/o `line` From 55ea63b325ea94b8877078537702e3a6f774e105 Mon Sep 17 00:00:00 2001 From: Brandon Trautmann <8343465+btrautmann@users.noreply.github.com> Date: Fri, 6 Feb 2026 17:07:50 -0500 Subject: [PATCH 2/3] add back spec after rebase --- spec/claws/workflow_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/claws/workflow_spec.rb b/spec/claws/workflow_spec.rb index 3f79ea7..1ea3e17 100644 --- a/spec/claws/workflow_spec.rb +++ b/spec/claws/workflow_spec.rb @@ -48,6 +48,30 @@ expect(workflow.meta["triggers"]).to eq(["pull_request"]) end + + context "key normalization" do + it "preserves line numbers when normalizing hyphenated keys that are not the first key" do + workflow = described_class.load(<<~YAML) + name: test + + on: push + + jobs: + build: + defaults: + run: + working-directory: ./app + runs-on: ubuntu-latest + steps: + - run: echo hello + YAML + + job = workflow.jobs["build"] + runs_on_key = job.keys.find { |k| k == "runs_on" } + + expect(runs_on_key.line).to eq(10) + end + end end context "line information" do From 9ceb5ecf2dea2ae37cdba874a8691945901d6c27 Mon Sep 17 00:00:00 2001 From: Brandon Trautmann <8343465+btrautmann@users.noreply.github.com> Date: Fri, 6 Feb 2026 17:08:35 -0500 Subject: [PATCH 3/3] move spec --- spec/claws/workflow_spec.rb | 48 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/spec/claws/workflow_spec.rb b/spec/claws/workflow_spec.rb index 1ea3e17..2d3081e 100644 --- a/spec/claws/workflow_spec.rb +++ b/spec/claws/workflow_spec.rb @@ -48,30 +48,6 @@ expect(workflow.meta["triggers"]).to eq(["pull_request"]) end - - context "key normalization" do - it "preserves line numbers when normalizing hyphenated keys that are not the first key" do - workflow = described_class.load(<<~YAML) - name: test - - on: push - - jobs: - build: - defaults: - run: - working-directory: ./app - runs-on: ubuntu-latest - steps: - - run: echo hello - YAML - - job = workflow.jobs["build"] - runs_on_key = job.keys.find { |k| k == "runs_on" } - - expect(runs_on_key.line).to eq(10) - end - end end context "line information" do @@ -101,6 +77,30 @@ expect(BaseRule.parse_rule("$step.with.type_nil == nil").eval_with(values:)).to eq true expect(BaseRule.parse_rule("$step.with.type_float == 1.2").eval_with(values:)).to eq true end + + context "key normalization" do + it "preserves line numbers when normalizing hyphenated keys that are not the first key" do + workflow = described_class.load(<<~YAML) + name: test + + on: push + + jobs: + build: + defaults: + run: + working-directory: ./app + runs-on: ubuntu-latest + steps: + - run: echo hello + YAML + + job = workflow.jobs["build"] + runs_on_key = job.keys.find { |k| k == "runs_on" } + + expect(runs_on_key.line).to eq(10) + end + end end context "built in function - get_key" do