Skip to content
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Commit 909839c

Browse files
committed
Minor linter and typo fixes
1 parent f6469c2 commit 909839c

23 files changed

+60
-24
lines changed

.golangci.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
run:
2+
# timeout for analysis, e.g. 30s, 5m, default is 1m
3+
timeout: 5m
4+
5+
# include test files or not, default is true
6+
tests: true
7+
8+
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
9+
# If invoked with -mod=readonly, the go command is disallowed from the implicit
10+
# automatic updating of go.mod described above. Instead, it fails when any changes
11+
# to go.mod are needed. This setting is most useful to check that go.mod does
12+
# not need updates, such as in a continuous integration and testing system.
13+
# If invoked with -mod=vendor, the go command assumes that the vendor
14+
# directory holds the correct copies of dependencies and ignores
15+
# the dependency descriptions in go.mod.
16+
modules-download-mode: readonly
17+
18+
# output configuration options
19+
output:
20+
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
21+
formats:
22+
- format: colored-line-number
23+
24+
linters:
25+
enable:
26+
- bodyclose
27+
- errcheck
28+
- errorlint
29+
- gocheckcompilerdirectives
30+
- gochecknoinits
31+
- gochecksumtype
32+
- goconst
33+
- gofmt
34+
- gosimple
35+
- gosec
36+
- govet
37+
- nilerr
38+
- nilnil
39+
- staticcheck
40+
- typecheck
41+
- unused
42+
- whitespace
43+
44+
issues:
45+
# Excluding configuration per-path, per-linter, per-text and per-source
46+
exclude-rules:
47+
# Exclude some linters from running on tests files.
48+
- path: _test\.go
49+
linters:
50+
- errcheck
51+
- goconst
52+
- gosec
53+
54+
# checking for errors in defers seldom makes sense...
55+
- source: "^\\s*defer\\s"
56+
linters:
57+
- errcheck
58+
- staticcheck

cem/events.go

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
// handle SPINE events
99
func (h *Cem) HandleEvent(payload spineapi.EventPayload) {
10-
1110
if util.IsDeviceConnected(payload) {
1211
h.eventCB(payload.Ski, payload.Device, DeviceConnected)
1312
return

uccevc/events.go

-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ func (e *UCCEVC) evIncentiveTableDescriptionDataUpdate(payload spineapi.EventPay
156156
if e.evCheckIncentiveTableDescriptionUpdateRequired(payload.Entity) {
157157
e.eventCB(payload.Ski, payload.Device, payload.Entity, DataRequestedIncentiveTableDescription)
158158
}
159-
160159
}
161160

162161
// the incentive table constraint data of an EV was updated

uccevc/events_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,4 @@ func (s *UCCEVCSuite) Test_evTimeSeriesDescriptionDataUpdate() {
158158
assert.Nil(s.T(), fErr)
159159

160160
s.sut.evTimeSeriesDescriptionDataUpdate(payload)
161-
162161
}

uccevc/public_scen1.go

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ func (e *UCCEVC) ChargeStrategy(entity spineapi.EntityRemoteInterface) api.EVCha
6363

6464
return api.EVChargeStrategyTypeNoDemand
6565
}
66-
6766
}
6867

6968
return api.EVChargeStrategyTypeUnknown

