From 373839ee85f02f9f0e4082de6d9b2fb918d16aef Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 9 Apr 2025 19:31:33 +0200 Subject: [PATCH 1/3] refactor: improve file closing error handling --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 3a70316..9d35c7f 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,13 @@ func main() { fmt.Printf("Error opening %s: %v\n", eventPath, err) os.Exit(1) } - defer eventFile.Close() + defer func() { + closeFileErr := eventFile.Close() + if closeFileErr != nil { + fmt.Println("Error closing eventFile") + os.Exit(1) + } + }() var event GithubEvent decoder := json.NewDecoder(eventFile) -- 2.47.2 From 79e4f6c2bf7a3e42079a4cb365b3ebc4817cb9ed Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 9 Apr 2025 19:37:47 +0200 Subject: [PATCH 2/3] chore: add golangci lint configuration file --- .golangci.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..d5ac850 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,4 @@ +version: "2" +linters: + enable: + - revive -- 2.47.2 From f0839e48e1e83e1042d7fe0f500930b28898c0c1 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 9 Apr 2025 19:39:56 +0200 Subject: [PATCH 3/3] docs: update package comments for clarity --- internal/validation/validation.go | 2 ++ main.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/internal/validation/validation.go b/internal/validation/validation.go index 8c3123e..0a4ada9 100644 --- a/internal/validation/validation.go +++ b/internal/validation/validation.go @@ -1,3 +1,4 @@ +// Package validation General validation tasks package validation import ( @@ -6,6 +7,7 @@ import ( "strings" ) +// ValidateConventionalCommit validates if string follows conventional commit func ValidateConventionalCommit(commit string) error { // Regex to match the commit format // type(scope)!: description diff --git a/main.go b/main.go index 9d35c7f..507692b 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,4 @@ +// Package main is the main package package main import ( @@ -8,6 +9,7 @@ import ( "git.kjan.de/actions/pull-request-lint/internal/validation" ) +// GithubEvent represents a github actions event type GithubEvent struct { PullRequest struct { Title string `json:"title"` -- 2.47.2