Skip to content

Commit

Permalink
Merge pull request #238 from coinbase/patrick/update-golangci
Browse files Browse the repository at this point in the history
[chore] Update golangci-lint to `v1.32.2`
  • Loading branch information
patrick-ogrady committed Nov 13, 2020
2 parents 33063f8 + 605dd76 commit 1e2b4a3
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 87 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ version: 2.1
executors:
default:
docker:
- image: circleci/golang:1.13
- image: circleci/golang:1.15
user: root # go directory is owned by root
working_directory: /go/src/github.com/coinbase/rosetta-sdk-go
environment:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
name: default
steps:
- *fast-checkout
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.32.2
- run: make lint
check-license:
executor:
Expand Down
67 changes: 27 additions & 40 deletions asserter/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,14 @@ import (
utils "github.com/coinbase/rosetta-sdk-go/errors"
)

// Named error types for Asserter errors
var (
/////////////////////
/* ASSERTER ERRORS */
/////////////////////

// ErrAsserterNotInitialized is returned when some call in the asserter
// package requires the asserter to be initialized first.
ErrAsserterNotInitialized = errors.New("asserter not initialized")
)

//////////////////////////////////
/* ACCOUNT BALANCE QUERY ERRORS */
//////////////////////////////////

// Account Balance Errors
var (
ErrReturnedBlockHashMismatch = errors.New(
"request block hash does not match response block hash",
)
Expand All @@ -45,11 +39,10 @@ var (
ErrReturnedBlockHashMismatch,
ErrReturnedBlockIndexMismatch,
}
)

//////////////////
/* BLOCK ERRORS */
//////////////////

// Block Errors
var (
ErrAmountValueMissing = errors.New("Amount.Value is missing")
ErrAmountIsNotInt = errors.New("Amount.Value is not an integer")
ErrAmountCurrencyIsNil = errors.New("Amount.Currency is nil")
Expand Down Expand Up @@ -133,11 +126,10 @@ var (
ErrBlockHashEqualsParentBlockHash,
ErrBlockIndexPrecedesParentBlockIndex,
}
)

/////////////////
/* COIN ERRORS */
/////////////////

// Coin Errors
var (
ErrCoinIsNil = errors.New("coin cannot be nil")
ErrCoinDuplicate = errors.New("duplicate coin identifier detected")
ErrCoinIdentifierIsNil = errors.New("coin identifier cannot be nil")
Expand All @@ -153,11 +145,10 @@ var (
ErrCoinChangeIsNil,
ErrCoinActionInvalid,
}
)

/////////////////////////
/* CONSTRUCTION ERRORS */
/////////////////////////

// Construction Errors
var (
ErrConstructionPreprocessResponseIsNil = errors.New(
"ConstructionPreprocessResponse cannot be nil",
)
Expand Down Expand Up @@ -250,11 +241,10 @@ var (
ErrSignatureBytesZero,
ErrSignatureTypeNotSupported,
}
)

////////////////////
/* NETWORK ERRORS */
////////////////////

// Network Errors
var (
ErrSubNetworkIdentifierInvalid = errors.New(
"NetworkIdentifier.SubNetworkIdentifier.Network is missing",
)
Expand Down Expand Up @@ -318,11 +308,10 @@ var (
ErrBalanceExemptionNoHistoricalLookup,
ErrTimestampStartIndexInvalid,
}
)

///////////////////
/* SERVER ERRORS */
///////////////////

// Server Errors
var (
ErrNoSupportedNetworks = errors.New(
"no supported networks",
)
Expand Down Expand Up @@ -422,11 +411,10 @@ var (
ErrMaxBlockInvalid,
ErrDuplicateCurrency,
}
)

///////////////////
/* EVENTS ERRORS */
///////////////////

// Events Errors
var (
ErrMaxSequenceInvalid = errors.New("max sequence invalid")
ErrSequenceInvalid = errors.New("sequence invalid")
ErrBlockEventTypeInvalid = errors.New("block event type invalid")
Expand All @@ -438,20 +426,19 @@ var (
ErrBlockEventTypeInvalid,
ErrSequenceOutOfOrder,
}
)

///////////////////
/* SEARCH ERRORS */
///////////////////

// Search Errors
var (
ErrNextOffsetInvalid = errors.New("next offset invalid")

SearchErrs = []error{
ErrNextOffsetInvalid,
}
)

///////////////////
/* ERROR ERRORS */
///////////////////
// Error Errors
var (
ErrErrorIsNil = errors.New("Error is nil")
ErrErrorCodeIsNeg = errors.New("Error.Code is negative")
ErrErrorMessageMissing = errors.New("Error.Message is missing")
Expand Down
4 changes: 2 additions & 2 deletions client/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ func (c *Configuration) ServerURL(index int, variables map[string]string) (strin
variable.EnumValues,
)
}
url = strings.Replace(url, "{"+name+"}", value, -1)
url = strings.ReplaceAll(url, "{"+name+"}", value)
} else {
url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1)
url = strings.ReplaceAll(url, "{"+name+"}", variable.DefaultValue)
}
}
return url, nil
Expand Down
11 changes: 4 additions & 7 deletions parser/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ import (
utils "github.com/coinbase/rosetta-sdk-go/errors"
)

