From 20dd4b74015e98b5821f2a0a0c9d067982733694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 17:02:15 -0700 Subject: [PATCH 01/11] add golangci-lint --- .github/workflows/ci.yml | 32 +++++++++++++++----- .golangci.yml | 39 +++++++++++++++++++++++++ Makefile | 63 ---------------------------------------- 3 files changed, 63 insertions(+), 71 deletions(-) create mode 100644 .golangci.yml delete mode 100644 Makefile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89298a57..0f161488 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,9 +57,11 @@ jobs: restore-keys: | ${{ runner.os }}-go- - name: Test - run: make test-test + working-directory: test + run: make test - name: Check tidy - run: make check-tidy-test + working-directory: test + run: make check-tidy test-lint: needs: paths-filter @@ -80,9 +82,11 @@ jobs: restore-keys: | ${{ runner.os }}-go- - name: Test - run: make test-lint + working-directory: lint + run: make test - name: Check tidy - run: make check-tidy-lint + working-directory: lint + run: make check-tidy test-languageserver: needs: paths-filter @@ -111,9 +115,11 @@ jobs: working-directory: languageserver run: make build - name: Test - run: make test-languageserver + working-directory: languageserver + run: make test - name: Check tidy - run: make check-tidy-languageserver + working-directory: languageserver + run: make check-tidy test-docgen: needs: paths-filter @@ -136,9 +142,11 @@ jobs: restore-keys: | ${{ runner.os }}-go- - name: Test - run: make test-docgen + working-directory: docgen + run: make test - name: Check tidy - run: make check-tidy-docgen + working-directory: docgen + run: make check-tidy lint: name: Lint @@ -158,3 +166,11 @@ jobs: ${{ runner.os }}-go- - name: Check license headers run: make check-headers + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.54 + args: -v + # https://github.com/golangci/golangci-lint-action/issues/244 + skip-cache: true diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..c57668f9 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,39 @@ +linters: + disable-all: true + enable: + - govet + - gosimple + - errcheck + - staticcheck + - ineffassign + - typecheck + - misspell + - unused + - exportloopref + - gocritic + - gofmt + - goimports + - unconvert + - nilerr + - forbidigo + - bidichk + - asciicheck + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + +linters-settings: + gocritic: + disabled-checks: + - ifElseChain # style + - singleCaseSwitch # style + - unslice # false positives + - commentFormatting # does not detect commented out code + - exitAfterDefer + goimports: + local-prefixes: github.com/onflow/cadence-tools + forbidigo: + forbid: + - '^maps.Keys.*(# has indeterminate order\.)?$' + - '^maps.Values.*(# has indeterminate order\.)?$' diff --git a/Makefile b/Makefile deleted file mode 100644 index fabe8aec..00000000 --- a/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -.PHONY: test -test: test-test test-lint test-languageserver test-docgen - -.PHONY: test-test -test-test: - (cd ./test && make test && cd -) - -.PHONY: test-lint -test-lint: - (cd ./lint && make test && cd -) - -.PHONY: test-languageserver -test-languageserver: - (cd ./languageserver && make test && cd -) - -.PHONY: test-docgen -test-docgen: - (cd ./docgen && make test && cd -) - -.PHONY: generate -generate: generate-lint generate-test generate-languageserver generate-docgen - -.PHONY: generate-lint -generate-lint: - (cd ./lint && make generate && cd -) - -.PHONY: generate-test -generate-test: - (cd ./test && make generate && cd -) - -.PHONY: generate-languageserver -generate-languageserver: - (cd ./languageserver && make generate && cd -) - -.PHONY: generate-docgen -generate-docgen: - (cd ./docgen && make generate && cd -) - -.PHONY: check-headers -check-headers: - (cd ./lint && make check-headers && cd -) - (cd ./test && make check-headers && cd -) - (cd ./languageserver && make check-headers && cd -) - (cd ./docgen && make check-headers && cd -) - -.PHONY: check-tidy -check-tidy: check-tidy-lint check-tidy-test check-tidy-languageserver check-tidy-docgen - -.PHONY: check-tidy-lint -check-tidy-lint: generate-lint - (cd ./lint && make check-tidy && cd -) - -.PHONY: check-tidy-test -check-tidy-test: generate-test - (cd ./test && make check-tidy && cd -) - -.PHONY: check-tidy-languageserver -check-tidy-languageserver: generate-languageserver - (cd ./languageserver && make check-tidy && cd -) - -.PHONY: check-tidy-docgen -check-tidy-docgen: generate-docgen - (cd ./docgen && make check-tidy && cd -) From ff0ae6383ce017190dc4380c6711715ba9d86c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:06:35 -0700 Subject: [PATCH 02/11] add separate jobs --- .github/workflows/ci.yml | 77 ++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f161488..43b26cf6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ on: env: GO_VERSION: '1.22' + GOLANGCI_LINT_VERSION: 'v1.54' jobs: paths-filter: @@ -63,6 +64,22 @@ jobs: working-directory: test run: make check-tidy + lint-test: + needs: paths-filter + if: ${{ needs.paths-filter.outputs.test == 'true' }} + name: Lint (Test Framework) + runs-on: ubuntu-20.04 + steps: + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + working-directory: test + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: ${{ env.GOLANGCI_LINT_VERSION }} + args: -v + # https://github.com/golangci/golangci-lint-action/issues/244 + skip-cache: true + test-lint: needs: paths-filter if: ${{ needs.paths-filter.outputs.lint == 'true' }} @@ -88,6 +105,22 @@ jobs: working-directory: lint run: make check-tidy + lint-lint: + needs: paths-filter + if: ${{ needs.paths-filter.outputs.lint == 'true' }} + name: Lint (Lint) + runs-on: ubuntu-20.04 + steps: + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + working-directory: lint + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: ${{ env.GOLANGCI_LINT_VERSION }} + args: -v + # https://github.com/golangci/golangci-lint-action/issues/244 + skip-cache: true + test-languageserver: needs: paths-filter if: ${{ needs.paths-filter.outputs.languageserver == 'true' }} @@ -121,6 +154,22 @@ jobs: working-directory: languageserver run: make check-tidy + lint-languageserver: + needs: paths-filter + if: ${{ needs.paths-filter.outputs.languageserver == 'true' }} + name: Lint (Language Server) + runs-on: ubuntu-20.04 + steps: + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + working-directory: languageserver + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: ${{ env.GOLANGCI_LINT_VERSION }} + args: -v + # https://github.com/golangci/golangci-lint-action/issues/244 + skip-cache: true + test-docgen: needs: paths-filter if: ${{ needs.paths-filter.outputs.docgen == 'true' }} @@ -148,8 +197,24 @@ jobs: working-directory: docgen run: make check-tidy - lint: - name: Lint + lint-docgen: + needs: paths-filter + if: ${{ needs.paths-filter.outputs.docgen == 'true' }} + name: Lint (Docgen) + runs-on: ubuntu-20.04 + steps: + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + working-directory: docgen + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: ${{ env.GOLANGCI_LINT_VERSION }} + args: -v + # https://github.com/golangci/golangci-lint-action/issues/244 + skip-cache: true + + check-license-headers: + name: Check license headers runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 @@ -166,11 +231,3 @@ jobs: ${{ runner.os }}-go- - name: Check license headers run: make check-headers - - name: Run golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.54 - args: -v - # https://github.com/golangci/golangci-lint-action/issues/244 - skip-cache: true From c725d9614b89f8358c1c5e596457b00557471742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:07:28 -0700 Subject: [PATCH 03/11] temporary disable path filters --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43b26cf6..8650ed23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: lint-test: needs: paths-filter - if: ${{ needs.paths-filter.outputs.test == 'true' }} + # TODO: if: ${{ needs.paths-filter.outputs.test == 'true' }} name: Lint (Test Framework) runs-on: ubuntu-20.04 steps: @@ -107,7 +107,7 @@ jobs: lint-lint: needs: paths-filter - if: ${{ needs.paths-filter.outputs.lint == 'true' }} + # TODO: if: ${{ needs.paths-filter.outputs.lint == 'true' }} name: Lint (Lint) runs-on: ubuntu-20.04 steps: @@ -156,7 +156,7 @@ jobs: lint-languageserver: needs: paths-filter - if: ${{ needs.paths-filter.outputs.languageserver == 'true' }} + # TODO: if: ${{ needs.paths-filter.outputs.languageserver == 'true' }} name: Lint (Language Server) runs-on: ubuntu-20.04 steps: @@ -199,7 +199,7 @@ jobs: lint-docgen: needs: paths-filter - if: ${{ needs.paths-filter.outputs.docgen == 'true' }} + # TODO: if: ${{ needs.paths-filter.outputs.docgen == 'true' }} name: Lint (Docgen) runs-on: ubuntu-20.04 steps: From f304a8436896247576fd4f3d5fe1d77584e161dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:13:28 -0700 Subject: [PATCH 04/11] fetch --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8650ed23..7b2b62b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,9 @@ jobs: name: Lint (Test Framework) runs-on: ubuntu-20.04 steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 with: @@ -111,6 +114,9 @@ jobs: name: Lint (Lint) runs-on: ubuntu-20.04 steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 with: @@ -160,6 +166,9 @@ jobs: name: Lint (Language Server) runs-on: ubuntu-20.04 steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 with: @@ -203,6 +212,9 @@ jobs: name: Lint (Docgen) runs-on: ubuntu-20.04 steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 with: From 250477278562cefc5d208cdde057a2b2fe3788f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:37:39 -0700 Subject: [PATCH 05/11] update to latest version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b2b62b9..d65ad1d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ on: env: GO_VERSION: '1.22' - GOLANGCI_LINT_VERSION: 'v1.54' + GOLANGCI_LINT_VERSION: 'v1.59' jobs: paths-filter: From 2341fef11e1578031a5524124bb56d6601f3a0ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:37:55 -0700 Subject: [PATCH 06/11] non-determinism is OK in tools --- .golangci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c57668f9..90f737ff 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -33,7 +33,3 @@ linters-settings: - exitAfterDefer goimports: local-prefixes: github.com/onflow/cadence-tools - forbidigo: - forbid: - - '^maps.Keys.*(# has indeterminate order\.)?$' - - '^maps.Values.*(# has indeterminate order\.)?$' From c2465fcbd32b7207fa5b98478bdc7795651bc25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:38:25 -0700 Subject: [PATCH 07/11] lint --- docgen/cmd/main.go | 2 +- docgen/doc_generator.go | 5 +++- docgen/go.mod | 1 + docgen/go.sum | 1 + docgen/templates/markdown-templates.go | 1 - docgen/templates/templates.go | 1 - docgen/test/doc_gen_test.go | 4 ++-- languageserver/cmd/languageserver/main.go | 3 ++- languageserver/languageserver.go | 8 ++++--- languageserver/server/server.go | 29 +++++++++++++---------- languageserver/test/util.go | 2 +- lint/cadence_v1_analyzer_test.go | 2 +- lint/lint.go | 13 ++++++++-- test/dummy_test.go | 2 +- test/errors.go | 2 -- test/test_runner.go | 2 +- 16 files changed, 48 insertions(+), 30 deletions(-) diff --git a/docgen/cmd/main.go b/docgen/cmd/main.go index 578fbb95..f49347d7 100644 --- a/docgen/cmd/main.go +++ b/docgen/cmd/main.go @@ -65,5 +65,5 @@ func main() { log.Fatal(err) } - fmt.Println(fmt.Sprintf("Docs generated at: %s", outputDir)) + _, _ = fmt.Fprintf(os.Stdout, "Docs generated at: %s\n", outputDir) } diff --git a/docgen/doc_generator.go b/docgen/doc_generator.go index 29b031fe..a07f587e 100644 --- a/docgen/doc_generator.go +++ b/docgen/doc_generator.go @@ -31,6 +31,8 @@ import ( "github.com/onflow/cadence/runtime/ast" "github.com/onflow/cadence/runtime/common" "github.com/onflow/cadence/runtime/parser" + "golang.org/x/text/cases" + "golang.org/x/text/language" "github.com/onflow/cadence-tools/docgen/templates" ) @@ -316,7 +318,8 @@ func (ASTDeclarationTemplateFunctions) DeclKeywords(declaration ast.Declaration) } func (ASTDeclarationTemplateFunctions) DeclTypeTitle(declaration ast.Declaration) string { - return strings.Title(declaration.DeclarationKind().Keywords()) + return cases.Title(language.English). + String(declaration.DeclarationKind().Keywords()) } func (ASTDeclarationTemplateFunctions) GenInitializer(declaration ast.Declaration) bool { diff --git a/docgen/go.mod b/docgen/go.mod index 8f0dec19..b1be5313 100644 --- a/docgen/go.mod +++ b/docgen/go.mod @@ -5,6 +5,7 @@ go 1.18 require ( github.com/onflow/cadence v0.28.0 github.com/stretchr/testify v1.7.3 + golang.org/x/text v0.3.7 ) require ( diff --git a/docgen/go.sum b/docgen/go.sum index a496ee7b..163f67b7 100644 --- a/docgen/go.sum +++ b/docgen/go.sum @@ -37,6 +37,7 @@ go.opentelemetry.io/otel v1.8.0 h1:zcvBFizPbpa1q7FehvFiHbQwGzmPILebO0tyqIR5Djg= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/docgen/templates/markdown-templates.go b/docgen/templates/markdown-templates.go index 201b4fdc..64b79eb4 100644 --- a/docgen/templates/markdown-templates.go +++ b/docgen/templates/markdown-templates.go @@ -27,7 +27,6 @@ import ( var mdTemplateFiles embed.FS // MarkdownTemplateProvider is a provider for the markdown template files. -// type MarkdownTemplateProvider struct { } diff --git a/docgen/templates/templates.go b/docgen/templates/templates.go index 2f567666..77ac4834 100644 --- a/docgen/templates/templates.go +++ b/docgen/templates/templates.go @@ -21,7 +21,6 @@ package templates // TemplateProvider is a template provider interface that has to be // implemented by all the template providers of the document generator. // e.g: Markdown templates. -// type TemplateProvider interface { Get(templateName string) (string, error) } diff --git a/docgen/test/doc_gen_test.go b/docgen/test/doc_gen_test.go index 3f844e23..983d9075 100644 --- a/docgen/test/doc_gen_test.go +++ b/docgen/test/doc_gen_test.go @@ -126,9 +126,9 @@ func TestFunctionDocFormatting(t *testing.T) { docFiles, err := docGen.GenerateInMemory(string(content)) require.NoError(t, err) - require.Len(t, docFiles, 1) + assert.Len(t, docFiles, 1) expectedContent, err := os.ReadFile(path.Join("outputs", "sample3_output.md")) - + require.NoError(t, err) assert.Equal(t, string(expectedContent), string(docFiles["index.md"])) } diff --git a/languageserver/cmd/languageserver/main.go b/languageserver/cmd/languageserver/main.go index 0004ee32..0834c42f 100644 --- a/languageserver/cmd/languageserver/main.go +++ b/languageserver/cmd/languageserver/main.go @@ -22,8 +22,9 @@ package main import ( - "github.com/onflow/cadence-tools/languageserver" "github.com/spf13/pflag" + + "github.com/onflow/cadence-tools/languageserver" ) var enableFlowClientFlag = pflag.Bool("enable-flow-client", true, "enable Flow client functionality") diff --git a/languageserver/languageserver.go b/languageserver/languageserver.go index 21bc0df4..80da6c69 100644 --- a/languageserver/languageserver.go +++ b/languageserver/languageserver.go @@ -22,6 +22,7 @@ package languageserver import ( + "fmt" "os" "github.com/mattn/go-isatty" @@ -33,9 +34,10 @@ import ( func RunWithStdio(enableFlowClient bool) { if isatty.IsTerminal(os.Stdout.Fd()) { - print( - "This program implements the Language Server Protocol for Cadence.\n" + - "Please check the documentation on how to run it.\n" + + _, _ = fmt.Fprint( + os.Stdout, + "This program implements the Language Server Protocol for Cadence.\n"+ + "Please check the documentation on how to run it.\n"+ "It does nothing in a terminal, it should be run with an editor/IDE.\n", ) os.Exit(1) diff --git a/languageserver/server/server.go b/languageserver/server/server.go index 927db431..5642547b 100644 --- a/languageserver/server/server.go +++ b/languageserver/server/server.go @@ -179,8 +179,6 @@ type Server struct { codeLensProviders []CodeLensProvider // diagnosticProviders are the functions that are used to provide diagnostics for a checker diagnosticProviders []DiagnosticProvider - // documentSymbolProviders are the functions that are used to provide information about document symbols for a checker - documentSymbolProviders []DocumentSymbolProvider // initializationOptionsHandlers are the functions that are used to handle initialization options sent by the client initializationOptionsHandlers []InitializationOptionsHandler accessCheckMode sema.AccessCheckMode @@ -1505,13 +1503,11 @@ func (s *Server) ResolveCompletionItem( return } - resolved := s.maybeResolveMember(data.URI, data.ID, result) - if resolved { + if s.maybeResolveMember(data.URI, data.ID, result) { return } - resolved = s.maybeResolveRange(data.URI, data.ID, result) - if resolved { + if s.maybeResolveRange(data.URI, data.ID, result) { return } @@ -1984,10 +1980,17 @@ func (s *Server) getDiagnosticsForParentError( return } +type sentryContextKey string + +const ( + sentryContextKeyCode sentryContextKey = "code" + sentryContextKeyLocation sentryContextKey = "location" +) + // parse the given code and returns the resultant program. func parse(code, location string, log func(*protocol.LogMessageParams)) (*ast.Program, error) { - ctx := context.WithValue(context.Background(), "code", code) - ctx = context.WithValue(ctx, "location", location) + ctx := context.WithValue(context.Background(), sentryContextKeyCode, code) + ctx = context.WithValue(ctx, sentryContextKeyLocation, location) defer sentry.RecoverWithContext(ctx) start := time.Now() @@ -2660,6 +2663,7 @@ func (s *Server) maybeAddDeclarationActionsResolver( if memberInsertionPosGetter == nil { + loop: // Find the containing function declaration, if any for i := len(stack) - 2; i > 0; i-- { element := stack[i] @@ -2667,12 +2671,12 @@ func (s *Server) maybeAddDeclarationActionsResolver( case *ast.FunctionDeclaration: position := element.EndPosition(nil) parentFunctionEndPos = &position - break + break loop case *ast.SpecialFunctionDeclaration: position := element.FunctionDeclaration.EndPosition(nil) parentFunctionEndPos = &position - break + break loop } } } @@ -3042,15 +3046,16 @@ func insertionPrefixSuffix( ) { if insertionPos.before { + loop: for offset := insertionPos.Offset - 1; offset >= insertionPos.Offset-insertionPos.Column; offset-- { switch document.Text[offset] { case ' ', '\t': continue case '{': prefix = "\n" + indentation - break + break loop default: - break + break loop } } diff --git a/languageserver/test/util.go b/languageserver/test/util.go index 73186679..7cb7d639 100644 --- a/languageserver/test/util.go +++ b/languageserver/test/util.go @@ -71,7 +71,7 @@ func SetupDebugStdout() { // Log is a helper to log to a file during debugging or development. // -// You can view logs by using the command `tail -f ./debug.log` in the root langauge server folder. +// You can view logs by using the command `tail -f ./debug.log` in the root language server folder. func Log(msg ...any) { SetupLogging() log.Println(msg...) diff --git a/lint/cadence_v1_analyzer_test.go b/lint/cadence_v1_analyzer_test.go index 18451b24..f1aeb28e 100644 --- a/lint/cadence_v1_analyzer_test.go +++ b/lint/cadence_v1_analyzer_test.go @@ -709,7 +709,7 @@ func TestCadenceV1Analyzer(t *testing.T) { t.Parallel() // Ensure that no error is reported/no panic when there is no type annotation - // I.e. does not throw when type for delcaration is inferred + // I.e. does not throw when type for declaration is inferred diagnostics := testAnalyzers(t, ` access(all) fun main() { diff --git a/lint/lint.go b/lint/lint.go index 4091887b..44f6d707 100644 --- a/lint/lint.go +++ b/lint/lint.go @@ -26,10 +26,10 @@ import ( "log" "os" "path" + "sort" "strings" "sync" - "golang.org/x/exp/maps" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -171,7 +171,16 @@ func newFlowAccess(networkName string) (*grpcAccess.Client, error) { network := networkMap[networkName] if network == "" { - return nil, fmt.Errorf("invalid network name provided, only valid %s", maps.Keys(networkMap)) + var names []string + for name := range networkMap { + names = append(names, name) + } + sort.Strings(names) + + return nil, fmt.Errorf( + "missing network name. expected one of: %s", + strings.Join(names, ","), + ) } return grpcAccess.NewClient( diff --git a/test/dummy_test.go b/test/dummy_test.go index 415f977f..7e6f32c0 100644 --- a/test/dummy_test.go +++ b/test/dummy_test.go @@ -22,4 +22,4 @@ import "github.com/btcsuite/btcd/chaincfg/chainhash" // this is added to resolve the issue with chainhash ambiguous import, // the code is not used, but it's needed to force go.mod specify and retain chainhash version // workaround for issue: https://github.com/golang/go/issues/27899 - var _ = chainhash.Hash{} \ No newline at end of file +var _ = chainhash.Hash{} diff --git a/test/errors.go b/test/errors.go index 0c5b7cc4..61acadce 100644 --- a/test/errors.go +++ b/test/errors.go @@ -21,7 +21,6 @@ package test // ImportResolverNotProvidedError is thrown if the import resolver is not // set in the TestRunner, when running tests. -// type ImportResolverNotProvidedError struct { Err error } @@ -38,7 +37,6 @@ func (e ImportResolverNotProvidedError) Error() string { // FileResolverNotProvidedError is thrown if the file resolver is not // set in the TestRunner, when running tests. -// type FileResolverNotProvidedError struct { Err error } diff --git a/test/test_runner.go b/test/test_runner.go index de531379..6fa7ed5b 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -832,7 +832,7 @@ func baseContracts() map[string]common.Address { contracts["ViewResolver"] = serviceAddress for _, addressLocation := range systemContracts { contract := addressLocation.Name - address := common.Address(addressLocation.Address) + address := addressLocation.Address contracts[contract] = address } for _, contractDescription := range commonContracts { From 7565ec8d1d3ed45fcff1632b0019b4833341f4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:43:20 -0700 Subject: [PATCH 08/11] go mod tidy --- lint/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lint/go.mod b/lint/go.mod index cf4881de..9b80678a 100644 --- a/lint/go.mod +++ b/lint/go.mod @@ -9,7 +9,6 @@ require ( github.com/onflow/cadence v1.0.0-preview.34 github.com/onflow/flow-go-sdk v1.0.0-preview.36 github.com/stretchr/testify v1.9.0 - golang.org/x/exp v0.0.0-20240119083558-1b970713d09a google.golang.org/grpc v1.63.2 ) @@ -44,6 +43,7 @@ require ( github.com/zeebo/blake3 v0.2.3 // indirect go.opentelemetry.io/otel v1.24.0 // indirect golang.org/x/crypto v0.19.0 // indirect + golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect From 1782ad91b20a085e816ca3035a5c40ac2aa4db1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:43:30 -0700 Subject: [PATCH 09/11] increase timeout --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d65ad1d0..7c09df55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,7 +79,7 @@ jobs: working-directory: test # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: ${{ env.GOLANGCI_LINT_VERSION }} - args: -v + args: -v --timeout=5m # https://github.com/golangci/golangci-lint-action/issues/244 skip-cache: true @@ -123,7 +123,7 @@ jobs: working-directory: lint # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: ${{ env.GOLANGCI_LINT_VERSION }} - args: -v + args: -v --timeout=5m # https://github.com/golangci/golangci-lint-action/issues/244 skip-cache: true @@ -175,7 +175,7 @@ jobs: working-directory: languageserver # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: ${{ env.GOLANGCI_LINT_VERSION }} - args: -v + args: -v --timeout=5m # https://github.com/golangci/golangci-lint-action/issues/244 skip-cache: true @@ -221,7 +221,7 @@ jobs: working-directory: docgen # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: ${{ env.GOLANGCI_LINT_VERSION }} - args: -v + args: -v --timeout=5m # https://github.com/golangci/golangci-lint-action/issues/244 skip-cache: true From bc8e41c1c89e6c6d1343ef9cf0457d68faedd1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:44:22 -0700 Subject: [PATCH 10/11] lint --- lint/cmd/lint/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lint/cmd/lint/main.go b/lint/cmd/lint/main.go index fe8bfe8f..d7a4d260 100644 --- a/lint/cmd/lint/main.go +++ b/lint/cmd/lint/main.go @@ -127,7 +127,10 @@ func main() { linter.AnalyzeTransaction(transactionID, network) default: - println("Nothing to do. Please provide -address, -transaction, -directory, or -csv. See -help") + _, _ = fmt.Fprintln( + os.Stdout, + "Nothing to do. Please provide -address, -transaction, -directory, or -csv. See -help", + ) } } From b0d8d8d7fe65cb977ae776e46a8026d06eac8342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 12 Jun 2024 18:46:28 -0700 Subject: [PATCH 11/11] re-enable path filters --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c09df55..d1675bc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: lint-test: needs: paths-filter - # TODO: if: ${{ needs.paths-filter.outputs.test == 'true' }} + if: ${{ needs.paths-filter.outputs.test == 'true' }} name: Lint (Test Framework) runs-on: ubuntu-20.04 steps: @@ -110,7 +110,7 @@ jobs: lint-lint: needs: paths-filter - # TODO: if: ${{ needs.paths-filter.outputs.lint == 'true' }} + if: ${{ needs.paths-filter.outputs.lint == 'true' }} name: Lint (Lint) runs-on: ubuntu-20.04 steps: @@ -162,7 +162,7 @@ jobs: lint-languageserver: needs: paths-filter - # TODO: if: ${{ needs.paths-filter.outputs.languageserver == 'true' }} + if: ${{ needs.paths-filter.outputs.languageserver == 'true' }} name: Lint (Language Server) runs-on: ubuntu-20.04 steps: @@ -208,7 +208,7 @@ jobs: lint-docgen: needs: paths-filter - # TODO: if: ${{ needs.paths-filter.outputs.docgen == 'true' }} + if: ${{ needs.paths-filter.outputs.docgen == 'true' }} name: Lint (Docgen) runs-on: ubuntu-20.04 steps: