Skip to content

Commit

Permalink
Update golangci-lint version to 1.50.1 (#1381)
Browse files Browse the repository at this point in the history
* Update golangci-lint version to 1.50.1

Remove deprecated lints: golangci/golangci-lint#3125
Re-enable gocritic features which previously didn't support generics

* gofmt

* Pass PrevBackupInfo by reference as it is 232 bytes
  • Loading branch information
serprex committed Dec 20, 2022
1 parent e5bb11f commit 02a4000
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Expand Up @@ -27,4 +27,4 @@ jobs:
uses: golangci/golangci-lint-action@v3.3.1
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.46.2
version: v1.50.1
14 changes: 4 additions & 10 deletions .golangci.yml
Expand Up @@ -17,12 +17,9 @@ linters-settings:
- experimental
- opinionated
- style
disabled-checks:
- hugeParam
- rangeValCopy
# settings:
# hugeParam:
# sizeThreshold: 170 # temporary, default is 80
settings:
hugeParam:
sizeThreshold: 170 # temporary, default is 80
gocyclo:
min-complexity: 15
govet:
Expand Down Expand Up @@ -77,14 +74,11 @@ linters:
- nakedret
- revive
- staticcheck
# - structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- lll
- deadcode
- stylecheck
- gosimple
- whitespace
Expand All @@ -108,5 +102,5 @@ severity:
rules:
- linters:
- godox
- deadcode
- unused
severity: info
2 changes: 1 addition & 1 deletion internal/backup.go
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/wal-g/wal-g/utility"
)

//region errors
// region errors
type SentinelMarshallingError struct {
error
}
Expand Down
4 changes: 2 additions & 2 deletions internal/backup_mark.go
Expand Up @@ -119,7 +119,7 @@ func (h *BackupMarkHandler) getBackupsToMarkImpermanent(backupName string) ([]st
return []string{meta.BackupName}, nil
}

//backup has permanent in future only when one of the next backups is permanent
// backup has permanent in future only when one of the next backups is permanent
func backupHasPermanentInFuture(reverseLinks *map[string][]string,
backupName string,
permanentBackups *map[string]bool) bool {
Expand All @@ -138,7 +138,7 @@ func backupHasPermanentInFuture(reverseLinks *map[string][]string,
return false
}

//return graph where nodes - backup names, edges - links from base backups to increment backups
// return graph where nodes - backup names, edges - links from base backups to increment backups
func (h *BackupMarkHandler) getGraphFromBaseToIncrement() (map[string][]string, error) {
backups, err := GetBackups(h.baseBackupFolder)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/databases/greenplum/ao_storage.go
Expand Up @@ -30,7 +30,7 @@ func makeDeltaAoFileStorageKey(baseKey string, modCount int64) string {
return fmt.Sprintf("%s%s%d%s", trimmedKey, AoSegDeltaDelimiter, modCount, AoSegSuffix)
}

//LoadStorageAoFiles loads the list of the AO/AOCS segment files that are referenced from previous backups
// LoadStorageAoFiles loads the list of the AO/AOCS segment files that are referenced from previous backups
func LoadStorageAoFiles(baseBackupsFolder storage.Folder) (map[string]struct{}, error) {
aoSegments := make(map[string]struct{}, 0)

Expand Down
2 changes: 1 addition & 1 deletion internal/databases/greenplum/backup_push_handler.go
Expand Up @@ -222,7 +222,7 @@ func (bh *BackupHandler) HandleBackupPush() {
bh.currBackupInfo.segmentsMetadata, err = bh.fetchSegmentBackupsMetadata()
tracelog.ErrorLogger.FatalOnError(err)

sentinelDto := NewBackupSentinelDto(bh.currBackupInfo, bh.prevBackupInfo,
sentinelDto := NewBackupSentinelDto(bh.currBackupInfo, &bh.prevBackupInfo,
restoreLSNs, bh.arguments.userData, bh.arguments.isPermanent)
err = bh.uploadSentinel(sentinelDto)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/databases/greenplum/backup_sentinel_dto.go
Expand Up @@ -98,7 +98,7 @@ func (s *BackupSentinelDto) String() string {
}

// NewBackupSentinelDto returns new BackupSentinelDto instance
func NewBackupSentinelDto(currBackupInfo CurrBackupInfo, prevBackupInfo PrevBackupInfo, restoreLSNs map[int]string, userData interface{},
func NewBackupSentinelDto(currBackupInfo CurrBackupInfo, prevBackupInfo *PrevBackupInfo, restoreLSNs map[int]string, userData interface{},
isPermanent bool) BackupSentinelDto {
hostname, err := os.Hostname()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/databases/greenplum/configure.go
Expand Up @@ -32,7 +32,7 @@ func ConfigureSegContentID(contentIDFlag string) (int, error) {
return contentID, nil
}

//initGpLog is required for gp-common-go library to function properly
// initGpLog is required for gp-common-go library to function properly
func initGpLog(logsDir string) {
gplog.SetLogFileNameFunc(func(program, logdir string) string {
return fmt.Sprintf("%s/%s-gplog.log", logdir, program)
Expand Down
6 changes: 3 additions & 3 deletions internal/databases/greenplum/generic_meta_interactor.go
Expand Up @@ -24,7 +24,7 @@ func NewGenericMetaFetcher() GenericMetaFetcher {
return GenericMetaFetcher{}
}

//TODO: Unit tests
// TODO: Unit tests
func (mf GenericMetaFetcher) Fetch(backupName string, backupFolder storage.Folder) (internal.GenericMetadata, error) {
var backup = internal.NewBackup(backupFolder, backupName)
var sentinel BackupSentinelDto
Expand Down Expand Up @@ -52,7 +52,7 @@ func NewGenericMetaSetter() GenericMetaSetter {
return GenericMetaSetter{}
}

//TODO: Unit tests
// TODO: Unit tests
func (ms GenericMetaSetter) SetUserData(backupName string, backupFolder storage.Folder, userData interface{}) error {
modifier := func(dto BackupSentinelDto) BackupSentinelDto {
dto.UserData = userData
Expand All @@ -61,7 +61,7 @@ func (ms GenericMetaSetter) SetUserData(backupName string, backupFolder storage.
return modifyBackupSentinel(backupName, backupFolder, modifier)
}

//TODO: Unit tests
// TODO: Unit tests
func (ms GenericMetaSetter) SetIsPermanent(backupName string, backupFolder storage.Folder, isPermanent bool) error {
modifier := func(dto BackupSentinelDto) BackupSentinelDto {
dto.IsPermanent = isPermanent
Expand Down
2 changes: 1 addition & 1 deletion internal/databases/mongo/archive/layout.go
Expand Up @@ -144,7 +144,7 @@ func SplitPurgingOplogArchivesByTS(archives []models.Archive, purgeBeforeTS mode
return purge
}

//OldestBackupAfterTime returns last backup after given time.
// OldestBackupAfterTime returns last backup after given time.
func OldestBackupAfterTime(backups []*models.Backup, after time.Time) (*models.Backup, error) {
if len(backups) <= 0 {
return nil, fmt.Errorf("empty backup list received")
Expand Down
2 changes: 1 addition & 1 deletion internal/databases/mongo/archive/loader.go
Expand Up @@ -100,7 +100,7 @@ func (sd *StorageDownloader) LoadBackups(names []string) ([]*models.Backup, erro
return backups, nil
}

//ListBackups lists backups in folder
// ListBackups lists backups in folder
func (sd *StorageDownloader) ListBackups() ([]internal.BackupTime, []string, error) {
return internal.GetBackupsAndGarbage(sd.backupsFolder)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/databases/mysql/generic_meta_interactor.go
Expand Up @@ -24,7 +24,7 @@ func NewGenericMetaFetcher() GenericMetaFetcher {
return GenericMetaFetcher{}
}

//TODO: Unit tests
// TODO: Unit tests
func (mf GenericMetaFetcher) Fetch(backupName string, backupFolder storage.Folder) (internal.GenericMetadata, error) {
var backup = internal.NewBackup(backupFolder, backupName)
var sentinel StreamSentinelDto
Expand Down Expand Up @@ -52,7 +52,7 @@ func NewGenericMetaSetter() GenericMetaSetter {
return GenericMetaSetter{}
}

//TODO: Unit tests
// TODO: Unit tests
func (ms GenericMetaSetter) SetUserData(backupName string, backupFolder storage.Folder, userData interface{}) error {
modifier := func(dto StreamSentinelDto) StreamSentinelDto {
dto.UserData = userData
Expand All @@ -61,7 +61,7 @@ func (ms GenericMetaSetter) SetUserData(backupName string, backupFolder storage.
return modifyBackupSentinel(backupName, backupFolder, modifier)
}

//TODO: Unit tests
// TODO: Unit tests
func (ms GenericMetaSetter) SetIsPermanent(backupName string, backupFolder storage.Folder, isPermanent bool) error {
modifier := func(dto StreamSentinelDto) StreamSentinelDto {
dto.IsPermanent = isPermanent
Expand Down
6 changes: 3 additions & 3 deletions internal/databases/postgres/generic_meta_interactor.go
Expand Up @@ -24,7 +24,7 @@ func NewGenericMetaFetcher() GenericMetaFetcher {
return GenericMetaFetcher{}
}

//TODO: Unit tests
// TODO: Unit tests
func (mf GenericMetaFetcher) Fetch(backupName string, backupFolder storage.Folder) (internal.GenericMetadata, error) {
var backup = NewBackup(backupFolder, backupName)
meta, err := backup.FetchMeta()
Expand All @@ -51,7 +51,7 @@ func NewGenericMetaSetter() GenericMetaSetter {
return GenericMetaSetter{}
}

//TODO: Unit tests
// TODO: Unit tests
func (ms GenericMetaSetter) SetUserData(backupName string, backupFolder storage.Folder, userData interface{}) error {
modifier := func(dto ExtendedMetadataDto) ExtendedMetadataDto {
dto.UserData = userData
Expand All @@ -60,7 +60,7 @@ func (ms GenericMetaSetter) SetUserData(backupName string, backupFolder storage.
return modifyBackupMetadata(backupName, backupFolder, modifier)
}

//TODO: Unit tests
// TODO: Unit tests
func (ms GenericMetaSetter) SetIsPermanent(backupName string, backupFolder storage.Folder, isPermanent bool) error {
modifier := func(dto ExtendedMetadataDto) ExtendedMetadataDto {
dto.IsPermanent = isPermanent
Expand Down
2 changes: 1 addition & 1 deletion internal/databases/postgres/physical_slot.go
Expand Up @@ -21,7 +21,7 @@ type PhysicalSlot struct {
RestartLSN pglogrepl.LSN
}

//NewPhysicalSlot is a helper function to declare a new PhysicalSlot object and set vaues from the parsed arguments
// NewPhysicalSlot is a helper function to declare a new PhysicalSlot object and set vaues from the parsed arguments
func NewPhysicalSlot(name string, exists bool, active bool, restartLSN string) (slot PhysicalSlot, err error) {
err = ValidateSlotName(name)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions internal/databases/postgres/tarball_streamer.go
Expand Up @@ -90,7 +90,7 @@ func NewTarballStreamer(input io.Reader, maxTarSize int64, bundleFiles internal.
return streamer
}

//NextInputFile is what makes the TarballStreamer move to the next file.
// NextInputFile is what makes the TarballStreamer move to the next file.
func (streamer *TarballStreamer) NextInputFile() (err error) {
// First output tar, or switching to next
if streamer.outputTar == nil {
Expand All @@ -117,7 +117,7 @@ func (streamer *TarballStreamer) NextInputFile() (err error) {
return streamer.addFile()
}

//addFile adds the new file to the stream
// addFile adds the new file to the stream
func (streamer *TarballStreamer) addFile() (err error) {
if streamer.tarFileReadIndex+streamer.curHeader.Size > streamer.maxTarSize {
if streamer.tarFileReadIndex > 0 {
Expand Down Expand Up @@ -155,14 +155,14 @@ func (streamer *TarballStreamer) addFile() (err error) {
return nil
}

//remap rebuilds the name of the file according to remapping rules
// remap rebuilds the name of the file according to remapping rules
func (streamer *TarballStreamer) remap() {
for _, remap := range streamer.Remaps {
streamer.curHeader.Name = remap.from.ReplaceAllString(streamer.curHeader.Name, remap.to)
}
}

//readFileData reads the data from a tarred file
// readFileData reads the data from a tarred file
func (streamer *TarballStreamer) readFileData() (err error) {
err = streamer.NextInputFile()
if err != nil && err != errTarInputHeaderAlreadySet {
Expand Down Expand Up @@ -195,7 +195,7 @@ func (streamer *TarballStreamer) readFileData() (err error) {
return err
}

//pipeFileData calls readFileData to read file data from tar and then writes it to output tar writer
// pipeFileData calls readFileData to read file data from tar and then writes it to output tar writer
func (streamer *TarballStreamer) pipeFileData() (err error) {
if streamer.outputIo.Len() > 0 {
// There is still data in the buffer. Just stream that.
Expand Down Expand Up @@ -228,7 +228,7 @@ func (streamer *TarballStreamer) pipeFileData() (err error) {
return nil
}

//Read is what makes the TarballStreamer an io.Reader, which can be handled by WalUploader.UploadFile.
// Read is what makes the TarballStreamer an io.Reader, which can be handled by WalUploader.UploadFile.
func (streamer *TarballStreamer) Read(p []byte) (n int, err error) {
// Handle next file header if needed, read file data if needed, and write to output tar writer
err = streamer.pipeFileData()
Expand Down
2 changes: 1 addition & 1 deletion internal/databases/postgres/timeline_history.go
Expand Up @@ -43,7 +43,7 @@ type TimeLineHistFile struct {
readIndex int
}

//NewTimeLineHistFile is a helper function to define a new TimeLineHistFile
// NewTimeLineHistFile is a helper function to define a new TimeLineHistFile
func NewTimeLineHistFile(timelineid uint32, filename string, body []byte) (TimeLineHistFile, error) {
tlh := TimeLineHistFile{TimeLineID: timelineid, Filename: filename, data: body}
return tlh, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/databases/redis/redis.go
Expand Up @@ -18,7 +18,7 @@ func GetSettingWithLocalDefault(key string, defaultValue string) string {
return defaultValue
}

//getRedisConnection
// getRedisConnection
func _() *redis.Client {
redisAddr := GetSettingWithLocalDefault("WALG_REDIS_HOST", "localhost")
redisPort := GetSettingWithLocalDefault("WALG_REDIS_PORT", "6379")
Expand Down

0 comments on commit 02a4000

Please sign in to comment.