Migrate from gometalinter.v2 to golangci-lint (#249)

* Migrate from gometalinter.v2 to golangci-lint
This commit is contained in:
Adrian Gallagher
2019-03-01 16:10:29 +11:00
committed by GitHub
parent 81852f2e01
commit 7dcb1ab553
133 changed files with 2179 additions and 2204 deletions

View File

@@ -192,7 +192,7 @@ func getInternationalBankDepositFee(amount float64) float64 {
}
// CalculateTradingFee returns fee on a currency pair
func (b *Bitstamp) CalculateTradingFee(currency string, purchasePrice float64, amount float64) float64 {
func (b *Bitstamp) CalculateTradingFee(currency string, purchasePrice, amount float64) float64 {
var fee float64
switch currency {
@@ -233,7 +233,7 @@ func (b *Bitstamp) GetTicker(currency string, hourly bool) (Ticker, error) {
// GetOrderbook Returns a JSON dictionary with "bids" and "asks". Each is a list
// of open orders and each order is represented as a list holding the price and
//the amount.
// the amount.
func (b *Bitstamp) GetOrderbook(currency string) (Orderbook, error) {
type response struct {
Timestamp int64 `json:"timestamp,string"`
@@ -415,20 +415,20 @@ func (b *Bitstamp) GetOpenOrders(currencyPair string) ([]Order, error) {
}
// GetOrderStatus returns an the status of an order by its ID
func (b *Bitstamp) GetOrderStatus(OrderID int64) (OrderStatus, error) {
func (b *Bitstamp) GetOrderStatus(orderID int64) (OrderStatus, error) {
resp := OrderStatus{}
req := url.Values{}
req.Add("id", strconv.FormatInt(OrderID, 10))
req.Add("id", strconv.FormatInt(orderID, 10))
return resp,
b.SendAuthenticatedHTTPRequest(bitstampAPIOrderStatus, false, req, &resp)
}
// CancelExistingOrder cancels order by ID
func (b *Bitstamp) CancelExistingOrder(OrderID int64) (bool, error) {
func (b *Bitstamp) CancelExistingOrder(orderID int64) (bool, error) {
result := false
var req = url.Values{}
req.Add("id", strconv.FormatInt(OrderID, 10))
req.Add("id", strconv.FormatInt(orderID, 10))
return result,
b.SendAuthenticatedHTTPRequest(bitstampAPICancelOrder, true, req, &result)
@@ -443,7 +443,7 @@ func (b *Bitstamp) CancelAllExistingOrders() (bool, error) {
}
// PlaceOrder places an order on the exchange.
func (b *Bitstamp) PlaceOrder(currencyPair string, price float64, amount float64, buy, market bool) (Order, error) {
func (b *Bitstamp) PlaceOrder(currencyPair string, price, amount float64, buy, market bool) (Order, error) {
var req = url.Values{}
req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64))
req.Add("price", strconv.FormatFloat(price, 'f', -1, 64))

View File

@@ -254,10 +254,11 @@ func TestGetOpenOrders(t *testing.T) {
func TestGetOrderStatus(t *testing.T) {
t.Parallel()
if b.APIKey == "" || b.APISecret == "" ||
b.APIKey == "Key" || b.APISecret == "Secret" {
if !areTestAPIKeysSet() {
t.Skip()
}
_, err := b.GetOrderStatus(1337)
if err == nil {
t.Error("Test Failed - GetOpenOrders() error")
@@ -284,10 +285,11 @@ func TestCancelAllExistingOrders(t *testing.T) {
func TestPlaceOrder(t *testing.T) {
t.Parallel()
if b.APIKey == "" || b.APISecret == "" ||
b.APIKey == "Key" || b.APISecret == "Secret" {
if !areTestAPIKeysSet() {
t.Skip()
}
_, err := b.PlaceOrder("btcusd", 0.01, 1, true, true)
if err == nil {
t.Error("Test Failed - PlaceOrder() error")
@@ -309,8 +311,8 @@ func TestGetWithdrawalRequests(t *testing.T) {
func TestCryptoWithdrawal(t *testing.T) {
t.Parallel()
if b.APIKey == "" || b.APISecret == "" ||
b.APIKey == "Key" || b.APISecret == "Secret" {
if !areTestAPIKeysSet() {
t.Skip()
}
@@ -340,14 +342,16 @@ func TestGetUnconfirmedBitcoinDeposits(t *testing.T) {
func TestTransferAccountBalance(t *testing.T) {
t.Parallel()
if b.APIKey == "" || b.APISecret == "" ||
b.APIKey == "Key" || b.APISecret == "Secret" {
if !areTestAPIKeysSet() {
t.Skip()
}
_, err := b.TransferAccountBalance(1, "", "", true)
if err == nil {
t.Error("Test Failed - TransferAccountBalance() error", err)
}
_, err = b.TransferAccountBalance(1, "btc", "", false)
if err == nil {
t.Error("Test Failed - TransferAccountBalance() error", err)

View File

@@ -43,8 +43,8 @@ func (b *Bitstamp) Run() {
if pairs[x].Trading != "Enabled" {
continue
}
pair := strings.Split(pairs[x].Name, "/")
currencies = append(currencies, pair[0]+pair[1])
p := strings.Split(pairs[x].Name, "/")
currencies = append(currencies, p[0]+p[1])
}
err = b.UpdateCurrencies(currencies, false, false)
if err != nil {
@@ -128,32 +128,28 @@ func (b *Bitstamp) GetAccountInfo() (exchange.AccountInfo, error) {
return response, err
}
var currencies []exchange.AccountCurrencyInfo
currencies = append(currencies, exchange.AccountCurrencyInfo{
CurrencyName: "BTC",
TotalValue: accountBalance.BTCAvailable,
Hold: accountBalance.BTCReserved,
})
currencies = append(currencies, exchange.AccountCurrencyInfo{
CurrencyName: "XRP",
TotalValue: accountBalance.XRPAvailable,
Hold: accountBalance.XRPReserved,
})
currencies = append(currencies, exchange.AccountCurrencyInfo{
CurrencyName: "USD",
TotalValue: accountBalance.USDAvailable,
Hold: accountBalance.USDReserved,
})
currencies = append(currencies, exchange.AccountCurrencyInfo{
CurrencyName: "EUR",
TotalValue: accountBalance.EURAvailable,
Hold: accountBalance.EURReserved,
})
var currencies = []exchange.AccountCurrencyInfo{
{
CurrencyName: "BTC",
TotalValue: accountBalance.BTCAvailable,
Hold: accountBalance.BTCReserved,
},
{
CurrencyName: "XRP",
TotalValue: accountBalance.XRPAvailable,
Hold: accountBalance.XRPReserved,
},
{
CurrencyName: "USD",
TotalValue: accountBalance.USDAvailable,
Hold: accountBalance.USDReserved,
},
{
CurrencyName: "EUR",
TotalValue: accountBalance.EURAvailable,
Hold: accountBalance.EURReserved,
},
}
response.Accounts = append(response.Accounts, exchange.Account{
Currencies: currencies,
})
@@ -215,7 +211,7 @@ func (b *Bitstamp) CancelOrder(order exchange.OrderCancellation) error {
func (b *Bitstamp) CancelAllOrders(_ exchange.OrderCancellation) (exchange.CancelAllOrdersResponse, error) {
isCancelAllSuccessful, err := b.CancelAllExistingOrders()
if !isCancelAllSuccessful {
err = errors.New("Cancel all failed. Bitstamp provides no further information. Check order status to verify")
err = errors.New("cancel all orders failed. Bitstamp provides no further information. Check order status to verify")
}
return exchange.CancelAllOrdersResponse{}, err
@@ -337,39 +333,42 @@ func (b *Bitstamp) GetOrderHistory(getOrdersRequest exchange.GetOrdersRequest) (
var orders []exchange.OrderDetail
for _, order := range resp {
if order.Type == 2 {
quoteCurrency := ""
baseCurrency := ""
if order.BTC > 0 {
baseCurrency = symbol.BTC
} else if order.XRP > 0 {
baseCurrency = symbol.XRP
} else {
log.Warnf("No quote currency found for OrderID '%v'", order.OrderID)
}
if order.USD > 0 {
quoteCurrency = symbol.USD
} else if order.EUR > 0 {
quoteCurrency = symbol.EUR
} else {
log.Warnf("No quote currency found for OrderID '%v'", order.OrderID)
}
var currPair pair.CurrencyPair
if quoteCurrency != "" && baseCurrency != "" {
currPair = pair.NewCurrencyPairWithDelimiter(baseCurrency, quoteCurrency, b.ConfigCurrencyPairFormat.Delimiter)
}
orderDate := time.Unix(order.Date, 0)
orders = append(orders, exchange.OrderDetail{
ID: fmt.Sprintf("%v", order.OrderID),
OrderDate: orderDate,
Exchange: b.Name,
CurrencyPair: currPair,
})
if order.Type != 2 {
continue
}
quoteCurrency := ""
baseCurrency := ""
switch {
case order.BTC > 0:
baseCurrency = symbol.BTC
case order.XRP > 0:
baseCurrency = symbol.XRP
default:
log.Warnf("no base currency found for OrderID '%v'", order.OrderID)
}
switch {
case order.USD > 0:
quoteCurrency = symbol.USD
case order.EUR > 0:
quoteCurrency = symbol.EUR
default:
log.Warnf("no quote currency found for orderID '%v'", order.OrderID)
}
var currPair pair.CurrencyPair
if quoteCurrency != "" && baseCurrency != "" {
currPair = pair.NewCurrencyPairWithDelimiter(baseCurrency, quoteCurrency, b.ConfigCurrencyPairFormat.Delimiter)
}
orderDate := time.Unix(order.Date, 0)
orders = append(orders, exchange.OrderDetail{
ID: fmt.Sprintf("%v", order.OrderID),
OrderDate: orderDate,
Exchange: b.Name,
CurrencyPair: currPair,
})
}
exchange.FilterOrdersByTickRange(&orders, getOrdersRequest.StartTicks, getOrdersRequest.EndTicks)