Skip to content

Commit

Permalink
chore: fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tphakala committed Apr 6, 2024
1 parent b34c445 commit c726fcf
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
6 changes: 5 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"log"

"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -26,7 +27,10 @@ func RootCommand(settings *conf.Settings) *cobra.Command {
}

// Set up the global flags for the root command.
setupFlags(rootCmd, settings)
err := setupFlags(rootCmd, settings)
if err != nil {
log.Printf("error setting up flags: %v\n", err)
}

// Add sub-commands to the root command.
fileCmd := file.Command(settings)
Expand Down
1 change: 0 additions & 1 deletion internal/analysis/processor/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type DatabaseAction struct {
Ds datastore.Interface
Note datastore.Note
Results []datastore.Results
pcmData []byte
EventTracker *EventTracker
AudioBuffer *myaudio.AudioBuffer
}
Expand Down
2 changes: 1 addition & 1 deletion internal/analysis/processor/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ExecuteScriptAction struct {
}

// A map to store the action configurations for different species
var speciesActionsMap map[string]SpeciesActionConfig
//var speciesActionsMap map[string]SpeciesActionConfig

func (a ExecuteScriptAction) Execute(data interface{}) error {
//log.Println("Executing script:", a.ScriptPath)
Expand Down
7 changes: 3 additions & 4 deletions internal/analysis/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ type Processor struct {
}

type Detections struct {
pcmData3s []byte
pcmDataExt []byte
Note datastore.Note // Note containing highest match
Results []datastore.Results // Full BirdNET prediction results
pcmData3s []byte // 3s PCM data containing the detection
Note datastore.Note // Note containing highest match
Results []datastore.Results // Full BirdNET prediction results
}

// PendingDetection struct represents a single detection held in memory,
Expand Down
4 changes: 2 additions & 2 deletions internal/birdnet/rangefilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func loadSpeciesFromCSV(fileName string) ([]string, error) {
}

// mergeSpeciesLists merges two slices of species, removing duplicates.
func mergeSpeciesLists(list1, list2 []string) []string {
/*func mergeSpeciesLists(list1, list2 []string) []string {
uniqueSpecies := make(map[string]struct{})
for _, species := range list1 {
uniqueSpecies[species] = struct{}{}
Expand All @@ -238,4 +238,4 @@ func mergeSpeciesLists(list1, list2 []string) []string {
}
}
return list1
}
}*/
2 changes: 1 addition & 1 deletion internal/mqtt/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (c *Client) Publish(topic string, payload string) error {
return errors.New("MQTT client is not initialized")
}

if c.internalClient.IsConnected() == false {
if !c.internalClient.IsConnected() {
return errors.New("MQTT client is not connected")
}

Expand Down
6 changes: 5 additions & 1 deletion internal/myaudio/buffers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package myaudio

import (
"log"
"sync"
"time"

Expand Down Expand Up @@ -32,7 +33,10 @@ func InitRingBuffer(capacity int) {

// writeToBuffer writes audio data into the ring buffer.
func WriteToBuffer(data []byte) {
ringBuffer.Write(data)
_, err := ringBuffer.Write(data)
if err != nil {
log.Printf("Error writing to ring buffer: %v", err)
}
}

// readFromBuffer reads a sliding chunk of audio data from the ring buffer.
Expand Down
4 changes: 2 additions & 2 deletions internal/myaudio/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func captureAudioMalgo(settings *conf.Settings, wg *sync.WaitGroup, quitChan cha
if err != nil {
log.Fatalf("context init failed %v", err)
}
defer malgoCtx.Uninit()
defer malgoCtx.Uninit() //nolint:errcheck

deviceConfig := malgo.DefaultDeviceConfig(malgo.Capture)
deviceConfig.Capture.Format = malgo.FormatS16
Expand Down Expand Up @@ -132,7 +132,7 @@ func captureAudioMalgo(settings *conf.Settings, wg *sync.WaitGroup, quitChan cha
if err != nil {
log.Fatalf("Device start failed %v", err)
}
defer device.Stop()
defer device.Stop() //nolint:errcheck

if settings.Debug {
fmt.Println("Device started")
Expand Down

0 comments on commit c726fcf

Please sign in to comment.