Skip to content

Commit

Permalink
[MM-59825] Update module names for mono repo (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzei authored Jul 23, 2024
1 parent 5fc973b commit 72e7752
Show file tree
Hide file tree
Showing 18 changed files with 213 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: ${{ env.go-version }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # v4.3.0
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mattermost Go Vet

This repository contains mattermost-specific go-vet rules that are used to maintain code consistency in `mattermost-server`.
This repository contains mattermost-specific go-vet rules that are used to maintain code consistency in `mattermost`.

## Included analyzers

Expand Down
9 changes: 5 additions & 4 deletions apiAuditLogs/apiAuditLogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"

"github.com/mattermost/mattermost-govet/v2/facts"
"github.com/mattermost/mattermost-govet/v2/util"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
Expand All @@ -26,7 +27,7 @@ var Analyzer = &analysis.Analyzer{
}

func run(pass *analysis.Pass) (interface{}, error) {
if pass.Pkg.Path() != mattermostPackagePath+"api4" {
if pass.Pkg.Path() != util.API4PkgPath {
return nil, nil
}

Expand Down Expand Up @@ -68,14 +69,14 @@ func run(pass *analysis.Pass) (interface{}, error) {
return true
}

if instanceType.Type.String() == "*"+mattermostPackagePath+"audit.Record" && fun.Sel.Name == "Success" {
if instanceType.Type.String() == "*"+util.ServerModulePath+"/channels/audit.Record" && fun.Sel.Name == "Success" {
successCallFound = true
}
if instanceType.Type.String() == "*"+mattermostPackagePath+"web.Context" && (fun.Sel.Name == "LogAuditRec" || fun.Sel.Name == "LogAuditRecWithLevel") {
if instanceType.Type.String() == "*"+mattermostPackagePath+"/channels/web.Context" && (fun.Sel.Name == "LogAuditRec" || fun.Sel.Name == "LogAuditRecWithLevel") {
logCallFound = true
}

if instanceType.Type.String() == "*"+mattermostPackagePath+"web.Context" && fun.Sel.Name == "MakeAuditRecord" {
if instanceType.Type.String() == "*"+mattermostPackagePath+"/channels/web.Context" && fun.Sel.Name == "MakeAuditRecord" {
initializationFound = true
if len(n.Args) < 2 {
pass.Reportf(n.Pos(), "Invalid record initialization, expected at least 2 parameters")
Expand Down
5 changes: 3 additions & 2 deletions configtelemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import (
"reflect"
"strings"

"github.com/mattermost/mattermost-govet/v2/util"
"golang.org/x/tools/go/analysis"
)

var (
telemetryPkgPath = "github.com/mattermost/mattermost-server/v6/services/telemetry"
modelPkgPath = "github.com/mattermost/mattermost-server/v6/model"
telemetryPkgPath = util.ServerModulePath + "/platform/telemetry"
modelPkgPath = util.ModelPkgPath
)

const (
Expand Down
13 changes: 7 additions & 6 deletions errorAssertions/errorAssertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ package errorAssertions
import (
"go/ast"

"github.com/mattermost/mattermost-govet/v2/util"
"golang.org/x/tools/go/analysis"
)

const (
appErrorString = "*github.com/mattermost/mattermost-server/v6/model.AppError"
var (
appErrorType = util.AppErrType
)

var Analyzer = &analysis.Analyzer{
Expand All @@ -29,10 +30,10 @@ func run(pass *analysis.Pass) (interface{}, error) {
{"NotNil", "error", "Error"},
{"Nilf", "error", "NoErrorf"},
{"NotNilf", "error", "Errorf"},
{"Error", appErrorString, "NotNil"},
{"NoError", appErrorString, "Nil"},
{"Errorf", appErrorString, "NotNilf"},
{"NoErrorf", appErrorString, "Nilf"},
{"Error", appErrorType, "NotNil"},
{"NoError", appErrorType, "Nil"},
{"Errorf", appErrorType, "NotNilf"},
{"NoErrorf", appErrorType, "Nilf"},
}

for _, file := range pass.Files {
Expand Down
16 changes: 16 additions & 0 deletions errorAssertions/errorAssertions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

package errorAssertions

import (
"testing"

"golang.org/x/tools/go/analysis/analysistest"
)

func Test(t *testing.T) {
appErrorType = "*model.AppError"
testdata := analysistest.TestData()
analysistest.Run(t, testdata, Analyzer, "model", "assert", "errorAssertions")
}
14 changes: 14 additions & 0 deletions errorAssertions/testdata/src/assert/assert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package require

import (
"testing"
)

func Error(t *testing.T, err error, msgAndArgs ...interface{}) {}
func Errorf(t *testing.T, err error, msg string, args ...interface{}) {}
func NoError(t *testing.T, err error, msgAndArgs ...interface{}) {}
func NoErrorf(t *testing.T, err error, msg string, args ...interface{}) {}
func Nil(t *testing.T, object interface{}, msgAndArgs ...interface{}) {}
func NotNil(t *testing.T, object interface{}, msgAndArgs ...interface{}) {}
func Nilf(t *testing.T, object interface{}, msg string, args ...interface{}) {}
func NotNilf(t *testing.T, object interface{}, msg string, args ...interface{}) {}
51 changes: 51 additions & 0 deletions errorAssertions/testdata/src/errorAssertions/errorassertions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package errorAssertions

import (
"testing"

"assert"
"model"
"require"
)

func TestError(t *testing.T) {
var err error
assert.Error(t, err)
assert.Errorf(t, err, "%s", "foo")
assert.NoError(t, err)
assert.NoErrorf(t, err, "%s", "foo")
assert.Nil(t, err) // want `calling assert.Nil on error, please use assert.NoError instead`
assert.Nilf(t, err, "%s", "foo") // want `calling assert.Nilf on error, please use assert.NoErrorf instead`
assert.NotNil(t, err) // want `calling assert.NotNil on error, please use assert.Error instead`
assert.NotNilf(t, err, "%s", "foo") // want `calling assert.NotNilf on error, please use assert.Errorf instead`

require.Error(t, err)
require.Errorf(t, err, "%s", "foo")
require.NoError(t, err)
require.NoErrorf(t, err, "%s", "foo")
require.Nil(t, err) // want `calling require.Nil on error, please use require.NoError instead`
require.Nilf(t, err, "%s", "foo") // want `calling require.Nilf on error, please use require.NoErrorf instead`
require.NotNil(t, err) // want `calling require.NotNil on error, please use require.Error instead`
require.NotNilf(t, err, "%s", "foo") // want `calling require.NotNilf on error, please use require.Errorf instead`
}

func TestModelAppError(t *testing.T) {
var appErr *model.AppError
assert.Error(t, appErr) // want `calling assert.Error on \*model.AppError, please use assert.NotNil instead`
assert.Errorf(t, appErr, "%s", "foo") // want `calling assert.Errorf on \*model.AppError, please use assert.NotNilf instead`
assert.NoError(t, appErr) // want `calling assert.NoError on \*model.AppError, please use assert.Nil instead`
assert.NoErrorf(t, appErr, "%s", "foo") // want `calling assert.NoErrorf on \*model.AppError, please use assert.Nilf instead`
assert.Nil(t, appErr)
assert.Nilf(t, appErr, "%s", "foo")
assert.NotNil(t, appErr)
assert.NotNilf(t, appErr, "%s", "foo")

require.Error(t, appErr) // want `calling require.Error on \*model.AppError, please use require.NotNil instead`
require.Errorf(t, appErr, "%s", "foo") // want `calling require.Errorf on \*model.AppError, please use require.NotNilf instead`
require.NoError(t, appErr) // want `calling require.NoError on \*model.AppError, please use require.Nil instead`
require.NoErrorf(t, appErr, "%s", "foo") // want `calling require.NoErrorf on \*model.AppError, please use require.Nilf instead`
require.Nil(t, appErr)
require.Nilf(t, appErr, "%s", "foo")
require.NotNil(t, appErr)
require.NotNilf(t, appErr, "%s", "foo")
}
7 changes: 7 additions & 0 deletions errorAssertions/testdata/src/model/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package model

type AppError struct{}

func (a *AppError) Error() string {
return "an error"
}
14 changes: 14 additions & 0 deletions errorAssertions/testdata/src/require/require.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package assert

import (
"testing"
)

func Error(t *testing.T, err error, msgAndArgs ...interface{}) {}
func Errorf(t *testing.T, err error, msg string, args ...interface{}) {}
func NoError(t *testing.T, err error, msgAndArgs ...interface{}) {}
func NoErrorf(t *testing.T, err error, msg string, args ...interface{}) {}
func Nil(t *testing.T, object interface{}, msgAndArgs ...interface{}) {}
func NotNil(t *testing.T, object interface{}, msgAndArgs ...interface{}) {}
func Nilf(t *testing.T, object interface{}, msg string, args ...interface{}) {}
func NotNilf(t *testing.T, object interface{}, msg string, args ...interface{}) {}
9 changes: 3 additions & 6 deletions errorVars/errorVars.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ import (
"go/ast"
"strings"

"github.com/mattermost/mattermost-govet/v2/util"
"golang.org/x/tools/go/analysis"
)

const (
appErrorString = "*github.com/mattermost/mattermost-server/v6/model.AppError"
)

var Analyzer = &analysis.Analyzer{
Name: "errorVars",
Doc: "check for non valid type assignments to err and appErr prefixed variables",
Expand All @@ -31,12 +28,12 @@ func run(pass *analysis.Pass) (interface{}, error) {
// This is needed to extract the type name string a multi-value return type
if typeAndValue, ok := pass.TypesInfo.Types[x.Rhs[0]]; ok {
returnTypes := strings.Split(strings.Trim(typeAndValue.Type.String(), "()"), ", ")
if len(returnTypes) > idx && returnTypes[idx] == appErrorString {
if len(returnTypes) > idx && returnTypes[idx] == util.AppErrType {
pass.Reportf(x.Pos(), "assigning a *model.AppError to a `error` type variable, please create a new variable to store this value.")
}
}
} else if len(x.Rhs) == len(x.Lhs) {
if typeAndValue, ok := pass.TypesInfo.Types[x.Rhs[idx]]; ok && typeAndValue.Type.String() == appErrorString {
if typeAndValue, ok := pass.TypesInfo.Types[x.Rhs[idx]]; ok && typeAndValue.Type.String() == util.AppErrType {
pass.Reportf(x.Pos(), "assigning a *model.AppError to a `error` type variable, please create a new variable to store this value.")
}
}
Expand Down
3 changes: 2 additions & 1 deletion errorVarsName/errorVarsName.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"go/ast"
"strings"

"github.com/mattermost/mattermost-govet/v2/util"
"golang.org/x/tools/go/analysis"
)

const (
appErrorString = "*github.com/mattermost/mattermost-server/v6/model.AppError"
appErrorString = "*" + util.ModelPkgPath + ".AppError"
)

var Analyzer = &analysis.Analyzer{
Expand Down
3 changes: 2 additions & 1 deletion facts/apiHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"go/ast"
"go/types"

"github.com/mattermost/mattermost-govet/v2/util"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
Expand All @@ -26,7 +27,7 @@ var ApiHandlerFacts = &analysis.Analyzer{
}

func apiHandlers(pass *analysis.Pass) (interface{}, error) {
if pass.Pkg.Path() != "github.com/mattermost/mattermost-server/v6/api4" {
if pass.Pkg.Path() != util.API4PkgPath {
return nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ require (
github.com/getkin/kin-openapi v0.61.0
github.com/pkg/errors v0.9.1
github.com/sajari/fuzzy v1.0.0
golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f
golang.org/x/tools v0.23.0
)
67 changes: 65 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUe
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand All @@ -28,13 +30,74 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f h1:3MlESg/jvTr87F4ttA/q4B+uhe/q6qleC9/DP+IwQmY=
golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
Expand Down
11 changes: 7 additions & 4 deletions rawSql/rawSql.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ package rawSql
import (
"go/ast"
"go/token"
"strings"
"strconv"
"strings"

"github.com/mattermost/mattermost-govet/v2/util"
"golang.org/x/tools/go/analysis"
)

const sqlstorePackagePath = "github.com/mattermost/mattermost-server/v6/store/sqlstore"
const (
sqlstorePackagePath = util.ServerModulePath + "/channels/store/sqlstore"
)

var Analyzer = &analysis.Analyzer{
Name: "rawSql",
Doc: "check invalid usage of raw SQL queries instead of using the squirrel lib",
Run: run,
Doc: "check invalid usage of raw SQL queries instead of using the squirrel lib",
Run: run,
}

func run(pass *analysis.Pass) (interface{}, error) {
Expand Down
Loading

0 comments on commit 72e7752

Please sign in to comment.