From b1501f4b1713b006cc6780f3732509762f57bc63 Mon Sep 17 00:00:00 2001 From: Vinay Shankar Shukla Date: Thu, 1 Apr 2021 14:05:36 +0530 Subject: [PATCH] Fix params type for step ref request. (#1858) * Fix params type for step ref request. Signed-off-by: BugDiver * Bump release version Signed-off-by: Zabil Cheriya Maliackal * Upgrade golangci lint version Signed-off-by: Zabil Cheriya Maliackal * Fix lint issues Signed-off-by: Zabil Cheriya Maliackal * Add the right import statement Signed-off-by: Zabil Cheriya Maliackal * Upgrade libraries Signed-off-by: Zabil Cheriya Maliackal Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Zabil Cheriya Maliackal --- .github/workflows/golangci-lint.yml | 4 ++-- api/lang/diagnostics.go | 2 +- api/lang/references.go | 4 ++-- api/lang/references_test.go | 2 +- cmd/run.go | 5 +---- execution/merge.go | 4 +++- execution/result/specResult.go | 4 ++-- gauge/protoConverters.go | 2 +- go.sum | 5 +++++ logger/logger_test.go | 2 +- parser/dataTableSpecs.go | 2 +- runner/grpcRunner.go | 2 +- validation/validate.go | 4 ++-- validation/validation_test.go | 4 ++-- version/version.go | 2 +- 15 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 384bedebe..391b14f25 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -17,7 +17,7 @@ jobs: uses: golangci/golangci-lint-action@v2 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.29 + version: v1.39 # Optional: working directory, useful for monorepos # working-directory: somedir @@ -26,4 +26,4 @@ jobs: args: --disable=staticcheck # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true \ No newline at end of file + # only-new-issues: true diff --git a/api/lang/diagnostics.go b/api/lang/diagnostics.go index 55b08ce00..16f9ffa69 100644 --- a/api/lang/diagnostics.go +++ b/api/lang/diagnostics.go @@ -127,7 +127,7 @@ func validateConcepts(diagnostics map[lsp.DocumentURI][]lsp.Diagnostic) (*gauge. return nil, fmt.Errorf("unable to read file %s", err) } cpts, pRes := new(parser.ConceptParser).Parse(content, conceptFile) - pErrs, err := parser.AddConcept(cpts, conceptFile, conceptDictionary) + pErrs, err := parser.AddConcept(cpts, conceptFile, conceptDictionary) // nolint if err != nil { return nil, err } diff --git a/api/lang/references.go b/api/lang/references.go index 83e221d14..58a363915 100644 --- a/api/lang/references.go +++ b/api/lang/references.go @@ -17,11 +17,11 @@ import ( ) func stepReferences(req *jsonrpc2.Request) (interface{}, error) { - var params string + var params []string if err := json.Unmarshal(*req.Params, ¶ms); err != nil { return nil, fmt.Errorf("failed to parse request %v", err) } - return getLocationFor(params) + return getLocationFor(params[0]) } func stepValueAt(req *jsonrpc2.Request) (interface{}, error) { diff --git a/api/lang/references_test.go b/api/lang/references_test.go index 90ca9f359..a402a594f 100644 --- a/api/lang/references_test.go +++ b/api/lang/references_test.go @@ -33,7 +33,7 @@ Scenario Heading openFilesCache = &files{cache: make(map[lsp.DocumentURI][]string)} openFilesCache.add(uri, specText) - b, _ := json.Marshal("Say {} to {}") + b, _ := json.Marshal([]string{"Say {} to {}"}) params := json.RawMessage(b) want := []lsp.Location{ {URI: uri, Range: lsp.Range{ diff --git a/cmd/run.go b/cmd/run.go index b2eca64d1..829693c78 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -10,11 +10,8 @@ import ( "fmt" "os" "strconv" - - "github.com/getgauge/gauge/gauge" - "strings" - + gauge "github.com/getgauge/gauge/gauge" "github.com/getgauge/gauge/config" "github.com/getgauge/gauge/env" "github.com/getgauge/gauge/execution" diff --git a/execution/merge.go b/execution/merge.go index 65b031fab..9b628ce0d 100644 --- a/execution/merge.go +++ b/execution/merge.go @@ -81,7 +81,9 @@ func mergeResults(results []*result.SpecResult) *result.SpecResult { if res.GetFailed() { specResult.IsFailed = true } - var tableRows []*m.ProtoTableRow + + var tableRows []*m.ProtoTableRow // nolint + for _, item := range res.ProtoSpec.Items { switch item.ItemType { case m.ProtoItem_Scenario: diff --git a/execution/result/specResult.go b/execution/result/specResult.go index 014c2c6ef..0e3f03fbc 100644 --- a/execution/result/specResult.go +++ b/execution/result/specResult.go @@ -55,7 +55,7 @@ func (specResult *SpecResult) AddTableDrivenScenarioResult(r *ScenarioResult, t specResult.ScenarioFailedCount++ } specResult.AddExecTime(r.ExecTime()) - pItem := &gauge_messages.ProtoItem{ + pItem := &gauge_messages.ProtoItem{ // nolint ItemType: gauge_messages.ProtoItem_TableDrivenScenario, TableDrivenScenario: &gauge_messages.ProtoTableDrivenScenario{ Scenario: r.Item().(*gauge_messages.ProtoScenario), @@ -88,7 +88,7 @@ func (specResult *SpecResult) AddTableRelatedScenarioResult(scenarioResults [][] TableRowIndex: int32(index), ScenarioTableRow: eachRow[scenarioIndex].(*ScenarioResult).ScenarioDataTableRow, } - protoItem := &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_TableDrivenScenario, TableDrivenScenario: protoTableDrivenScenario} + protoItem := &gauge_messages.ProtoItem{ItemType: gauge_messages.ProtoItem_TableDrivenScenario, TableDrivenScenario: protoTableDrivenScenario} // nolint specResult.ProtoSpec.Items = append(specResult.ProtoSpec.Items, protoItem) } if scenarioFailed { diff --git a/gauge/protoConverters.go b/gauge/protoConverters.go index aface8314..118a5b6fb 100644 --- a/gauge/protoConverters.go +++ b/gauge/protoConverters.go @@ -154,7 +154,7 @@ func ConvertToProtoTable(table *Table) *gauge_messages.ProtoTable { } protoTableParam := &gauge_messages.ProtoTable{Rows: make([]*gauge_messages.ProtoTableRow, 0)} protoTableParam.Headers = &gauge_messages.ProtoTableRow{Cells: table.Headers} - for _, row := range table.Rows() { + for _, row := range table.Rows() { // nolint protoTableParam.Rows = append(protoTableParam.Rows, &gauge_messages.ProtoTableRow{Cells: row}) } return protoTableParam diff --git a/go.sum b/go.sum index 34674482e..6f0601fdd 100644 --- a/go.sum +++ b/go.sum @@ -129,6 +129,7 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -150,6 +151,7 @@ github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY= github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= @@ -209,6 +211,7 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= +github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -346,6 +349,7 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.34.1 h1:ugq+9++ZQPFzM2pKUMCIK8gj9M0pFyuUWO9Q8kwEDQw= google.golang.org/grpc v1.34.1/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.0 h1:o1bcQ6imQMIOpdrO3SWf2z5RV72WbDwdXuK0MDlc8As= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -373,6 +377,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/logger/logger_test.go b/logger/logger_test.go index 44fd64e18..c54ecb7b6 100644 --- a/logger/logger_test.go +++ b/logger/logger_test.go @@ -17,7 +17,7 @@ import ( "github.com/getgauge/gauge/config" "github.com/getgauge/gauge/plugin/pluginInfo" "github.com/getgauge/gauge/version" - "github.com/op/go-logging" + logging "github.com/op/go-logging" ) func TestGetLoggerShouldGetTheLoggerForGivenModule(t *testing.T) { diff --git a/parser/dataTableSpecs.go b/parser/dataTableSpecs.go index 8d1567c9c..515e51ab6 100644 --- a/parser/dataTableSpecs.go +++ b/parser/dataTableSpecs.go @@ -24,7 +24,7 @@ func GetSpecsForDataTableRows(s []*gauge.Specification, errMap *gauge.BuildError if len(tableRelatedScenarios) > 0 { s := createSpecsForTableRows(spec, tableRelatedScenarios, errMap) s[0].Scenarios = append(s[0].Scenarios, nonTableRelatedScenarios...) - for _, scn := range nonTableRelatedScenarios { + for _, scn := range nonTableRelatedScenarios { // nolint s[0].Items = append(s[0].Items, scn) } specs = append(specs, s...) diff --git a/runner/grpcRunner.go b/runner/grpcRunner.go index 0ec6733a1..1c183e630 100644 --- a/runner/grpcRunner.go +++ b/runner/grpcRunner.go @@ -20,7 +20,7 @@ import ( "github.com/getgauge/gauge/config" "github.com/getgauge/gauge/logger" "github.com/getgauge/gauge/manifest" - "google.golang.org/genproto/googleapis/rpc/errdetails" + errdetails "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/validation/validate.go b/validation/validate.go index 4102d0279..82ef0139f 100644 --- a/validation/validate.go +++ b/validation/validate.go @@ -219,7 +219,7 @@ func fillScenarioErrors(scenario *gauge.Scenario, errMap *gauge.BuildErrors, ste if step.IsConcept { fillScenarioErrors(scenario, errMap, step.ConceptSteps) } - if err, ok := errMap.StepErrs[step]; ok { + if err, ok := errMap.StepErrs[step]; ok { // nolint errMap.ScenarioErrs[scenario] = append(errMap.ScenarioErrs[scenario], err) } } @@ -230,7 +230,7 @@ func fillSpecErrors(spec *gauge.Specification, errMap *gauge.BuildErrors, steps if context.IsConcept { fillSpecErrors(spec, errMap, context.ConceptSteps) } - if err, ok := errMap.StepErrs[context]; ok { + if err, ok := errMap.StepErrs[context]; ok { // nolint errMap.SpecErrs[spec] = append(errMap.SpecErrs[spec], err) for _, scenario := range spec.Scenarios { if _, ok := errMap.ScenarioErrs[scenario]; !ok { diff --git a/validation/validation_test.go b/validation/validation_test.go index 8abe9c94d..3c7d15270 100644 --- a/validation/validation_test.go +++ b/validation/validation_test.go @@ -41,7 +41,7 @@ Scenario 2 ` p := new(parser.SpecParser) spec, _, _ := p.Parse(specText, gauge.NewConceptDictionary(), "") - err := gauge_messages.StepValidateResponse_STEP_IMPLEMENTATION_NOT_FOUND + err := gauge_messages.StepValidateResponse_STEP_IMPLEMENTATION_NOT_FOUND // nolint errs := validationErrors{spec: []error{ NewStepValidationError(spec.Scenarios[0].Steps[0], "", "", &err, ""), NewStepValidationError(spec.Scenarios[1].Steps[0], "", "", &err, ""), @@ -67,7 +67,7 @@ Scenario 2 ` p := new(parser.SpecParser) spec, _, _ := p.Parse(specText, gauge.NewConceptDictionary(), "") - err := gauge_messages.StepValidateResponse_STEP_IMPLEMENTATION_NOT_FOUND + err := gauge_messages.StepValidateResponse_STEP_IMPLEMENTATION_NOT_FOUND // nolint errs := validationErrors{spec: []error{ NewStepValidationError(spec.Scenarios[0].Steps[0], "", "", &err, ""), diff --git a/version/version.go b/version/version.go index b120f1970..03846fe9e 100644 --- a/version/version.go +++ b/version/version.go @@ -14,7 +14,7 @@ import ( ) // CurrentGaugeVersion represents the current version of Gauge -var CurrentGaugeVersion = &Version{1, 1, 7} +var CurrentGaugeVersion = &Version{1, 1, 8} // BuildMetadata represents build information of current release (e.g, nightly build information) var BuildMetadata = ""