Skip to content

chore: shellcheck 除外リストを外部ファイルに分離 - #507

Merged
keito4 merged 1 commit into
mainfrom
chore/shellcheck-exclude-file
Feb 23, 2026
Merged

chore: shellcheck 除外リストを外部ファイルに分離#507
keito4 merged 1 commit into
mainfrom
chore/shellcheck-exclude-file

Conversation

@keito4

@keito4 keito4 commented Feb 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • package.jsonshellcheck スクリプトにハードコードされていた 10 個の grep -v 除外パターンを script/.shellcheck-exclude ファイルに外部化
  • スクリプト値を grep -vFf script/.shellcheck-exclude に置き換え、保守性とレビュー性を改善
  • 動作は変更前と同一(除外対象ファイルの追加・削除が外部ファイルの編集だけで完結するようになった)

Changes

ファイル 変更内容
script/.shellcheck-exclude 新規: 除外パターン 10 行
package.json shellcheck スクリプトを grep -vFf 方式に変更

Test plan

  • npm run shellcheck が変更前と同じ結果になることを確認
  • 全ユニットテスト(101件)がパス
  • Format / Lint / ShellCheck の Quality Gates がパス

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Refactored development tooling configuration to improve maintainability and streamline script exclusion management.

package.json の shellcheck スクリプトでハードコードしていた 10個の
grep -v 除外パターンを script/.shellcheck-exclude に外部化。
保守性とレビュー性を改善。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Feb 23, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The shellcheck script configuration is being refactored to externalize exclusion patterns. Rather than maintaining a long inline regex within the npm script, exclusions are now read from a dedicated script/.shellcheck-exclude file containing specific shell scripts and directories to ignore during analysis.

Changes

