Skip to content

Commit 7b799c7

Browse files
KuaaMUUbuntu
andauthored
fix: resolve all shellcheck warnings (#3)
- SC1091: Add shellcheck source comments for sourced files - SC2034: Remove unused 'branch' variable in submit.sh - SC2002: Replace useless cat with direct file read in watch.sh - All tests passing (12/12) Co-authored-by: Ubuntu <ubuntu@localhost.localdomain>
1 parent 64e0a3c commit 7b799c7

4 files changed

Lines changed: 18 additions & 15 deletions

File tree

bin/auto-pr

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
99
SRC_DIR="$SCRIPT_DIR/../src"
1010

1111
# 加载模块
12+
# shellcheck source=src/checks.sh
1213
source "$SRC_DIR/checks.sh"
14+
# shellcheck source=src/submit.sh
1315
source "$SRC_DIR/submit.sh"
16+
# shellcheck source=src/watch.sh
1417
source "$SRC_DIR/watch.sh"
18+
# shellcheck source=src/fix.sh
1519
source "$SRC_DIR/fix.sh"
1620

1721
# 颜色定义
@@ -123,7 +127,7 @@ cmd_init() {
123127
# 创建 Rust CI
124128
create_rust_ci() {
125129
if [ ! -f ".github/workflows/ci.yml" ]; then
126-
cat > .github/workflows/ci.yml << 'EOF'
130+
cat > .github/workflows/ci.yml << 'CIEOF'
127131
name: CI
128132
129133
on:
@@ -157,15 +161,15 @@ jobs:
157161
158162
- name: Tests
159163
run: cargo test
160-
EOF
164+
CIEOF
161165
log_success "创建 Rust CI workflow"
162166
fi
163167
}
164168

165169
# 创建 Node.js CI
166170
create_node_ci() {
167171
if [ ! -f ".github/workflows/ci.yml" ]; then
168-
cat > .github/workflows/ci.yml << 'EOF'
172+
cat > .github/workflows/ci.yml << 'CIEOF'
169173
name: CI
170174
171175
on:
@@ -199,15 +203,15 @@ jobs:
199203
200204
- name: Build
201205
run: npm run build || true
202-
EOF
206+
CIEOF
203207
log_success "创建 Node.js CI workflow"
204208
fi
205209
}
206210

207211
# 创建 Python CI
208212
create_python_ci() {
209213
if [ ! -f ".github/workflows/ci.yml" ]; then
210-
cat > .github/workflows/ci.yml << 'EOF'
214+
cat > .github/workflows/ci.yml << 'CIEOF'
211215
name: CI
212216
213217
on:
@@ -237,15 +241,15 @@ jobs:
237241
238242
- name: Test
239243
run: pytest || true
240-
EOF
244+
CIEOF
241245
log_success "创建 Python CI workflow"
242246
fi
243247
}
244248

245249
# 创建 Go CI
246250
create_go_ci() {
247251
if [ ! -f ".github/workflows/ci.yml" ]; then
248-
cat > .github/workflows/ci.yml << 'EOF'
252+
cat > .github/workflows/ci.yml << 'CIEOF'
249253
name: CI
250254
251255
on:
@@ -273,7 +277,7 @@ jobs:
273277
274278
- name: Build
275279
run: go build ./...
276-
EOF
280+
CIEOF
277281
log_success "创建 Go CI workflow"
278282
fi
279283
}
@@ -282,15 +286,15 @@ EOF
282286
create_dependabot() {
283287
local ecosystem=$1
284288
if [ ! -f ".github/dependabot.yml" ]; then
285-
cat > .github/dependabot.yml << EOF
289+
cat > .github/dependabot.yml << DEPEOF
286290
version: 2
287291
updates:
288292
- package-ecosystem: "$ecosystem"
289293
directory: "/"
290294
schedule:
291295
interval: "weekly"
292296
open-pull-requests-limit: 5
293-
EOF
297+
DEPEOF
294298
log_success "创建 Dependabot 配置"
295299
fi
296300
}

src/submit.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ cmd_submit() {
1919

2020
local project_type
2121
project_type=$(detect_project_type)
22-
local branch
23-
branch=$(git branch --show-current)
2422

2523
# 1. 本地安全门禁
2624
log_info "运行本地检查..."
@@ -79,7 +77,7 @@ get_pr_body() {
7977
local changes
8078
changes=$(git diff main...HEAD --stat 2>/dev/null || echo "No changes")
8179

82-
cat << EOF
80+
cat << BODYEOF
8381
## Summary
8482
$(git log -1 --format=%s)
8583
@@ -94,7 +92,7 @@ $changes
9492
9593
## Related Issues
9694
N/A
97-
EOF
95+
BODYEOF
9896
}
9997

10098
# 手动触发 AI 审查

src/watch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cmd_watch() {
6363
log_error "无法自动修复,请手动处理"
6464
echo ""
6565
echo "失败日志:"
66-
cat /tmp/ci-failure.log 2>/dev/null | head -50
66+
head -50 /tmp/ci-failure.log 2>/dev/null
6767
return 1
6868
fi
6969
done

tests/test_checks.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ assert_exit_code() {
3232

3333
# 加载模块
3434
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
35+
# shellcheck source=src/checks.sh
3536
source "$SCRIPT_DIR/../src/checks.sh"
3637

3738
# 测试用例

0 commit comments

Comments
 (0)