// Named error types for Parser errors
// Intent Errors
var (
///////////////////
/* INTENT ERRORS */
///////////////////
ErrExpectedOperationAccountMismatch = errors.New(
"intended account did not match observed account",
)
Expand All @@ -46,10 +43,10 @@ var (
ErrExpectedSignerUnexpectedSigner,
ErrExpectedSignerMissing,
}
)

/////////////////////////////
/* MATCH OPERATIONS ERRORS */
/////////////////////////////
// Match Operations Errors
var (
ErrAccountMatchAccountMissing = errors.New("account is missing")
ErrAccountMatchSubAccountMissing = errors.New("SubAccountIdentifier.Address is missing")
ErrAccountMatchSubAccountPopulated = errors.New("SubAccount is populated")
Expand Down
2 changes: 1 addition & 1 deletion parser/match_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func metadataMatch(reqs []*MetadataDescription, metadata map[string]interface{})
// accountMatch returns an error if a *types.AccountIdentifier does not meet
// an *AccountDescription.
func accountMatch(req *AccountDescription, account *types.AccountIdentifier) error {
if req == nil { //anything is ok
if req == nil { // anything is ok
return nil
}

Expand Down
55 changes: 22 additions & 33 deletions storage/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ import (
utils "github.com/coinbase/rosetta-sdk-go/errors"
)

// Named error types for Storage errors
// Badger Storage Errors
var (
////////////////////
/* BADGER STORAGE */
////////////////////

ErrDatabaseOpenFailed = errors.New("unable to open database")
ErrCompressorLoadFailed = errors.New("unable to load compressor")
ErrDBCloseFailed = errors.New("unable to close database")
Expand Down Expand Up @@ -71,11 +67,10 @@ var (
ErrTrainZSTDFailed,
ErrWalkFilesFailed,
}
)

///////////////////////
/* BROADCAST STORAGE */
///////////////////////

// Broadcast Storage Errors
var (
ErrBroadcastTxStale = errors.New("unable to handle stale transaction")
ErrBroadcastTxConfirmed = errors.New(
"unable to handle confirmed transaction",
Expand Down Expand Up @@ -137,11 +132,10 @@ var (
ErrBroadcastCommitDeleteFailed,
ErrBroadcastPerformFailed,
}
)

//////////////////
/* COIN STORAGE */
//////////////////

// Coin Storage Errors
var (
ErrCoinQueryFailed = errors.New("unable to query for coin")
ErrCoinDecodeFailed = errors.New("unable to decode coin")
ErrCoinGetFailed = errors.New("unable to get coin")
Expand Down Expand Up @@ -187,11 +181,10 @@ var (
ErrCoinParseFailed,
ErrCoinImportFailed,
}
)

////////////////
/* COMPRESSOR */
////////////////

// Compressor Errors
var (
ErrLoadDictFailed = errors.New("unable to load dictionary")
ErrObjectEncodeFailed = errors.New("unable to encode object")
ErrRawCompressFailed = errors.New("unable to compress raw bytes")
Expand All @@ -215,11 +208,10 @@ var (
ErrReaderCloseFailed,
ErrCopyBlockFailed,
}
)

/////////////////
/* JOB STORAGE */
/////////////////

// Job Storage Errors
var (
ErrJobsGetAllFailed = errors.New("unable to get all jobs")
ErrJobIdentifierDecodeFailed = errors.New("unable to decode existing identifier")
ErrJobGetFailed = errors.New("unable to get job")
Expand Down Expand Up @@ -259,11 +251,10 @@ var (
ErrJobDoesNotExist,
ErrJobDecodeFailed,
}
)

/////////////////
/* KEY STORAGE */
/////////////////

// Key Storage Errors
var (
// ErrAddrExists is returned when key storage already
// contains an address.
ErrAddrExists = errors.New("address already exists")
Expand Down Expand Up @@ -306,11 +297,10 @@ var (
ErrAddrImportFailed,
ErrPrefundedAcctStoreFailed,
}
)

/////////////////////
/* BALANCE STORAGE */
/////////////////////

// Balance Storage Errors
var (
// ErrNegativeBalance is returned when an account
// balance goes negative as the result of an operation.
ErrNegativeBalance = errors.New("negative balance")
Expand Down Expand Up @@ -339,11 +329,10 @@ var (
ErrBlockNil,
ErrAccountMissing,
}
)

///////////////////
/* BLOCK STORAGE */
///////////////////

// Block Storage Errors
var (
// ErrHeadBlockNotFound is returned when there is no
// head block found in BlockStorage.
ErrHeadBlockNotFound = errors.New("head block not found")
Expand Down
4 changes: 2 additions & 2 deletions templates/client/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ func (c *Configuration) ServerUrl(index int, variables map[string]string) (strin
if !found {
return "", fmt.Errorf("The variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
}
url = strings.Replace(url, "{"+name+"}", value, -1)
url = strings.ReplaceAll(url, "{"+name+"}", value)
} else {
url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1)
url = strings.ReplaceAll(url, "{"+name+"}", variable.DefaultValue)
}
}
return url, nil
Expand Down

0 comments on commit 1e2b4a3

Please sign in to comment.