* Codebase cleanup
This commit is contained in:
2025-12-09 01:06:38 +00:00
committed by GitHub
parent 7dec532e18
commit d9888f1a56
16 changed files with 39 additions and 25 deletions
+1
View File
@@ -296,6 +296,7 @@ func LoadConfig(path string) (*Config, error) {
return nil, fmt.Errorf("config file too large: %d bytes (max %d)", fileInfo.Size(), maxConfigSize)
}
// #nosec G304 -- path is validated in main.go (no system dirs, absolute path)
data, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to read config file: %w", err)
+2 -2
View File
@@ -264,8 +264,8 @@ func (m *Mutator) writeAtomic(cfg *Config) error {
// Atomic rename
if err := os.Rename(tmpFile, m.configPath); err != nil {
// Clean up temp file on failure
os.Remove(tmpFile)
// Clean up temp file on failure - error ignored as we're already handling the rename error
_ = os.Remove(tmpFile)
return fmt.Errorf("failed to rename temp file: %w", err)
}
+3 -3
View File
@@ -33,7 +33,7 @@ func NewWatcher(configPath string, callback ReloadCallback, verbose bool) (*Watc
absPath, err := filepath.Abs(configPath)
if err != nil {
watcher.Close()
_ = watcher.Close()
return nil, fmt.Errorf("failed to resolve absolute path: %w", err)
}
@@ -41,7 +41,7 @@ func NewWatcher(configPath string, callback ReloadCallback, verbose bool) (*Watc
// (many editors delete and recreate files on save)
dir := filepath.Dir(absPath)
if err := watcher.Add(dir); err != nil {
watcher.Close()
_ = watcher.Close()
return nil, fmt.Errorf("failed to watch directory %s: %w", dir, err)
}
@@ -63,7 +63,7 @@ func (w *Watcher) Start() {
// Stop stops watching the configuration file and waits for the watch goroutine to exit.
func (w *Watcher) Stop() {
close(w.done)
w.watcher.Close()
_ = w.watcher.Close()
w.wg.Wait() // Wait for watch goroutine to exit
}