From a857f12cb5fdd0f900151a999355c8fafa3e7fa1 Mon Sep 17 00:00:00 2001 From: Nikolai Papin Date: Tue, 25 Nov 2025 15:52:38 +0300 Subject: [PATCH] chore: linted --- src/internal/browserlauncher/chrome.go | 2 +- src/internal/browserlauncher/firefox.go | 2 +- src/internal/config/config.go | 10 ++++---- src/internal/linkvalidator/linkvalidator.go | 10 ++++---- src/internal/screencapturer/interface.go | 2 +- .../screencapturer/wholescreencapturer.go | 25 ++++++++++--------- src/internal/vision/vision.go | 3 ++- src/utils/platform.go | 2 +- 8 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/internal/browserlauncher/chrome.go b/src/internal/browserlauncher/chrome.go index fdadbe0..2639813 100644 --- a/src/internal/browserlauncher/chrome.go +++ b/src/internal/browserlauncher/chrome.go @@ -1,7 +1,7 @@ // Copyright (c) 2025 Nikolai Papin // // This file is part of the Auto Attendance app that looks for -// self-attend QR-codes during lectures and opens their URLs in your +// self-attend QR-codes during lectures and opens their URLs in your // browser. // // This program is free software: you can redistribute it and/or modify diff --git a/src/internal/browserlauncher/firefox.go b/src/internal/browserlauncher/firefox.go index fdadbe0..2639813 100644 --- a/src/internal/browserlauncher/firefox.go +++ b/src/internal/browserlauncher/firefox.go @@ -1,7 +1,7 @@ // Copyright (c) 2025 Nikolai Papin // // This file is part of the Auto Attendance app that looks for -// self-attend QR-codes during lectures and opens their URLs in your +// self-attend QR-codes during lectures and opens their URLs in your // browser. // // This program is free software: you can redistribute it and/or modify diff --git a/src/internal/config/config.go b/src/internal/config/config.go index afd03a4..baf4bd3 100644 --- a/src/internal/config/config.go +++ b/src/internal/config/config.go @@ -46,10 +46,10 @@ type AppConfig struct { } type ScreenshotConfig struct { - ScreenIndex int `mapstructure:"screen_index"` - Interval int `mapstructure:"interval"` + ScreenIndex int `mapstructure:"screen_index"` + Interval int `mapstructure:"interval"` Directory string `mapstructure:"directory"` - BufferCount int `mapstructure:"buffer_count"` + BufferCount int `mapstructure:"buffer_count"` } type CommunicationConfig struct { @@ -84,8 +84,8 @@ func getDefaultConfig() Config { }, Screenshot: ScreenshotConfig{ ScreenIndex: 0, - Interval: 5, - Directory: getTempDirectoryPath(), + Interval: 5, + Directory: getTempDirectoryPath(), BufferCount: 5, }, Logging: LoggingConfig{ diff --git a/src/internal/linkvalidator/linkvalidator.go b/src/internal/linkvalidator/linkvalidator.go index b4e8173..c78e105 100644 --- a/src/internal/linkvalidator/linkvalidator.go +++ b/src/internal/linkvalidator/linkvalidator.go @@ -52,10 +52,10 @@ func (v *linkValidatorImpl) ValidateLink(rawURL string) (token string, ok bool) if v.config.Communication.QrUrl != "" { expectedURL, err := url.Parse(v.config.Communication.QrUrl) if err == nil { - if parsedURL.Scheme != expectedURL.Scheme || - parsedURL.Host != expectedURL.Host || - parsedURL.Path != expectedURL.Path { - v.log.Debug("URL doesn't match configured QR URL pattern", + if parsedURL.Scheme != expectedURL.Scheme || + parsedURL.Host != expectedURL.Host || + parsedURL.Path != expectedURL.Path { + v.log.Debug("URL doesn't match configured QR URL pattern", "url", rawURL, "expected", v.config.Communication.QrUrl) return "", false } @@ -64,7 +64,7 @@ func (v *linkValidatorImpl) ValidateLink(rawURL string) (token string, ok bool) if v.config.Communication.ApiSelfApproveMethod != "" { if !strings.Contains(parsedURL.Path, v.config.Communication.ApiSelfApproveMethod) { - v.log.Debug("URL doesn't contain expected API method", + v.log.Debug("URL doesn't contain expected API method", "url", parsedURL.Path, "expected", v.config.Communication.ApiSelfApproveMethod) return "", false } diff --git a/src/internal/screencapturer/interface.go b/src/internal/screencapturer/interface.go index ef2b976..6045dcd 100644 --- a/src/internal/screencapturer/interface.go +++ b/src/internal/screencapturer/interface.go @@ -1,7 +1,7 @@ // Copyright (c) 2025 Nikolai Papin // // This file is part of the Auto Attendance app that looks for -// self-attend QR-codes during lectures and opens their URLs in your +// self-attend QR-codes during lectures and opens their URLs in your // browser. // // This program is free software: you can redistribute it and/or modify diff --git a/src/internal/screencapturer/wholescreencapturer.go b/src/internal/screencapturer/wholescreencapturer.go index bf15551..12c43bc 100644 --- a/src/internal/screencapturer/wholescreencapturer.go +++ b/src/internal/screencapturer/wholescreencapturer.go @@ -43,15 +43,15 @@ var ( type wholeScreenCapturer struct { config *config.Config - log *logger.Logger + log *logger.Logger - displayIndex int - displayBounds image.Rectangle - interval int - bufferCount int + displayIndex int + displayBounds image.Rectangle + interval int + bufferCount int tempDirectory string - initialized bool - running bool + initialized bool + running bool files []string latest string @@ -189,7 +189,7 @@ func (w *wholeScreenCapturer) captureAndSave() (string, error) { func (w *wholeScreenCapturer) addToBuffer(fp string) { w.mu.Lock() - defer w.mu.Unlock() + defer w.mu.Unlock() w.files = append(w.files, fp) w.latest = fp @@ -208,20 +208,22 @@ func (w *wholeScreenCapturer) createTempDirectory() (path string, err error) { return os.MkdirTemp(w.config.Screenshot.Directory, constants.AppName+"-*") } -func NewWholeScreenCapturer(lc fx.Lifecycle, config *config.Config, log *logger.Logger) ScreenCapturer { +func NewWholeScreenCapturer( + lc fx.Lifecycle, config *config.Config, log *logger.Logger, +) ScreenCapturer { capturer := &wholeScreenCapturer{ config: config, log: log, done: make(chan struct{}), } lc.Append(fx.StopHook(func(ctx context.Context) error { - if (!capturer.initialized) { + if !capturer.initialized { log.Debug("wholescreencapturer not initialized, nothing to do") return nil } log.Debug("stopping wholescreencapturer") - + err := capturer.Stop() if err != nil { log.Error("failed to stop wholescreencapturer gracefully") @@ -237,4 +239,3 @@ func NewWholeScreenCapturer(lc fx.Lifecycle, config *config.Config, log *logger. })) return capturer } - diff --git a/src/internal/vision/vision.go b/src/internal/vision/vision.go index 867ca33..45881eb 100644 --- a/src/internal/vision/vision.go +++ b/src/internal/vision/vision.go @@ -42,6 +42,7 @@ var ( // AnalyzeImage implements Vision. func (v *visionImpl) AnalyzeImage(filePath string) (data VisionData, err error) { + // TODO: scanning for multiple QR-codes at once v.log.Debug("analyzing image for qr codes", "filePath", filePath) img := gocv.IMRead(filePath, gocv.IMReadColor) @@ -78,7 +79,7 @@ func (v *visionImpl) AnalyzeImage(filePath string) (data VisionData, err error) } v.log.Info("QR code decoded successfully", "content", result.GetText()) - + data = VisionData{result.GetText()} return data, nil } diff --git a/src/utils/platform.go b/src/utils/platform.go index 7f27a60..f898cdc 100644 --- a/src/utils/platform.go +++ b/src/utils/platform.go @@ -1,7 +1,7 @@ // Copyright (c) 2025 Nikolai Papin // // This file is part of the Auto Attendance app that looks for -// self-attend QR-codes during lectures and opens their URLs in your +// self-attend QR-codes during lectures and opens their URLs in your // browser. // // This program is free software: you can redistribute it and/or modify