Cohort / File(s) Summary
ShellCheck Configuration
package.json, script/.shellcheck-exclude
Refactored exclusion mechanism: moved from hardcoded inline regex patterns to external file-based filtering. The shellcheck script now reads exclusions from script/.shellcheck-exclude, which contains 10 exclusion entries including import.sh, export.sh, and several lib/* scripts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

size/S

Poem

🐰 Shell scripts need order, a place to hide,
Away from the checker's all-seeing eyes,
We hop through configs with care and pride,
One clean exclusion file—no more surprise! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is in Japanese and describes moving shellcheck exclusions to an external file, which aligns with the main changes shown in the raw_summary.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/shellcheck-exclude-file

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@keito4

keito4 commented Feb 23, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (default) / Gemini (default)

🤖 Codex Review

以下は、git merge-base で特定したマージベースから HEAD までの差分に対するレビューです。

問題点:

  1. シェルチェック除外が機能しない
    • find script -name '*.sh' の出力は script/xxx.sh 形式です。一方、除外ファイルのパターンは import.sh など script/ プレフィックス無しのため、grep -vFf で一致せず除外されません。結果として、従来除外されていたファイルが再び shellcheck の対象になり、意図しない失敗が発生します。
    • 影響箇所: package.json:15, script/.shellcheck-exclude:1-10

判定: patch is incorrect
理由: 変更によって shellcheck の除外が実質的に無効化され、既存の除外対象ファイルが検査対象に戻る回帰が発生するため。
信頼度: 0.63

自然な次のステップ:

  1. 除外パターンを script/ プレフィックス付きに修正するか、find-printf '%P\n' に変更して相対パスを出力するように調整します。

✨ Gemini Review

ご提示いただいたdiffをレビューいたしました。

指摘事項

  1. script/.shellcheck-exclude: ファイル末尾に改行(newline)がありません。
    • 影響: POSIX標準ではテキストファイルの各行は改行で終わる必要があり、一部のツールでは最終行が無視されたり、Gitの差分表示で警告が出たりします。
    • ファイルと行範囲: script/.shellcheck-exclude (行10)

判定

patch is correct

理由

package.json 内にハードコードされていた複雑な除外リストを外部ファイル(.shellcheck-exclude)に切り出したことで、スクリプトの保守性と可読性が大幅に向上しています。また、grep -F を使用することで、ファイルパスに含まれるドット(.)などが正規表現のメタ文字として解釈されるリスクを排除し、意図しないマッチングを防ぎつつパフォーマンスを改善しているため、非常に良い変更です。

信頼度スコア

0.95


⚠️ 修正が必要です

上記のレビューで問題が指摘されています。修正してからマージしてください。


🤖 Generated by post_pr_ai_review.py hook

@keito4

keito4 commented Feb 23, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (default) / Gemini (default)

🤖 Codex Review

指摘事項はありません。変更は単純な除外リストの外部化で、既存の挙動(部分一致での除外)を維持しています。script/.shellcheck-exclude による grep -vFf の利用は意図通りに動作します。

判定
patch is correct。理由: 差分は shellcheck 除外対象の管理方法を文字列直書きからファイルに移しただけで、挙動の破壊的変更や品質リスクが見当たりません。信頼度 0.78

✨ Gemini Review

発見事項

  • script/.shellcheck-exclude: ファイルの末尾に改行(newline)が含まれていません。POSIX準拠のツール(一部の grep 実装を含む)では、最終行が改行で終わっていない場合にその行を無視することがあります。この場合、最後の lib/platform.sh が除外リストとして機能しなくなる可能性があるため、改行の追加を推奨します。

判定: patch is correct
理由: package.json にハードコードされていた複雑な除外パターンを外部ファイルに集約したことで、保守性が向上しています。また、grep -F(固定文字列マッチング)への変更により、ドット(.)がメタ文字としてではなくリテラルとして正確に評価されるようになり、副作用の少ないクリーンな実装になっています。

信頼度スコア: 1.0


🤖 Generated by post_pr_ai_review.py hook

@claude

claude Bot commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

PR レビュー: chore: shellcheck 除外リストを外部ファイルに分離

総評

設計の方向性は正しく、CI も全てグリーン。変更は小さく的確です。ただし、1点の技術的な問題と、いくつかの改善提案があります。


問題点

ファイル末尾の改行なし(要修正)

script/.shellcheck-exclude のdiffに \ No newline at end of file が出ています。

POSIX テキストファイルの仕様として末尾改行が必要であり、grep -f は末尾改行なしでも多くの実装で動作しますが、環境依存のリスクがあります。


確認事項(動作に問題なし)

grep フラグの変更について確認しました:

変更前: grep -v 'pat1\|pat2\|...' - 基本正規表現(BRE)の交替
変更後: grep -vFf script/.shellcheck-exclude - 固定文字列(-F)の複数パターン

-F フラグにより固定文字列マッチになっていますが、除外パターンはすべてファイルパスのリテラル文字列のため、動作は同等です。正規表現エスケープが不要になり、むしろ意図が明確になっています。


改善提案(任意)

コメントの追加: 除外理由をファイル内に記載するとメンテナンス性が向上します。例:

# shellcheck除外リスト
# 外部スクリプト(import/export)は解析対象外
import.sh
export.sh
# 認証情報を含むスクリプトは意図的にチェック除外
credentials.sh

まとめ

項目 評価
コード品質 ✅ 向上(保守性改善)
バグ・問題 ⚠️ 末尾改行なし(軽微だが修正推奨)
セキュリティ ✅ 問題なし
テストカバレッジ ✅ CI全通過・動作確認済み
PR サイズ ✅ 小さく的確(+11/-1行)

末尾改行の修正後、マージ可能と判断します。

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
package.json (1)

1-51: ⚠️ Potential issue | 🟠 Major

Commit type chore is prohibited for package.json changes.

The PR title uses chore: but this file matches package*.json. As per coding guidelines, commits touching package*.json must use a release-triggering commit type (feat, fix, perf, revert, or docs) — chore is explicitly excluded.

Consider re-titling the commit, e.g.:

docs: shellcheck 除外リストを外部ファイルに分離

or

fix: shellcheck 除外リストを外部ファイルに分離
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 1 - 51, The commit type must not be "chore" for
changes touching package*.json (this file package.json, specifically the
scripts.shellcheck change) — update the commit title to a release-triggering
type (e.g., "fix:", "feat:", "perf:", "docs:", or "revert:") and reword the
message accordingly; amend the existing commit (git commit --amend -m "...") or
create a new commit with the corrected prefix and a concise description such as
moving the shellcheck exclude list to an external file so CI and release tooling
accept the change.
🧹 Nitpick comments (1)
script/.shellcheck-exclude (1)

10-10: Add a trailing newline to the file.

POSIX specifies that patterns in a pattern file must be terminated by a <newline>. The file currently ends at lib/platform.sh without a trailing newline. GNU grep silently supplies a newline for input files ending in a non-newline character, so this works in practice, but adding the trailing newline ensures strict POSIX compliance and avoids unexpected behaviour on non-GNU grep implementations.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@script/.shellcheck-exclude` at line 10, The pattern file entry
"lib/platform.sh" lacks a trailing newline; open the .shellcheck-exclude file
and ensure the line containing the literal token lib/platform.sh is terminated
with a newline character (add an empty line break at end of file) so the pattern
file conforms to POSIX requirements.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@package.json`:
- Around line 1-51: The commit type must not be "chore" for changes touching
package*.json (this file package.json, specifically the scripts.shellcheck
change) — update the commit title to a release-triggering type (e.g., "fix:",
"feat:", "perf:", "docs:", or "revert:") and reword the message accordingly;
amend the existing commit (git commit --amend -m "...") or create a new commit
with the corrected prefix and a concise description such as moving the
shellcheck exclude list to an external file so CI and release tooling accept the
change.

---

Nitpick comments:
In `@script/.shellcheck-exclude`:
- Line 10: The pattern file entry "lib/platform.sh" lacks a trailing newline;
open the .shellcheck-exclude file and ensure the line containing the literal
token lib/platform.sh is terminated with a newline character (add an empty line
break at end of file) so the pattern file conforms to POSIX requirements.

@keito4
keito4 merged commit fe92694 into main Feb 23, 2026
17 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.81.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released リリース済み label Feb 23, 2026
@claude claude Bot mentioned this pull request Mar 1, 2026
github-actions Bot added a commit that referenced this pull request Mar 1, 2026
- .devcontainer/README.md / VERSIONING.md: config-base イメージバージョンを v1.54.0 → v1.81.1 に更新
- docs/tool-catalog.md:
  - npm 11.10.0 → 11.10.1, @openai/codex 0.101.0 → 0.104.0, @google/gemini-cli 0.28.2 → 0.29.5
  - Vercel CLI 50.17.1 → 50.22.1, n8n 2.7.5 → 2.8.3, yaml-language-server 1.19.2 → 1.20.0
  - @commitlint/{cli,config-conventional} 20.4.1 → 20.4.2
  - Features テーブルから node Feature を削除(PR #509 で devcontainer.json より削除済み)
  - セクション 6.1 の最新バージョン記載を 1.58.0+ → 1.81.1 に更新
- script/README.md: .shellcheck-exclude ファイルの説明を追加(PR #507Closes #513

Co-authored-by: keito4 <keito4@users.noreply.github.com>
@keito4
keito4 deleted the chore/shellcheck-exclude-file branch March 1, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant