Skip to content

Commit

Permalink
Revert "Update assets manager client path (#111)"
Browse files Browse the repository at this point in the history
This reverts commit 2cceecb.
  • Loading branch information
tw-daniel committed May 24, 2024
1 parent be4f370 commit 687aa17
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 226 deletions.
44 changes: 21 additions & 23 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
name: CI
name: Check

on:
push:
branches: [ master ]
pull_request:
branches:
- main

env:
CI_GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
branches: [ master ]

jobs:
unit-test:
name: Unit Tests
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.21"
- uses: actions/checkout@v3
- run: git config --global url.https://ci:$CI_GITHUB_TOKEN@github.com/.insteadOf https://github.com/
- run: make unit-tests
go-version: 1.17
id: go

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git config --global url.https://ci:$CI_GITHUB_TOKEN@github.com/.insteadOf https://github.com/
- uses: golangci/golangci-lint-action@v3
with:
version: v1.55.2
args: --timeout=5m
- name: Check out code
uses: actions/checkout@v2

- name: Get dependencies
run: go get -v -t -d ./...

- name: Unit Test
run: make test

- name: Lint
run: make lint
263 changes: 75 additions & 188 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,215 +1,102 @@
service:
golangci-lint-version: 1.38.x

run:
tests: false
modules-download-mode: readonly

linters-settings:
cyclop:
max-complexity: 20
# the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)
package-average: 0.0
skip-tests: false
dogsled:
# checks assignments with too many blank identifiers; default is 2
max-blank-identifiers: 2
dupl:
threshold: 100
errcheck:
check-type-assertions: false
check-blank: false
errorlint:
errorf: false
asserts: true
comparison: true
forbidigo:
# Forbid the following identifiers (identifiers are written using regexp):
forbid:
- ^print.*$
- 'fmt\.Print.*'
exclude_godoc_examples: true
check-type-assertions: true
check-blank: true
funlen:
lines: 60
statements: 60
gocognit:
min-complexity: 35
goconst:
min-len: 3
min-occurrences: 3
ignore-tests: true
match-constant: true
numbers: false
min: 3
max: 3
ignore-calls: true
gocritic:
# Which checks should be disabled; can't be combined with 'enabled-checks'
disabled-checks:
- regexpMust
gocyclo:
min-complexity: 20
godot:
# comments to be checked: `declarations`, `toplevel`, or `all`
scope: all
capital: false
gofmt:
# simplify code: gofmt with `-s` option
simplify: true
lines: 100
statements: 75
gofumpt:
# Select the Go version to target
lang-version: "1.21"
extra-rules: false
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/trustwallet
gomnd:
settings:
mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks:
- argument
- case
- condition
- operation
- return
- assign
ignored-numbers: 10,1000
gomoddirectives:
replace-local: false
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
includes:
- G401
- G306
- G101
gosimple:
# Select the Go version to target
go: "1.21"
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
extra-rules: true
govet:
check-shadowing: true
composites: false
ifshort:
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
# Has higher priority than max-decl-chars.
max-decl-lines: 1
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
max-decl-chars: 30
importas:
golibsGin: github:com/trustwallet/go-common/gin

