Skip to content

Commit 79fb8c5

Browse files
committed
Fix linting errors. Add pre-commit
1 parent 950fa1c commit 79fb8c5

6 files changed

Lines changed: 48 additions & 30 deletions

File tree

‎.golangci.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: "2"
2+
linters:
3+
settings:
4+
staticcheck:
5+
checks:
6+
- all
7+
exclusions:
8+
paths:
9+
- ui/components
10+
- ui/utils/templui.go
11+
formatters:
12+
enable:
13+
- golines
14+
settings:
15+
golines:
16+
max-len: 120
17+
tab-len: 4

‎.pre-commit-config.yaml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
- repo: https://github.com/tekwizely/pre-commit-golang
3+
rev: v1.0.0-rc.2
4+
hooks:
5+
- id: go-mod-tidy
6+
7+
- repo: https://github.com/golangci/golangci-lint
8+
rev: v2.5.0
9+
hooks:
10+
- id: golangci-lint-full
11+
12+
- repo: local
13+
hooks:
14+
- id: prettier
15+
name: prettier
16+
entry: make prettier
17+
verbose: true
18+
language: system
19+
types: [css, javascript, html]

‎Makefile‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ CR_WEB_ASSETS_FILENAME ?= frontend-assets.tar.gz
88
CR_BUILD_ARTIFACTS_DIR ?= dist
99

1010

11-
lint:
12-
golangci-lint run --fix
11+
prettier:
1312
prettier --write frontend/
1413

14+
lint: prettier
15+
golangci-lint run --fix
16+
1517
test:
1618
gotestsum --format testname ./...
1719

‎db.go‎

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func initDB() error {
5151

5252
// Create claude-review directory
5353
dbDir := filepath.Join(dataHome, "claude-review")
54-
if err := os.MkdirAll(dbDir, 0755); err != nil {
54+
if err := os.MkdirAll(dbDir, 0o755); err != nil {
5555
return fmt.Errorf("failed to create database directory: %w", err)
5656
}
5757

@@ -178,31 +178,6 @@ func getComments(projectDir, filePath string, resolved bool) ([]Comment, error)
178178
return comments, nil
179179
}
180180

181-
func getAllCommentsForFile(projectDir, filePath string) ([]Comment, error) {
182-
query := `
183-
SELECT id, project_directory, file_path, line_start, line_end, selected_text, comment_text, resolved, created_at
184-
FROM comments
185-
WHERE project_directory = ? AND file_path = ?
186-
ORDER BY resolved ASC, line_start ASC`
187-
logQuery(query, projectDir, filePath)
188-
rows, err := db.Query(query, projectDir, filePath)
189-
if err != nil {
190-
return nil, err
191-
}
192-
defer func() { _ = rows.Close() }()
193-
194-
var comments []Comment
195-
for rows.Next() {
196-
var c Comment
197-
if err := rows.Scan(&c.ID, &c.ProjectDirectory, &c.FilePath, &c.LineStart, &c.LineEnd, &c.SelectedText, &c.CommentText, &c.Resolved, &c.CreatedAt); err != nil {
198-
return nil, err
199-
}
200-
comments = append(comments, c)
201-
}
202-
203-
return comments, nil
204-
}
205-
206181
func updateComment(commentID, commentText string) error {
207182
query := `
208183
UPDATE comments

‎frontend/static/viewer.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
commentButton.style.left = x + 'px';
131131
// Offset by button height to align bottom of button with top of selection
132132
const buttonHeight = 40; // 32px icon + 2*4px padding
133-
commentButton.style.top = (y - buttonHeight) + 'px';
133+
commentButton.style.top = y - buttonHeight + 'px';
134134
}
135135

136136
function hideCommentButton() {

‎markdown.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ func (r *CodeBlockRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegistere
129129
reg.Register(ast.KindCodeBlock, r.renderCodeBlock)
130130
}
131131

132-
func (r *CodeBlockRenderer) renderCodeBlock(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
132+
func (r *CodeBlockRenderer) renderCodeBlock(
133+
w util.BufWriter,
134+
source []byte,
135+
node ast.Node,
136+
entering bool,
137+
) (ast.WalkStatus, error) {
133138
if entering {
134139
// Write <pre> with data-line attributes
135140
_, _ = w.WriteString("<pre")

0 commit comments

Comments
 (0)