uccevc/public_scen3_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ func (s *UCCEVCSuite) Test_WriteIncentives() {
203203
for _, tc := range tests {
204204
s.T().Run(tc.name, func(t *testing.T) {
205205
for _, data := range tc.data {
206-
207206
constData = &model.IncentiveTableConstraintsDataType{
208207
IncentiveTableConstraints: []model.IncentiveTableConstraintsType{
209208
{

uccevc/public_scen4.go

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ func (e *UCCEVC) ChargePlan(entity spineapi.EntityRemoteInterface) (api.ChargePl
9292
currentStart := time.Now()
9393
currentEnd := currentStart
9494
if data.TimePeriod != nil && data.TimePeriod.StartTime != nil {
95-
9695
if start, err := data.TimePeriod.StartTime.GetTimeDuration(); err == nil {
9796
currentStart = currentStart.Add(start)
9897
startAvailable = true

uccevc/public_scen4_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ func (s *UCCEVCSuite) Test_ChargePlanConstaints() {
7878

7979
_, err = s.sut.ChargePlanConstraints(s.evEntity)
8080
assert.Nil(s.T(), err)
81-
8281
}
8382

8483
func (s *UCCEVCSuite) Test_ChargePlan() {

ucevcc/events.go

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ func (e *UCEVCC) evManufacturerDataUpdate(payload spineapi.EventPayload) {
187187
if _, err := evDeviceClassification.GetManufacturerDetails(); err == nil {
188188
e.eventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateManufacturerData)
189189
}
190-
191190
}
192191

193192
// the electrical connection parameter description data of an EV was updated

ucevcc/public.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func (e *UCEVCC) ChargeState(entity spineapi.EntityRemoteInterface) (api.EVCharg
1616

1717
evDeviceDiagnosis, err := util.DeviceDiagnosis(e.service, entity)
1818
if err != nil {
19-
return api.EVChargeStateTypeUnplugged, nil
19+
return api.EVChargeStateTypeUnplugged, err
2020
}
2121

2222
diagnosisState, err := evDeviceDiagnosis.GetState()
@@ -201,7 +201,6 @@ func (e *UCEVCC) ManufacturerData(
201201
api.ManufacturerData,
202202
error,
203203
) {
204-
205204
return util.ManufacturerData(e.service, entity, e.validEntityTypes)
206205
}
207206

ucevcem/events.go

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ func (e *UCEVCEM) evConnected(entity spineapi.EntityRemoteInterface) {
5252
if _, err := evElectricalConnection.RequestParameterDescriptions(); err != nil {
5353
logging.Log().Debug(err)
5454
}
55-
5655
}
5756

5857
if evMeasurement, err := util.Measurement(e.service, entity); err == nil {

ucevsecc/ucevsecc.go

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ func (e *UCEVSECC) IsUseCaseSupported(entity spineapi.EntityRemoteInterface) (bo
9898
) {
9999
return false, nil
100100
}
101-
102101
}
103102

104103
return true, nil

ucmgcp/events.go

-1
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,4 @@ func (e *UCMGCP) gridMeasurementDataUpdate(payload spineapi.EventPayload) {
139139
if _, err := util.MeasurementValueForScope(e.service, payload.Entity, model.ScopeTypeTypeACFrequency); err == nil {
140140
e.eventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFrequency)
141141
}
142-
143142
}

ucmgcp/public_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ func (s *UCMGCPSuite) Test_CurrentPerPhase() {
322322
data, err = s.sut.CurrentPerPhase(s.smgwEntity)
323323
assert.Nil(s.T(), err)
324324
assert.Equal(s.T(), []float64{10, 10, 10}, data)
325-
326325
}
327326

328327
func (s *UCMGCPSuite) Test_VoltagePerPhase() {

ucmpc/events.go

-1
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,4 @@ func (e *UCMPC) deviceMeasurementDataUpdate(payload spineapi.EventPayload) {
110110
if _, err := util.MeasurementValueForScope(e.service, payload.Entity, model.ScopeTypeTypeACFrequency); err == nil {
111111
e.eventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFrequency)
112112
}
113-
114113
}

ucmpc/public_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ func (s *UCMPCSuite) Test_CurrentPerPhase() {
382382
data, err = s.sut.CurrentPerPhase(s.monitoredEntity)
383383
assert.Nil(s.T(), err)
384384
assert.Equal(s.T(), []float64{10, 10, 10}, data)
385-
386385
}
387386

388387
func (s *UCMPCSuite) Test_VoltagePerPhase() {

ucopev/events.go

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ func (e *UCOPEV) evLoadControlLimitDataUpdate(payload spineapi.EventPayload) {
9494
e.eventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateLimit)
9595
return
9696
}
97-
9897
}
9998

10099
// the electrical connection permitted value sets data of an EV was updated

ucvabd/ucvabd_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,4 @@ func (s *UCVABDSuite) Test_IsUseCaseSupported() {
9494
data, err = s.sut.IsUseCaseSupported(s.batteryEntity)
9595
assert.Nil(s.T(), err)
9696
assert.Equal(s.T(), true, data)
97-
9897
}

ucvapd/ucvapd_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,4 @@ func (s *UCVAPDSuite) Test_IsUseCaseSupported() {
111111
data, err = s.sut.IsUseCaseSupported(s.pvEntity)
112112
assert.Nil(s.T(), err)
113113
assert.Equal(s.T(), true, data)
114-
115114
}

util/loadcontrol.go

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ func LoadControlLimits(
1919
entity spineapi.EntityRemoteInterface,
2020
entityTypes []model.EntityTypeType,
2121
category model.LoadControlCategoryType) (limits []api.LoadLimitsPhase, resultErr error) {
22-
2322
limits = nil
2423
resultErr = api.ErrNoCompatibleEntity
2524
if entity == nil || !IsCompatibleEntity(entity, entityTypes) {

util/loadcontrol_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ func (s *UtilSuite) Test_WriteLoadControlLimits() {
351351
IsActive: true,
352352
Value: limit,
353353
})
354-
355354
}
355+
356356
msgCounter, err = WriteLoadControlLimits(s.service, s.monitoredEntity, entityTypes, category, phaseLimitValues)
357357
assert.Nil(t, err)
358358
assert.NotNil(t, msgCounter)

util/measurement.go

-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func MeasurementValuesForTypeCommodityScope(
4343
energyDirection model.EnergyDirectionType,
4444
validPhaseNameTypes []model.ElectricalConnectionPhaseNameType,
4545
) ([]float64, error) {
46-
4746
measurement := measurementType
4847
commodity := commodityType
4948
scope := scopeType
@@ -99,7 +98,6 @@ func GetValuesForTypeCommodityScope(
9998
measurement model.MeasurementTypeType,
10099
commodity model.CommodityTypeType,
101100
scope model.ScopeTypeType) ([]model.MeasurementDataType, error) {
102-
103101
measurementFeature, err := Measurement(service, entity)
104102
if err != nil || measurementFeature == nil {
105103
return nil, err

util/measurement_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,4 @@ func (s *UtilSuite) Test_MeasurementValuesForTypeCommodityScope() {
197197
)
198198
assert.Nil(s.T(), err)
199199
assert.Equal(s.T(), []float64{10, 10, 10}, data)
200-
201200
}

0 commit comments

Comments
 (0)