Skip to content

Commit 3ce1836

Browse files
committed
fix
Signed-off-by: Sinelnikov Michail <mikhail.sinelnikov@flant.com>
1 parent 756c375 commit 3ce1836

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

pkg/linters/module/rules/changelog.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package rules
1818

1919
import (
2020
errs "errors"
21+
"fmt"
2122
"os"
2223
"path/filepath"
2324

@@ -46,22 +47,24 @@ func (r *ChangelogRule) CheckChangelog(modulePath string, errorList *errors.Lint
4647
errorList = errorList.WithRule(r.GetName())
4748

4849
changelogPath := filepath.Join(modulePath, changelogFilename)
49-
exists, empty := checkFile(changelogPath)
50-
51-
if !exists {
52-
errorList.WithFilePath(changelogFilename).Error("changelog.yaml file is missing")
53-
} else if empty {
54-
errorList.WithFilePath(changelogFilename).Error("changelog.yaml file is empty")
50+
err := checkFile(changelogPath)
51+
if err != nil {
52+
errorList.WithFilePath(changelogFilename).Error(err.Error())
5553
}
54+
5655
}
5756

58-
func checkFile(filePath string) (bool, bool) {
57+
func checkFile(filePath string) error {
5958
stat, err := os.Stat(filePath)
6059
if errs.Is(err, os.ErrNotExist) {
61-
return false, true
60+
return fmt.Errorf("changelog.yaml file does not exist: %w", err)
6261
}
6362
if err != nil {
64-
return false, true
63+
return fmt.Errorf("failed to stat changelog.yaml file: %w", err)
6564
}
66-
return true, stat.Size() == 0
65+
if stat.Size() == 0 {
66+
return fmt.Errorf("changelog.yaml file is empty")
67+
}
68+
69+
return nil
6770
}

0 commit comments

Comments
 (0)