Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
chore: Replace sidetree-core-go with sidetree-go (#350)
Browse files Browse the repository at this point in the history
Also updated to Go 1.21

Signed-off-by: Bob Stasyszyn <[email protected]>
  • Loading branch information
bstasyszyn committed Oct 2, 2023
1 parent ef011d8 commit a3b96bc
Show file tree
Hide file tree
Showing 54 changed files with 1,073 additions and 409 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/vc-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 10
env:
LINT_PATH: component/vc/status
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.50.0"
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.54.2"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
Expand All @@ -32,10 +32,10 @@ jobs:
env:
UNIT_TESTS_PATH: component/vc/status
steps:
- name: Setup Go 1.20
- name: Setup Go 1.21
uses: actions/setup-go@v2
with:
go-version: '1.20'
go-version: '1.21'
id: go

- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/vdr-jwk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 10
env:
LINT_PATH: component/vdr/jwk
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.50.0"
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.54.2"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
Expand All @@ -32,10 +32,10 @@ jobs:
env:
UNIT_TESTS_PATH: component/vdr/jwk
steps:
- name: Setup Go 1.20
- name: Setup Go 1.21
uses: actions/setup-go@v2
with:
go-version: '1.20'
go-version: '1.21'
id: go

- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/vdr-longform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 10
env:
LINT_PATH: component/vdr/longform
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.50.0"
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.54.2"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
Expand All @@ -32,10 +32,10 @@ jobs:
env:
UNIT_TESTS_PATH: component/vdr/longform
steps:
- name: Setup Go 1.20
- name: Setup Go 1.21
uses: actions/setup-go@v2
with:
go-version: '1.20'
go-version: '1.21'
id: go

- uses: actions/checkout@v2
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/vdr-orb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
timeout-minutes: 10
env:
LINT_PATH: component/vdr/orb
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.50.0"
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.54.2"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
Expand All @@ -34,10 +34,10 @@ jobs:
env:
UNIT_TESTS_PATH: component/vdr/orb
steps:
- name: Setup Go 1.19
- name: Setup Go 1.21
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.21
id: go

- uses: actions/checkout@v2
Expand All @@ -57,10 +57,10 @@ jobs:
timeout-minutes: 30
runs-on: ubuntu-18.04
steps:
- name: Setup Go 1.19
- name: Setup Go 1.21
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.21
id: go

- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/vdr-sidetree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 10
env:
LINT_PATH: component/vdr/sidetree
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.50.0"
GOLANGCI_LINT_IMAGE: "golangci/golangci-lint:v1.54.2"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
Expand All @@ -32,10 +32,10 @@ jobs:
env:
UNIT_TESTS_PATH: component/vdr/sidetree
steps:
- name: Setup Go 1.20
- name: Setup Go 1.21
uses: actions/setup-go@v2
with:
go-version: '1.20'
go-version: '1.21'
id: go

- uses: actions/checkout@v2
Expand Down
193 changes: 135 additions & 58 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,84 +17,161 @@ output:
print-issued-lines: true
print-linter-name: true


linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
govet:
check-shadowing: true
gofmt:
simplify: true
goimports:
local-prefixes: github.com/hyperledger/aries-framework-go-ext
gocyclo:
min-complexity: 10
depguard:
list-type: denylist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
packages-with-error-message:
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dupl:
threshold: 500
threshold: 100
funlen:
lines: 100
statements: 50
goconst:
min-len: 3
min-len: 2
min-occurrences: 3
misspell:
# default locale is a neutral variety of English.
locale:
ignore-words: []
lll:
line-length: 120
tab-width: 1
unused:
check-exported: false
unparam:
check-exported: false
nakedret:
max-func-lines: 0
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
- opinionated
disabled-checks:
- whyNoLint # TODO enable.
funlen:
lines: 60
statements: 40
wsl:
strict-append: true
allow-assign-and-call: true
allow-multiline-assign: true
allow-case-traling-whitespace: true
allow-cuddle-declarations: false
godot:
check-all: false
gomoddirectives:
replace-local: true
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- unnamedResult
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
ignored-numbers:
- '0'
- '1'
- '2'
- '3'
ignored-functions:
- strings.SplitN

govet:
check-shadowing: true
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
machine: false # don't require //nolint instead of //nolint
explain: false # don't require //nolint // my explanation instead of just //nolint

linters:
enable-all: true
disable:
- goerr113
- paralleltest
- exhaustivestruct
- interfacer # deprecated by the author https://github.com/mvdan/interfacer#interfacer
- scopelint # deprecated by the author https://github.com/kyoh86/scopelint#obsoleted
- maligned # deprecated by the author https://github.com/mdempsky/maligned
- cyclop # TODO consider replacing gocyclo with cyclop
- ifshort # TODO enable
- wrapcheck # TODO enable
- forbidigo # TODO enable
disable-all: true
enable:
- bodyclose
- dogsled
- errcheck
- exportloopref
- funlen
- gochecknoinits
- goconst
- gocyclo
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- nakedret
- noctx
- nolintlint
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace

# don't enable:
# - asciicheck
# - scopelint
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - interfacer
# - maligned
# - nestif
# - prealloc
# - testpackage
# - revive
# - wsl
# - depguard
# - gocritic
# - goimports
# - dupl

issues:
exclude-use-default: false
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- dupl
- funlen
- gomnd
- path: /
linters:
- typecheck
- bodyclose
- dupl
- goconst
- gosec
- noctx
- wrapcheck
- lll
- gocritic
- nolintlint

- path: pkg/golinters/errcheck.go
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
text: "SA1019: e.cfg.Run.Deadline is deprecated: Deadline exists for historical compatibility and should not be used."

- path: pkg/golinters/gofumpt.go
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."
- path: pkg/golinters/staticcheck_common.go
text: "SA1019: settings.GoVersion is deprecated: use the global `run.go` instead."
- path: pkg/lint/lintersdb/manager.go
text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead."

exclude:
- \`config\` is a global variable
- Line contains TODO/BUG/FIXME
# Add comments for package
- at least one file in a package should have a package comment
# Allow package logger variables (for now)
- logger is a global variable
6 changes: 3 additions & 3 deletions component/storage/mysql/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (s *store) Put(key string, value []byte, tags ...storage.Tag) error {
}

// create upsert query to insert the record, checking whether the key is already mapped to a value in the store.
insertStmt := "INSERT INTO " + s.tableName + " VALUES (?, ?) ON DUPLICATE KEY UPDATE value=?"
insertStmt := "INSERT INTO " + s.tableName + " VALUES (?, ?) ON DUPLICATE KEY UPDATE value=?" //nolint:gosec
// executing the prepared insert statement
_, err = s.db.Exec(insertStmt, key, entryBytes, entryBytes)
if err != nil {
Expand Down Expand Up @@ -371,7 +371,7 @@ func (s *store) Delete(k string) error {
}

// delete query to delete the record by key
_, err := s.db.Exec("DELETE FROM "+s.tableName+" WHERE `key`= ?", k)
_, err := s.db.Exec("DELETE FROM "+s.tableName+" WHERE `key`= ?", k) //nolint:gosec
if err != nil {
return fmt.Errorf(storage.ErrDataNotFound.Error(), err)
}
Expand All @@ -394,7 +394,7 @@ func (s *store) Delete(k string) error {
// Executing a single multi-statement query requires O(N) space for the query string and an additional
// slice with O(2*N) space holding the values for the query. Callers should take care of this additional
// memory usage by limiting the size of the batch.
func (s *store) Batch(batch []storage.Operation) error { // nolint:gocyclo
func (s *store) Batch(batch []storage.Operation) error {
if len(batch) == 0 {
return errors.New("batch requires at least one operation")
}
Expand Down
2 changes: 1 addition & 1 deletion component/storage/postgresql/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ func testProviderAndStoreNotImplemented(t *testing.T, provider spi.Provider) {
require.EqualError(t, err, "not implemented")
}

func verifyExpectedIterator(t *testing.T, actualResultsItr spi.Iterator, // nolint:gocyclo // Test file
func verifyExpectedIterator(t *testing.T, actualResultsItr spi.Iterator,
expectedKeys []string, expectedValues [][]byte) {
t.Helper()

Expand Down
1 change: 1 addition & 0 deletions component/vc/status/.custom_golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ linters:
- wrapcheck # TODO enable
- forbidigo # TODO enable
- typecheck
- depguard

issues:
exclude-use-default: false
Expand Down
2 changes: 1 addition & 1 deletion component/vc/status/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: Apache-2.0
module github.com/hyperledger/aries-framework-go-ext/component/vc/status

go 1.20
go 1.21

require (
github.com/google/uuid v1.3.0
Expand Down
Loading

0 comments on commit a3b96bc

Please sign in to comment.