Commit 733f2b06 by Carl Bergquist Committed by GitHub

Merge pull request #14012 from mjtrangoni/fix-megacheck-issues

Fix last megacheck issues
parents 0e7b6dcf a2275e8a
...@@ -85,12 +85,13 @@ jobs: ...@@ -85,12 +85,13 @@ jobs:
- run: 'go get -u github.com/tsenart/deadcode' - run: 'go get -u github.com/tsenart/deadcode'
- run: 'go get -u github.com/jgautheron/goconst/cmd/goconst' - run: 'go get -u github.com/jgautheron/goconst/cmd/goconst'
- run: 'go get -u github.com/gordonklaus/ineffassign' - run: 'go get -u github.com/gordonklaus/ineffassign'
- run: 'go get -u honnef.co/go/tools/cmd/megacheck'
- run: 'go get -u github.com/opennota/check/cmd/structcheck' - run: 'go get -u github.com/opennota/check/cmd/structcheck'
- run: 'go get -u github.com/mdempsky/unconvert' - run: 'go get -u github.com/mdempsky/unconvert'
- run: 'go get -u github.com/opennota/check/cmd/varcheck' - run: 'go get -u github.com/opennota/check/cmd/varcheck'
- run: - run:
name: run linters name: run linters
command: 'gometalinter --enable-gc --vendor --deadline 10m --disable-all --enable=deadcode --enable=goconst --enable=ineffassign --enable=structcheck --enable=unconvert --enable=varcheck ./...' command: 'gometalinter --enable-gc --vendor --deadline 10m --disable-all --enable=deadcode --enable=goconst --enable=ineffassign --enable=megacheck --enable=structcheck --enable=unconvert --enable=varcheck ./...'
- run: - run:
name: run go vet name: run go vet
command: 'go vet ./pkg/...' command: 'go vet ./pkg/...'
......
...@@ -96,16 +96,15 @@ func (e *InfluxDBExecutor) Query(ctx context.Context, dsInfo *models.DataSource, ...@@ -96,16 +96,15 @@ func (e *InfluxDBExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
} }
func (e *InfluxDBExecutor) getQuery(dsInfo *models.DataSource, queries []*tsdb.Query, context *tsdb.TsdbQuery) (*Query, error) { func (e *InfluxDBExecutor) getQuery(dsInfo *models.DataSource, queries []*tsdb.Query, context *tsdb.TsdbQuery) (*Query, error) {
for _, v := range queries { // The model supports multiple queries, but right now this is only used from
// alerting so we only needed to support batch executing 1 query at a time.
query, err := e.QueryParser.Parse(v.Model, dsInfo) if len(queries) > 0 {
query, err := e.QueryParser.Parse(queries[0].Model, dsInfo)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return query, nil return query, nil
} }
return nil, fmt.Errorf("query request contains no queries") return nil, fmt.Errorf("query request contains no queries")
} }
......
...@@ -3,19 +3,20 @@ package main ...@@ -3,19 +3,20 @@ package main
import "testing" import "testing"
func TestPreparingReleaseFromRemote(t *testing.T) { func TestPreparingReleaseFromRemote(t *testing.T) {
var builder releaseBuilder
versionIn := "v5.2.0-beta1" versionIn := "v5.2.0-beta1"
expectedVersion := "5.2.0-beta1" expectedVersion := "5.2.0-beta1"
whatsNewUrl := "https://whatsnews.foo/" whatsNewUrl := "https://whatsnews.foo/"
relNotesUrl := "https://relnotes.foo/" relNotesUrl := "https://relnotes.foo/"
expectedArch := "amd64" expectedArch := "amd64"
expectedOs := "linux" expectedOs := "linux"
buildArtifacts := []buildArtifact{{expectedOs,expectedArch, ".linux-amd64.tar.gz"}} buildArtifacts := []buildArtifact{{expectedOs, expectedArch, ".linux-amd64.tar.gz"}}
var builder releaseBuilder
builder = releaseFromExternalContent{ builder = releaseFromExternalContent{
getter: mockHttpGetter{}, getter: mockHttpGetter{},
rawVersion: versionIn, rawVersion: versionIn,
artifactConfigurations: buildArtifactConfigurations, artifactConfigurations: buildArtifactConfigurations,
} }
...@@ -50,7 +51,6 @@ func (mockHttpGetter) getContents(url string) (string, error) { ...@@ -50,7 +51,6 @@ func (mockHttpGetter) getContents(url string) (string, error) {
return url, nil return url, nil
} }
func TestPreparingReleaseFromLocal(t *testing.T) { func TestPreparingReleaseFromLocal(t *testing.T) {
whatsNewUrl := "https://whatsnews.foo/" whatsNewUrl := "https://whatsnews.foo/"
relNotesUrl := "https://relnotes.foo/" relNotesUrl := "https://relnotes.foo/"
...@@ -60,7 +60,7 @@ func TestPreparingReleaseFromLocal(t *testing.T) { ...@@ -60,7 +60,7 @@ func TestPreparingReleaseFromLocal(t *testing.T) {
var builder releaseBuilder var builder releaseBuilder
testDataPath := "testdata" testDataPath := "testdata"
builder = releaseLocalSources{ builder = releaseLocalSources{
path: testDataPath, path: testDataPath,
artifactConfigurations: buildArtifactConfigurations, artifactConfigurations: buildArtifactConfigurations,
} }
...@@ -93,7 +93,7 @@ func TestPreparingReleaseFromLocal(t *testing.T) { ...@@ -93,7 +93,7 @@ func TestPreparingReleaseFromLocal(t *testing.T) {
expectedOs := "win" expectedOs := "win"
builder = releaseLocalSources{ builder = releaseLocalSources{
path: testDataPath, path: testDataPath,
artifactConfigurations: []buildArtifact{{ artifactConfigurations: []buildArtifact{{
os: expectedOs, os: expectedOs,
arch: expectedArch, arch: expectedArch,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment