Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Rename fails when "---" is anywhere in the file #968

@riosdavi

Description

@riosdavi

Provided the following code:

01. func (cluster *Cluster) Update() {
02.	logger.Debug("--- Update begin")
03.	for _, device := range cluster.Devices {
04.
05.		objects, err := getObjectsByDeviceID(device.DeviceId)
06.		if err == nil {
07.			logger.Debug("--- Update count:", len(objects), " - deviceId:", device.DeviceId)
08.			err = updateObjectCount(objects)
09.		}
10.		if err != nil {
11.			logger.Error(err.Error())
12.		}
13.	}
14.	logger.Debug("--- Update end")
15. }

Renaming device to soDevice causes the following refactoring, where line4 (blank line) is replaced by a duplicate of line 5 with the old variable name (device), and lines 8, 9 and 10 are replaced by logger.Debug("Index:

01. func (cluster *Cluster) Update() {
02.	logger.Debug("--- Update begin")
03.	for _, soDevice := range cluster.Devices {
04.		objects, err := getObjectsByDeviceID(device.DeviceId)
05.		objects, err := getObjectsByDeviceID(soDevice.DeviceId)
06.			logger.Debug("--- Update count:", len(objects), " - deviceId:", device.DeviceId)
07.			logger.Debug("Index
08.			logger.Error(err.Error())
09.		}
10.	}
11.	logger.Debug("--- Update end")
12. }

Removing line 4 (empty line) causes the line 5 not being duplicated after the refactor but the result is almost the same.

Note: after removing the logging lines (logger.Debug and logger.Error), renaming worked as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions