AOSSIE-Org / AOSSIE-Org/Template-Repo

Config: Add Go-Specific Review Instructions to .coderabbit.yaml

Đang mở
#95 5 bình luận 0 reaction 1 người được giao Được @Okd2006 nhận Xem trên GitHub
Ngôn ngữ chính
YAML
Star
17
Fork
29
Merge trung bình
3 ngày 13 giờ
Pull request đã merge (30 ngày)
6

Mô tả

## Overview

`golangci-lint` is already enabled in `.coderabbit.yaml`, but there are no Go-specific `path_instructions` to guide CodeRabbit's review logic for `.go` files. This issue tracks adding a dedicated Go review instruction block to improve the quality and depth of reviews on AOSSIE's Go-based projects.

---

## Proposed Change

Add the following block to the `path_instructions` section in `.coderabbit.yaml`:

```yaml
path_instructions:
- path: "**/*.go"
instructions: |
Go code review guidelines:

**Naming & Style**
- Follow Effective Go naming conventions (MixedCaps, not underscores).
- Package names should be lowercase, single-word, and descriptive.
- Exported functions, types, and variables must have godoc comments.

**Error Handling**
- Errors must not be silently ignored (no bare `_` discards for error returns).
- Prefer wrapping errors with `fmt.Errorf("...: %w", err)` to preserve stack context.
- Avoid `panic` except in truly unrecoverable situations; prefer returning errors.

**Goroutine & Concurrency Hygiene**
- Every goroutine must have a clear lifetime and ownership.
- Ensure `sync.WaitGroup` or context cancellation is used to manage goroutine teardown.
- Flag potential data races: shared state accessed from multiple goroutines without synchronization.
- Prefer channels for communication over shared memory where appropriate.

**Context Propagation**
- Functions that perform I/O, network calls, or long computations should accept `context.Context` as the first parameter.
- Ensure contexts are not stored in structs; pass them explicitly.
- Check that context cancellation/deadlines are respected in loops and blocking calls.

**Testing**
- Prefer table-driven tests using `[]struct{...}` test case slices.
- Test function names should follow the `TestFunctionName_Scenario` pattern.
- Ensure test coverage for error paths and edge cases, not just happy paths.
- Flag missing tests for exported functions.

**Initialization**
- Flag usage of `init()` functions unless there is clear justification (e.g., driver registration).
- Prefer explicit initialization over side-effect imports.

**Performance & Resource Management**
- Ensure `defer` is used correctly for resource cleanup (files, mutexes, connections).
- Flag unnecessary allocations inside hot loops.
- Prefer pre-allocated slices (`make([]T, 0, n)`) when the size is known in advance.

**Security**
- Flag use of `unsafe` package and require justification.
- Check for SQL injection risks in dynamically constructed queries.
- Ensure sensitive data is not logged.
```

---

## Acceptance Criteria

- [ ] `.coderabbit.yaml` updated with the above `path_instructions` block for `**/*.go` files.
- [ ] The `template-sync.yml` workflow propagates the updated config to child repos using this template.
- [ ] Verified that CodeRabbit applies the Go-specific instructions when reviewing `.go` files.

---

## References

- CodeRabbit path-based instructions: https://docs.coderabbit.ai/guides/review-instructions
- Effective Go: https://go.dev/doc/effective_go
- golangci-lint: https://golangci-lint.run/

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.