Skip to content

Commit

Permalink
upgrade to 1.19, new lint version too
Browse files Browse the repository at this point in the history
  • Loading branch information
darcys22 committed Sep 26, 2022
1 parent 4192cf6 commit c9c62d7
Show file tree
Hide file tree
Showing 35 changed files with 90 additions and 153 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false # dont' want one scenario failing to deprive us of feedback on the others
matrix:
go-version: [1.14.x, 1.15.x]
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false # dont' want one scenario failing to deprive us of feedback on the others
matrix:
go-version: [1.14.x, 1.15.x]
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: true
matrix:
go-version: [1.15.x]
go-version: [1.19.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
environment: "PPA Signing Environment"
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
strategy:
fail-fast: true
matrix:
go-version: [1.15.x]
go-version: [1.19.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
environment: "PPA Signing Environment"
Expand Down
22 changes: 17 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file configures github.com/golangci/golangci-lint.

run:
timeout: 3m
timeout: 20m
tests: true
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
Expand All @@ -10,17 +10,29 @@ run:
linters:
disable-all: true
enable:
- deadcode
- goconst
- goimports
- gosimple
- govet
- ineffassign
- misspell
# - staticcheck
- unconvert
# - unused
- varcheck
- typecheck
- unused
- staticcheck
- bidichk
- durationcheck
- exportloopref
- whitespace

# - structcheck # lots of false positives
# - errcheck #lot of false positives
# - contextcheck
# - errchkjson # lots of false positives
# - errorlint # this check crashes
# - exhaustive # silly check
# - makezero # false positives
# - nilerr # several intentional

linters-settings:
gofmt:
Expand Down
19 changes: 11 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
module github.com/darcys22/godbledger

go 1.15
go 1.19

require (
github.com/BurntSushi/toml v0.3.1
github.com/Songmu/retry v0.1.0
github.com/cespare/cp v1.1.1
github.com/go-sql-driver/mysql v1.6.0
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.1.0 // indirect
github.com/joyt/godate v0.0.0-20150226210126-7151572574a7
github.com/marcmak/calc v0.0.0-20150509200512-5bbbfc3b3149
github.com/mattn/go-colorable v0.1.8
github.com/mattn/go-sqlite3 v1.14.7
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/olekukonko/tablewriter v0.0.5
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.17.0 // indirect
github.com/pkg/errors v0.9.1
github.com/rs/xid v1.3.0
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.5.1
github.com/urfave/cli/v2 v2.3.0
github.com/x-cray/logrus-prefixed-formatter v0.5.2
golang.org/x/net v0.0.0-20210610132358-84b48f89b13b // indirect
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 // indirect
golang.org/x/text v0.3.7
google.golang.org/genproto v0.0.0-20210611144927-798beca9d670 // indirect
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.26.0
)

require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.17.0 // indirect
golang.org/x/net v0.0.0-20210610132358-84b48f89b13b // indirect
golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 // indirect
google.golang.org/genproto v0.0.0-20210611144927-798beca9d670 // indirect
)
4 changes: 0 additions & 4 deletions godbledger/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"bytes"
//"fmt"
"os"
"path/filepath"

Expand Down Expand Up @@ -65,7 +64,6 @@ var (
)

func MakeConfig(cli *cli.Context) (error, *LedgerConfig) {

config := defaultLedgerConfig
//set logrus verbosity
level, err := logrus.ParseLevel(config.LogVerbosity)
Expand Down Expand Up @@ -136,7 +134,6 @@ func InitConfig(config *LedgerConfig) error {

// dumpConfig is the dumpconfig command.
func dumpConfig(ctx *cli.Context) error {

err, cfg := MakeConfig(ctx)
if err != nil {
log.Fatalf("Could not open the config file: %v", err)
Expand Down Expand Up @@ -165,7 +162,6 @@ func dumpConfig(ctx *cli.Context) error {

// genConfig generates a default config file for godbledger.
func genConfig(ctx *cli.Context) error {

config := defaultLedgerConfig
if ctx.Bool("mysql") {
config.DatabaseType = "mysql"
Expand Down
1 change: 0 additions & 1 deletion godbledger/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ var (
)

func setConfig(ctx *cli.Context, cfg *LedgerConfig) {

if ctx.IsSet(VerbosityFlag.Name) {
cfg.LogVerbosity = ctx.String(VerbosityFlag.Name)
}
Expand Down
3 changes: 0 additions & 3 deletions godbledger/core/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func NewUser(name string) (*User, error) {

usr := &User{guid.String(), name}
return usr, nil

}

type Currency struct {
Expand All @@ -26,10 +25,8 @@ type Currency struct {
}

func NewCurrency(name string, decimals int) (*Currency, error) {

cur := &Currency{name, decimals}
return cur, nil

}

type Account struct {
Expand Down
1 change: 0 additions & 1 deletion godbledger/core/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ func TestTransaction(t *testing.T) {
assert.Equal(t, reversedTxn.Splits[0].Accounts[0].Name, "cash")
assert.Equal(t, reversedTxn.Splits[1].Amount, amountDR)
assert.Equal(t, reversedTxn.Splits[1].Accounts[0].Name, "income")

}
1 change: 0 additions & 1 deletion godbledger/db/mysqldb/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
)

func TestValidateConnectionString(t *testing.T) {

//Test Regular string with no params
validatedString, err := ValidateConnectionString("godbledger:password@tcp(192.168.1.98:3306)/ledger")
assert.Nil(t, err)
Expand Down
2 changes: 0 additions & 2 deletions godbledger/db/mysqldb/mysqldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func (db *Database) Close() error {
}

func ValidateConnectionString(dsn string) (string, error) {

if dsn == "" {
return "", errors.New("Connection string not provided")
}
Expand Down Expand Up @@ -275,7 +274,6 @@ func (db *Database) InitDB() error {

// ClearDB drops all tables
func (db *Database) ClearDB() error {

//DROP TABLES
dropDB := `
DROP DATABASE ledger;
Expand Down
18 changes: 0 additions & 18 deletions godbledger/db/mysqldb/mysqlfuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,12 @@ func (db *Database) FindTransaction(txnID string) (*core.Transaction, error) {
split.Accounts = append(split.Accounts, &account)
split.Currency = &cur
resp.Splits = append(resp.Splits, &split)

}

return &resp, nil
}

func (db *Database) DeleteTransaction(txnID string) error {

sqlStatement := `
DELETE FROM transactions
WHERE transaction_id = ?;`
Expand Down Expand Up @@ -464,11 +462,9 @@ func (db *Database) AddTagToAccount(accountID string, tag int) error {
tx.Commit()

return nil

}

func (db *Database) DeleteTagFromAccount(account, tag string) error {

tagID, err := db.FindTag(tag)
if err != nil {
return err
Expand Down Expand Up @@ -539,11 +535,9 @@ func (db *Database) AddTagToTransaction(txnID string, tag int) error {
err = tx.Commit()

return err

}

func (db *Database) DeleteTagFromTransaction(txnID, tag string) error {

tagID, err := db.FindTag(tag)
if err != nil {
return err
Expand Down Expand Up @@ -612,7 +606,6 @@ func (db *Database) SafeAddCurrency(cur *core.Currency) error {
}

func (db *Database) DeleteCurrency(currency string) error {

sqlStatement := `
DELETE FROM currencies
WHERE name = ?;`
Expand Down Expand Up @@ -663,18 +656,15 @@ func (db *Database) AddAccount(acc *core.Account) error {
return err
}

//Returns True if account was created
func (db *Database) SafeAddAccount(acc *core.Account) (bool, error) {
u, _ := db.FindAccount(strings.TrimSpace(acc.Code))
if u != nil {
return false, nil
}
return true, db.AddAccount(acc)

}

func (db *Database) DeleteAccount(account string) error {

sqlStatement := `
DELETE FROM accounts
WHERE
Expand Down Expand Up @@ -733,7 +723,6 @@ func (db *Database) SafeAddUser(usr *core.User) error {
return nil
}
return db.AddUser(usr)

}

func (db *Database) TestDB() error {
Expand Down Expand Up @@ -781,7 +770,6 @@ func (db *Database) TestDB() error {
}

func (db *Database) GetTB(queryDate time.Time) (*[]core.TBAccount, error) {

queryDB := `
SELECT split_accounts.account_id,
Sum(splits.amount),
Expand Down Expand Up @@ -845,20 +833,16 @@ func (db *Database) GetTB(queryDate time.Time) (*[]core.TBAccount, error) {
}
accounts[index].Tags = append(accounts[index].Tags, tag)
}

}

return &accounts, nil

}

func (db *Database) Query(query string, args ...interface{}) (*sql.Rows, error) {
return db.DB.Query(query, args...)

}

func (db *Database) ReconcileTransactions(reconciliationID string, splitIDs []string) (string, error) {

tx, err := db.DB.Begin()

if err != nil {
Expand Down Expand Up @@ -939,7 +923,6 @@ func (db *Database) ReconcileTransactions(reconciliationID string, splitIDs []st
}

func (db *Database) GetListing(startDate, endDate time.Time) (*[]core.Transaction, error) {

var txns []core.Transaction

log.Debugf("Searching Transactions in DB between %s & %s", startDate.Format("2006-01-02"), endDate.Format("2006-01-02"))
Expand Down Expand Up @@ -1010,7 +993,6 @@ func (db *Database) GetListing(startDate, endDate time.Time) (*[]core.Transactio
split.Accounts = append(split.Accounts, &account)
split.Currency = &cur
t.Splits = append(t.Splits, &split)

}
if len(t.Splits) > 0 {
txns = append(txns, t)
Expand Down
1 change: 0 additions & 1 deletion godbledger/db/sqlite3db/sqlite3db.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func NewDB(dirPath, mode string) (*Database, error) {
db := &Database{DB: SqliteDB, DatabasePath: dirPath, Mode: mode}

return db, err

}

func (db *Database) InitDB() error {
Expand Down
Loading

0 comments on commit c9c62d7

Please sign in to comment.