Skip to content

Commit 2a3eace

Browse files
authored
chore: fix linter issues (#10)
1 parent d7fa35b commit 2a3eace

23 files changed

Lines changed: 124 additions & 84 deletions

‎entsoe/api_client.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package entsoe provides a client for the ENTSO-E Transparency Platform API.
12
package entsoe
23

34
import (
@@ -37,12 +38,13 @@ func (c *APIClient) DownloadPublicationMarketData(ctx context.Context, apiURL st
3738
return DownloadPublicationMarketDataWithOptions(ctx, apiURL, opts)
3839
}
3940

40-
// DownloadPublicationMarketDataWithOptions downloads and decodes a PublicationMarketData with additional options
41+
// DownloadOptions contains options for downloading publication market data with additional options.
4142
type DownloadOptions struct {
4243
UserAgent string
4344
Headers map[string]string
4445
}
4546

47+
// DownloadPublicationMarketData downloads and decodes publication market data for the current and next day if needed.
4648
func DownloadPublicationMarketData(ctx context.Context, securityToken string, urlFormat string, location *time.Location) (*PublicationMarketData, error) {
4749

4850
now := time.Now().In(location)

‎entsoe/api_client_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func TestDownloadPublicationMarketData_EmptyURL(t *testing.T) {
143143

144144
func TestDownloadPublicationMarketData_HTTPError(t *testing.T) {
145145
// Create a test server that returns HTTP 500
146-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
146+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
147147
w.WriteHeader(http.StatusInternalServerError)
148148
w.Write([]byte("Internal Server Error"))
149149
}))
@@ -166,7 +166,7 @@ func TestDownloadPublicationMarketData_HTTPError(t *testing.T) {
166166

167167
func TestDownloadPublicationMarketData_InvalidXML(t *testing.T) {
168168
// Create a test server that returns invalid XML
169-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
169+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
170170
w.Header().Set("Content-Type", "application/xml")
171171
w.WriteHeader(http.StatusOK)
172172
w.Write([]byte("<invalid><xml></invalid>"))
@@ -190,7 +190,7 @@ func TestDownloadPublicationMarketData_InvalidXML(t *testing.T) {
190190

191191
func TestDownloadPublicationMarketData_ContextCancellation(t *testing.T) {
192192
// Create a test server with a delay
193-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
193+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
194194
time.Sleep(100 * time.Millisecond)
195195
w.Header().Set("Content-Type", "application/xml")
196196
w.WriteHeader(http.StatusOK)
@@ -410,7 +410,7 @@ func TestDownloadPublicationMarketData_CustomUserAgent(t *testing.T) {
410410
// Benchmark tests
411411
func BenchmarkDownloadPublicationMarketData(b *testing.B) {
412412
// Create a test server
413-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
413+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
414414
w.Header().Set("Content-Type", "application/xml")
415415
w.WriteHeader(http.StatusOK)
416416
w.Write([]byte(sampleXMLResponse))

‎main.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main provides the Energy Management System (EMS) entry point and CLI interface.
12
package main
23

34
import (

‎meteo/client_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func TestGetCompact(t *testing.T) {
279279

280280
func TestAPIError(t *testing.T) {
281281
// Create test server that returns an error
282-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
282+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
283283
w.WriteHeader(http.StatusBadRequest)
284284
w.Write([]byte("Bad Request: Invalid parameters"))
285285
}))

‎meteo/example/main.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main provides an example of using the meteo client to fetch weather forecasts.
12
package main
23

34
import (

‎meteo/types.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import "time"
55
// WeatherSymbol represents weather condition identifiers
66
type WeatherSymbol string
77

8+
// Weather symbol constants represent different weather conditions.
89
const (
910
ClearSkyDay WeatherSymbol = "clearsky_day"
1011
ClearSkyNight WeatherSymbol = "clearsky_night"

‎miners/avalon.go‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package miners provides functionality for discovering and controlling cryptocurrency miners.
12
package miners
23

34
import (
@@ -15,9 +16,13 @@ import (
1516
"time"
1617
)
1718

19+
// Sender is a function type for sending data over a network connection.
1820
type Sender func(conn net.Conn) error
21+
22+
// Receiver is a generic function type for receiving data over a network connection.
1923
type Receiver[T any] func(conn net.Conn) (T, error)
2024

25+
// UnmarshalJSON implements custom JSON unmarshaling for StatsItem.
2126
func (s *StatsItem) UnmarshalJSON(data []byte) error {
2227
var raw map[string]string
2328
if err := json.Unmarshal(data, &raw); err != nil {
@@ -196,7 +201,7 @@ func (s *StatsItem) UnmarshalJSON(data []byte) error {
196201
}
197202
case "PCOMM_E":
198203
if i, err := strconv.Atoi(value); err == nil {
199-
stats.PCOMM_E = i
204+
stats.PCommE = i
200205
}
201206
case "GHSspd":
202207
if f, err := strconv.ParseFloat(value, 64); err == nil {
@@ -315,6 +320,7 @@ func (s *StatsItem) UnmarshalJSON(data []byte) error {
315320
return nil
316321
}
317322

323+
// Discover searches for Avalon miners on the specified network and returns a list of discovered hosts.
318324
func Discover(ctx context.Context, network string) []*AvalonQHost {
319325
hosts := make([]*AvalonQHost, 0)
320326
var wg sync.WaitGroup
@@ -351,6 +357,7 @@ func getAddresses(network string) iter.Seq[netip.Addr] {
351357
}
352358
}
353359

360+
// Standby puts the Avalon miner into standby mode.
354361
func (h *AvalonQHost) Standby(ctx context.Context) (string, error) {
355362
if _, err := h.SetWorkMode(ctx, AvalonEcoMode, true); err != nil {
356363
return "", err
@@ -364,6 +371,7 @@ func (h *AvalonQHost) Standby(ctx context.Context) (string, error) {
364371
)
365372
}
366373

374+
// SetWorkMode sets the work mode of the Avalon miner.
367375
func (h *AvalonQHost) SetWorkMode(ctx context.Context, mode AvalonWorkMode, resetHistory bool) (string, error) {
368376
if resetHistory {
369377
h.ResetLiteStats()
@@ -377,6 +385,7 @@ func (h *AvalonQHost) SetWorkMode(ctx context.Context, mode AvalonWorkMode, rese
377385
)
378386
}
379387

388+
// WakeUp wakes up the Avalon miner from standby mode.
380389
func (h *AvalonQHost) WakeUp(ctx context.Context) (string, error) {
381390
h.ResetLiteStats()
382391
return send(ctx, h.Address, h.Port,
@@ -388,14 +397,15 @@ func (h *AvalonQHost) WakeUp(ctx context.Context) (string, error) {
388397
)
389398
}
390399

400+
// RefreshLiteStats refreshes the lite statistics for the Avalon miner.
391401
func (h *AvalonQHost) RefreshLiteStats(ctx context.Context) {
392402
stats, err := send(ctx, h.Address, h.Port,
393403
func(conn net.Conn) error {
394404
return writeCommand("litestats", conn)
395405
},
396406
func(conn net.Conn) (*AvalonQLiteStats, error) {
397407
stats := &AvalonQLiteStats{}
398-
if err := readJsonResponse(conn, stats); err != nil {
408+
if err := readJSONResponse(conn, stats); err != nil {
399409
return nil, err
400410
}
401411
return stats, nil
@@ -417,7 +427,7 @@ func version(ctx context.Context, address string, port int) (*AvalonQVersion, er
417427
},
418428
func(conn net.Conn) (*AvalonQVersion, error) {
419429
v := &AvalonQVersion{}
420-
if err := readJsonResponse(conn, v); err != nil {
430+
if err := readJSONResponse(conn, v); err != nil {
421431
return nil, err
422432
}
423433
return v, nil
@@ -465,7 +475,7 @@ func readStringResponse(conn net.Conn) (string, error) {
465475
return string(r), nil
466476
}
467477

468-
func readJsonResponse(conn net.Conn, response any) error {
478+
func readJSONResponse(conn net.Conn, response any) error {
469479
dec := json.NewDecoder(conn)
470480
return dec.Decode(response)
471481
}

‎miners/avalon_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ func TestAvalonQLiteStatParsing(t *testing.T) {
209209
}
210210

211211
// Test communication error
212-
if stats.PCOMM_E != 0 {
213-
t.Errorf("Expected PCOMM_E 0, got %d", stats.PCOMM_E)
212+
if stats.PCommE != 0 {
213+
t.Errorf("Expected PCommE 0, got %d", stats.PCommE)
214214
}
215215

216216
// Test hash rate fields

‎miners/models.go‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ type AvalonState int
66
// AvalonWorkMode represents the work mode of an Avalon miner
77
type AvalonWorkMode int
88

9+
// Avalon miner state constants
910
const (
1011
AvalonStateRunning AvalonState = 0 // Running
1112
AvalonStateMining AvalonState = 1 // Mining
1213
AvalonStateStandBy AvalonState = 2 // StandBy
1314
)
1415

16+
// Avalon miner work mode constants
1517
const (
1618
AvalonEcoMode AvalonWorkMode = 0 // Eco
1719
AvalonStandardMode AvalonWorkMode = 1 // Standard
@@ -56,10 +58,12 @@ func (w AvalonWorkMode) String() string {
5658
}
5759
}
5860

61+
// AvalonQCommand represents a command to send to an Avalon miner.
5962
type AvalonQCommand struct {
6063
Command string `json:"command"`
6164
}
6265

66+
// AvalonQHost represents an Avalon miner host with its connection details and statistics.
6367
type AvalonQHost struct {
6468
Address string
6569
Port int
@@ -89,12 +93,14 @@ func (h *AvalonQHost) ResetLiteStats() {
8993
}
9094
}
9195

96+
// AvalonQVersion represents version information from an Avalon miner.
9297
type AvalonQVersion struct {
9398
Status []StatusItem `json:"STATUS"`
9499
Version []VersionItem `json:"VERSION"`
95100
ID int `json:"id"`
96101
}
97102

103+
// StatusItem represents a status response item from an Avalon miner.
98104
type StatusItem struct {
99105
Status string `json:"STATUS"`
100106
When int64 `json:"When"`
@@ -103,6 +109,7 @@ type StatusItem struct {
103109
Description string `json:"Description"`
104110
}
105111

112+
// VersionItem represents version details from an Avalon miner.
106113
type VersionItem struct {
107114
CGMiner string `json:"CGMiner"`
108115
API string `json:"API"`
@@ -119,16 +126,19 @@ type VersionItem struct {
119126
MAC string `json:"MAC"`
120127
}
121128

129+
// AvalonQLiteStats represents lite statistics response from an Avalon miner.
122130
type AvalonQLiteStats struct {
123131
Status []StatusItem `json:"STATUS"`
124132
Stats []StatsItem `json:"STATS"`
125133
ID int `json:"id"`
126134
}
127135

136+
// StatsItem represents a statistics item from an Avalon miner.
128137
type StatsItem struct {
129138
MMIDSummary *AvalonLiteStats `json:"-"`
130139
}
131140

141+
// AvalonLiteStats represents detailed statistics from an Avalon miner.
132142
type AvalonLiteStats struct {
133143
Ver string `json:"ver"`
134144
LVer string `json:"lver"`
@@ -169,7 +179,7 @@ type AvalonLiteStats struct {
169179
FanErr int `json:"fan_err"`
170180
SoloAllowed int `json:"solo_allowed"`
171181
PS []int `json:"ps"`
172-
PCOMM_E int `json:"pcomm_e"`
182+
PCommE int `json:"pcomm_e"`
173183
GHSspd float64 `json:"ghs_spd"`
174184
DHspd string `json:"dh_spd"`
175185
GHSmm float64 `json:"ghs_mm"`

‎mpc/example/main.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main provides an example of using the MPC (Model Predictive Control) optimization.
12
package main
23

34
import (
@@ -24,7 +25,7 @@ func main() {
2425
}
2526

2627
// Create MPC controller with 24-hour horizon
27-
mpcController := mpc.NewMPCController(config, 24, 0.5) // Start at 50% SOC
28+
mpcController := mpc.NewController(config, 24, 0.5) // Start at 50% SOC
2829

2930
// Create 24-hour forecast
3031
forecast := make([]mpc.TimeSlot, 24)

0 commit comments

Comments
 (0)