Skip to content

Commit

Permalink
Update lint, fix lint, update replay tests
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmclean committed Dec 8, 2024
1 parent 236ecec commit 82892e8
Show file tree
Hide file tree
Showing 12 changed files with 6,241 additions and 2,324 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
go-version: "1.23"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: latest
working-directory: ./${{ env.PROJECT_NAME }}
Expand Down
12 changes: 6 additions & 6 deletions garden-app/pkg/light_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ func (ls *LightSchedule) String() string {
}

// Patch allows modifying the struct in-place with values from a different instance
func (ls *LightSchedule) Patch(new *LightSchedule) {
if new.Duration != nil {
ls.Duration = new.Duration
func (ls *LightSchedule) Patch(newLightSchedule *LightSchedule) {
if newLightSchedule.Duration != nil {
ls.Duration = newLightSchedule.Duration
}
if new.StartTime != nil {
ls.StartTime = new.StartTime
if newLightSchedule.StartTime != nil {
ls.StartTime = newLightSchedule.StartTime
}
if new.AdhocOnTime == nil {
if newLightSchedule.AdhocOnTime == nil {
ls.AdhocOnTime = nil
}
}
52 changes: 26 additions & 26 deletions garden-app/pkg/water_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,42 +73,42 @@ func (ws *WaterSchedule) HasWeatherControl() bool {
}

// Patch allows modifying the struct in-place with values from a different instance
func (ws *WaterSchedule) Patch(new *WaterSchedule) *babyapi.ErrResponse {
if new.Duration != nil {
ws.Duration = new.Duration
func (ws *WaterSchedule) Patch(newWaterSchedule *WaterSchedule) *babyapi.ErrResponse {
if newWaterSchedule.Duration != nil {
ws.Duration = newWaterSchedule.Duration
}
if new.Interval != nil {
ws.Interval = new.Interval
if newWaterSchedule.Interval != nil {
ws.Interval = newWaterSchedule.Interval
}
if new.StartDate != nil {
ws.StartDate = new.StartDate
if newWaterSchedule.StartDate != nil {
ws.StartDate = newWaterSchedule.StartDate
}
if new.StartTime != nil {
ws.StartTime = new.StartTime
if newWaterSchedule.StartTime != nil {
ws.StartTime = newWaterSchedule.StartTime
}
if ws.EndDate != nil && new.EndDate == nil {
ws.EndDate = new.EndDate
if ws.EndDate != nil && newWaterSchedule.EndDate == nil {
ws.EndDate = newWaterSchedule.EndDate
}
if new.WeatherControl != nil {
if newWaterSchedule.WeatherControl != nil {
if ws.WeatherControl == nil {
ws.WeatherControl = &weather.Control{}
}
ws.WeatherControl.Patch(new.WeatherControl)
ws.WeatherControl.Patch(newWaterSchedule.WeatherControl)
}
if new.Name != "" {
ws.Name = new.Name
if newWaterSchedule.Name != "" {
ws.Name = newWaterSchedule.Name
}
if new.Description != "" {
ws.Description = new.Description
if newWaterSchedule.Description != "" {
ws.Description = newWaterSchedule.Description
}
if new.ActivePeriod != nil {
if newWaterSchedule.ActivePeriod != nil {
if ws.ActivePeriod == nil {
ws.ActivePeriod = &ActivePeriod{}
}
ws.ActivePeriod.Patch(new.ActivePeriod)
ws.ActivePeriod.Patch(newWaterSchedule.ActivePeriod)
}
if new.NotificationClientID != nil {
ws.NotificationClientID = new.NotificationClientID
if newWaterSchedule.NotificationClientID != nil {
ws.NotificationClientID = newWaterSchedule.NotificationClientID

Check warning on line 111 in garden-app/pkg/water_schedule.go

View check run for this annotation

Codecov / codecov/patch

garden-app/pkg/water_schedule.go#L111

Added line #L111 was not covered by tests
}

return nil
Expand Down Expand Up @@ -188,12 +188,12 @@ func (ap *ActivePeriod) Validate() error {
}

// Patch allows for easily updating/editing an ActivePeriod
func (ap *ActivePeriod) Patch(new *ActivePeriod) {
if new.StartMonth != "" {
ap.StartMonth = new.StartMonth
func (ap *ActivePeriod) Patch(newActivePeriod *ActivePeriod) {
if newActivePeriod.StartMonth != "" {
ap.StartMonth = newActivePeriod.StartMonth
}
if new.EndMonth != "" {
ap.EndMonth = new.EndMonth
if newActivePeriod.EndMonth != "" {
ap.EndMonth = newActivePeriod.EndMonth
}
}

Expand Down
28 changes: 14 additions & 14 deletions garden-app/pkg/weather/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ type Control struct {
}

// Patch allows modifying the struct in-place with values from a different instance
func (wc *Control) Patch(new *Control) {
if new.Rain != nil {
func (wc *Control) Patch(newControl *Control) {
if newControl.Rain != nil {
if wc.Rain == nil {
wc.Rain = &ScaleControl{}
}
wc.Rain.Patch(new.Rain)
wc.Rain.Patch(newControl.Rain)
}
if new.Temperature != nil {
if newControl.Temperature != nil {
if wc.Temperature == nil {
wc.Temperature = &ScaleControl{}
}
wc.Temperature.Patch(new.Temperature)
wc.Temperature.Patch(newControl.Temperature)
}
}

Expand Down Expand Up @@ -51,18 +51,18 @@ type ScaleControl struct {
}

// Patch allows modifying the struct in-place with values from a different instance
func (sc *ScaleControl) Patch(new *ScaleControl) {
if new.BaselineValue != nil {
sc.BaselineValue = new.BaselineValue
func (sc *ScaleControl) Patch(newScaleControl *ScaleControl) {
if newScaleControl.BaselineValue != nil {
sc.BaselineValue = newScaleControl.BaselineValue
}
if new.Factor != nil {
sc.Factor = new.Factor
if newScaleControl.Factor != nil {
sc.Factor = newScaleControl.Factor
}
if new.Range != nil {
sc.Range = new.Range
if newScaleControl.Range != nil {
sc.Range = newScaleControl.Range
}
if !new.ClientID.IsNil() {
sc.ClientID = new.ClientID
if !newScaleControl.ClientID.IsNil() {
sc.ClientID = newScaleControl.ClientID
}
}

Expand Down
10 changes: 5 additions & 5 deletions garden-app/pkg/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ func (zd *ZoneDetails) String() string {
}

// Patch allows modifying the struct in-place with values from a different instance
func (zd *ZoneDetails) Patch(new *ZoneDetails) {
if new.Description != "" {
zd.Description = new.Description
func (zd *ZoneDetails) Patch(newZoneDetails *ZoneDetails) {
if newZoneDetails.Description != "" {
zd.Description = newZoneDetails.Description
}
if new.Notes != "" {
zd.Notes = new.Notes
if newZoneDetails.Notes != "" {
zd.Notes = newZoneDetails.Notes
}
}

Expand Down
Loading

0 comments on commit 82892e8

Please sign in to comment.