lll:
# max line length
line-length: 120
tab-width: 1
enable-all: true
disable:
- fieldalignment
misspell:
locale: US
# ignore-words:
revive:
# see https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: true
severity: warning
rules:
- name: indent-error-flow
severity: warning
- name: time-naming
severity: warn
- name: errorf
severity: warn
- name: blank-imports
sevetiry: warn
# The error return parameter should be last
- name: error-return
severity: error
# Redundant if when returning an error
- name: if-return
severity: warn
# Warns when there are heading or trailing newlines in a block
- name: empty-lines
severity: error
staticcheck:
# Select the Go version to target
go: "1.21"
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
stylecheck:
# Select the Go version to target
go: "1.21"
# https://staticcheck.io/docs/options#checks
checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ]
# https://staticcheck.io/docs/options#dot_import_whitelist
dot-import-whitelist:
- fmt
# https://staticcheck.io/docs/options#initialisms
initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS" ]
# https://staticcheck.io/docs/options#http_status_code_whitelist
http-status-code-whitelist: [ "200", "400", "404", "500" ]
nolintlint:
allow-unused: false
allow-leading-space: true
gci:
local-prefixes: github.com/trustwallet
unparam:
check-exported: true
unused:
# Select the Go version to target
go: "1.21"
whitespace:
multi-if: true # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
wsl:
# See https://github.com/bombsimon/wsl/blob/master/doc/configuration.md for
# documentation of available settings
allow-assign-and-anything: false
allow-assign-and-call: true
allow-cuddle-declarations: false
allow-multiline-assign: true
allow-separated-leading-comment: false
allow-trailing-comment: false
force-case-trailing-whitespace: 0
force-err-cuddling: false
force-short-decl-cuddling: false
strict-append: true

check-exported: true
errorlint:
errorf: true
gocyclo:
min-complexity: 25
wrapcheck:
ignorePackageGlobs:
- github.com/trustwallet/*
issues:
new: false
linters:
disable-all: true
enable:
# - deadcode
# - depguard
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- asciicheck
- bodyclose
- dogsled
- dupl
- errcheck
- durationcheck
- errorlint
- exhaustive
- exportloopref
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
# - goerr113
- gofmt
- gofumpt
- goimports
# - gomnd
- goprintffuncname
- gosec
- gosimple
- ineffassign
- importas
- lll
- makezero
- misspell
- nakedret
- noctx
- nestif
- nilerr
- nlreturn
- nolintlint
- paralleltest
- prealloc
- predeclared
- revive
- rowserrcheck
- staticcheck
# - structcheck
- typecheck
- sqlclosecheck
- stylecheck
- testpackage
- thelper
- tparallel
- unconvert
- unparam
- unused
# - varcheck
- wastedassign
- whitespace
- asciicheck
- gocognit
- nestif
- testpackage

run:
timeout: 2m
issues-exit-code: 1
tests: false
skip-dirs:
- ide
- local
skip-dirs-use-default: true
modules-download-mode: readonly
allow-parallel-runners: false

output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
uniq-by-line: true
path-prefix: ""
sort-results: true
# - wrapcheck
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)

all: fmt lint test

unit-tests:
test:
@echo " > Running unit tests"
GOBIN=$(GOBIN) go test -cover -race -coverprofile=coverage.txt -covermode=atomic -v ./...

Expand Down
11 changes: 2 additions & 9 deletions client/assets-manager/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package assetsmanager

import (
"context"
"time"

"github.com/trustwallet/go-libs/client"
Expand All @@ -18,19 +17,13 @@ func InitClient(url string, errorHandler client.HttpErrorHandler) Client {
}

func (c *Client) ValidateAssetInfo(req *AssetValidationReq) (result AssetValidationResp, err error) {
request := client.NewReqBuilder().
Method("POST").
PathStatic("/api/v1/validate/asset_info").
Body(req).
WriteTo(&result).Build()

_, err = c.req.Execute(context.Background(), request)
err = c.req.Post(&result, "/v1/validate/asset_info", req)

return result, err
}

func (c *Client) GetTagValues() (result TagValuesResp, err error) {
err = c.req.GetWithCache(&result, "/api/v1/values/tags", nil, time.Hour)
err = c.req.GetWithCache(&result, "/v1/values/tags", nil, time.Hour)

return result, err
}
2 changes: 1 addition & 1 deletion file/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (p Path) defineFileType(path string) (string, *regexp.Regexp) {
func ReadLocalFileStructure(root string, filesToSkip []string) ([]string, error) {
paths := []string{"./"}

err := filepath.Walk(root, func(path string, _ os.FileInfo, err error) error {
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 687aa17

Please sign in to comment.