Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #75 twist 関数で文字列の前方一致していたところを、キーの前方一致判定に変更 #76

Merged
merged 2 commits into from
Dec 4, 2023

Conversation

mew-ton
Copy link
Contributor

@mew-ton mew-ton commented Dec 1, 2023

Summary by CodeRabbit

  • 新機能

    • アプリに検索機能を追加しました。
  • バグ修正

  • 機能改善

    • データのキーに共通のプレフィックスがある場合に正しくデータを操作するための新しいテストケースを追加しました。
    • キーのプレフィックスマッチングのロジックを改善しました。

Copy link

changeset-bot bot commented Dec 1, 2023

🦋 Changeset detected

Latest commit: c2067b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
json-origami Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Dec 1, 2023

Walkthrough

変更の概要は、プロジェクト全体の設定とコントロールフローに関するものです。VS Codeのワークスペース設定にTypeScriptのパスが追加され、twist関数のロジックが改善されました。また、新しいユーティリティ関数includesKeyが導入され、より効率的なキー検索が可能になりました。テストケースも更新され、新しいロジックが正しく機能することが確認されています。

Changes

ファイル 変更概要
.vscode/project.code-workspace
src/twist.ts
"folders"キーにネスティングレベルを追加し、"settings"キーに"typescript.tsdk"プロパティを追加。
includesKey関数をインポートし、twist関数内のロジックを変更
test/.../twist.spec.ts 共通プレフィックスを持つキーマップデータの正しい扱いを確認する新しいテストケースを追加

🐰✨
コードの森を跳ねる小さな兎よ
新しい葉を見つけたんだね
型の木々、輝くTSの道
今日もまた、バグを追い越せ


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

],
"settings": {
"typescript.tsdk": "node_modules/typescript/lib"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ついで

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fcac62f and 1bcd338.
Files selected for processing (3)
  • .vscode/project.code-workspace (1 hunks)
  • src/twist.ts (2 hunks)
  • test/twist.spec.ts (1 hunks)
Additional comments: 3
.vscode/project.code-workspace (1)
  • 1-9: 設定ファイルの変更点は問題ないように見えますが、プロジェクトの他の部分に影響を与えないか確認してください。特に、TypeScriptの設定変更はプロジェクトのビルドや実行に影響を与える可能性があります。
src/twist.ts (1)
  • 3-4: 新しいユーティリティ関数includesKeyのインポート文が正しく追加されました。
test/twist.spec.ts (1)
  • 251-285: 新しいテストケースが追加され、マップデータのキーが共通のプレフィックスを持つ場合にデータが正しく変換されることを確認しています。この変更は、要約に記載されている内容と一致しています。

Comment on lines 18 to 23
const twisted = Object.fromEntries(
Object.entries(folded).map(([key, value]) => {
const found = Object.keys(moveMap).find((k) => key.startsWith(k))
const found = Object.keys(moveMap).find((k) => includesKey(key, k, option))

if (found) {
const newKey = key.replace(found, moveMap[found]!)
Copy link

@coderabbitai coderabbitai bot Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

includesKey関数の使用方法が間違っています。Object.keys(moveMap).findを使う代わりに、直接includesKeyを使ってマッチするキーを見つけるべきです。

- const found = Object.keys(moveMap).find((k) => includesKey(key, k, option))
+ const found = includesKey(key, Object.keys(moveMap), option)

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const twisted = Object.fromEntries(
Object.entries(folded).map(([key, value]) => {
const found = Object.keys(moveMap).find((k) => key.startsWith(k))
const found = Object.keys(moveMap).find((k) => includesKey(key, k, option))
if (found) {
const newKey = key.replace(found, moveMap[found]!)
const twisted = Object.fromEntries(
Object.entries(folded).map(([key, value]) => {
const found = includesKey(key, Object.keys(moveMap), option)
if (found) {
const newKey = key.replace(found, moveMap[found]!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

間違ってないです。

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mew-ton 承知しました。現在の実装を維持することにします。もし他に何か手伝えることがあれば、お知らせください。

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1bcd338 and c2067b7.
Files selected for processing (1)
  • .changeset/khaki-sheep-roll.md (1 hunks)
Additional comments: 1
.changeset/khaki-sheep-roll.md (1)
  • 1-5: 変更セットの記述が適切であり、twist 関数のキーの前方一致判定への変更を正確に反映しています。

Copy link

@skadota skadota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mew-ton mew-ton merged commit aff83a1 into main Dec 4, 2023
1 check passed
@mew-ton mew-ton deleted the fix/75_twist_including_number_key branch December 4, 2023 06:51
@github-actions github-actions bot mentioned this pull request Dec 4, 2023
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.

2 participants