Skip to content

fix: Ruby の演算子の後の空白の有無を保ち、空白だけの更新を報告しない - #134

Merged
owayo merged 1 commit into
mainfrom
fix/issue-107-ruby-operator-spacing
Nov 6, 2026
Merged

owayo merged 1 commit into
mainfrom
fix/issue-107-ruby-operator-spacing

Conversation

@owayo

@owayo owayo commented Nov 6, 2026

Copy link
Copy Markdown
Owner

概要

Gemfile で演算子の後に空白のない ~>2.2 を書くと、範囲内に新しい版があるだけで更新として報告し、~> 2.2 に書き換えていました。指定の意味は変わらず、空白だけの差分になります。次の実行からは latest になっていました。元の書き方 (空白の有無) を保ち、範囲内の版しかなければ latest と判定します。

原因

parser/ruby.rs が単一の制約の接頭辞を "~> " / "= " / ">= " などに固定していたので、書き換え後の表記 (~> 2.2) が元の表記 (~>2.2) と一致せず、何も変わらない更新の判定 (formatted == raw) が働きませんでした。

変更内容

  • 単一の制約 (~> / = / >= / > / <= / <) の接頭辞を、元の表記の演算子と、その後の空白の有無そのままにした (operator_spec)。~>2.2 は ~>2.3 に、~> 2.2 は ~> 2.3 に書き換え、範囲内の版しかなければ latest と判定する。
  • AGENTS.md に書いた。

>=1.0 などの空白のない比較演算子も、これまでは >= 1.5.0 のように空白を足して書き換えていました。同じ原因なので、あわせて元の書き方を保ちます。

検証

  • 回帰テスト (修正前のコードでは失敗することを確認済み):
    • parser::ruby::tests::test_operator_spacing_is_preserved_when_updated (~>2.2・~> 2.2・~> 2.2・>=1.0・=1.2.3 の空白を書き戻しでも保つ)
    • parser::ruby::tests::test_pessimistic_without_space_is_latest_within_its_range (~>2.2 は範囲内の版 (2.2.0〜2.2.9) しかなければ更新しない)
    • parser::ruby::tests::test_parse_pessimistic_no_space (接頭辞が ~> になる)
  • cargo fmt --all -- --check: pass
  • cargo clippy --locked --all-targets -- -D warnings: pass
  • cargo test --locked (Windows): pass

Closes #107

🤖 Generated with Claude Code

Gemfile で演算子の後に空白のない ~>2.2 を書くと、範囲内に新しい版がある
だけで更新として報告し、~> 2.2 に書き換えていた。指定の意味は変わらず、
空白だけの差分になる。次の実行からは latest になっていた。

parser/ruby.rs が単一の制約の接頭辞を "~> " / "= " / ">= " などに固定して
いたので、書き換え後の表記 (~> 2.2) が元の表記 (~>2.2) と一致せず、何も
変わらない更新の判定 (formatted == raw) が働かなかった。

- 単一の制約 (~> / = / >= / > / <= / <) の接頭辞を、元の表記の演算子と、
  その後の空白の有無そのままにした (operator_spec)。~>2.2 は ~>2.3 に、
  ~> 2.2 は ~> 2.3 に書き換え、範囲内の版しかなければ latest と判定する。
- AGENTS.md に書いた。

テスト: ~>2.2・~>  2.2・~> 2.2・>=1.0・=1.2.3 の空白を書き戻しでも保つ
こと。~>2.2 は範囲内の版 (2.2.0〜2.2.9) しかなければ更新しないこと。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@owayo owayo self-assigned this Nov 6, 2026
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 40365f2d-974e-4e33-a7fb-3ec209677a31
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@owayo
owayo merged commit 83ae3e6 into main Nov 6, 2026
8 checks passed
@owayo
owayo deleted the fix/issue-107-ruby-operator-spacing branch November 6, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ruby の空白なしの ~>2.2 を、範囲内の版しかなくても更新として報告し ~> 2.2 に書き換える

1 participant