Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: Replace Gometalinter to Golangci-lint #13405

Merged
merged 5 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,10 @@ goword:tools/bin/goword
gosec:tools/bin/gosec
tools/bin/gosec $$($(PACKAGE_DIRECTORIES))

check-static:tools/bin/gometalinter tools/bin/misspell tools/bin/ineffassign
@ # TODO: enable megacheck.
@ # TODO: gometalinter has been DEPRECATED.
@ # https://github.com/alecthomas/gometalinter/issues/590
tools/bin/gometalinter --disable-all --deadline 120s \
--enable misspell \
--enable ineffassign \
check-static: tools/bin/golangci-lint
tools/bin/golangci-lint run -v --disable-all --deadline=3m \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why changed to 3m ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, golangci-lint is faster than gometalinter.
But it cannot support like --deadline 120s , therefore I changed it to --deadline=3m .
The reason for 3m rather than 2m , beacuse I think we should give more time for the new tool.
And changed it back when it stable enough.

--enable=misspell \
--enable=ineffassign \
$$($(PACKAGE_DIRECTORIES))

check-slow:tools/bin/gometalinter tools/bin/gosec
Expand Down Expand Up @@ -277,6 +274,8 @@ tools/bin/misspell:tools/check/go.mod
tools/bin/ineffassign:tools/check/go.mod
cd tools/check; \
$(GO) build -o ../bin/ineffassign github.com/gordonklaus/ineffassign
tools/bin/golangci-lint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ./tools/bin v1.21.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the binary from this URL change? Is there any version control for tools?
If the make result depends on the tool's version, it may trouble us sometimes. @xiekeyi98

We use go.mod to control the version of other tools here:
https://github.com/pingcap/tidb/blob/master/tools/check/go.mod

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, version control for tool is at last ( v1.21.0 ).
What do you think about we should do to install it.? I use this tool: https://github.com/golangci/golangci-lint


# Usage:
#
Expand Down
2 changes: 0 additions & 2 deletions executor/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ func (e *SimpleExec) executeAlterUser(s *ast.AlterUserStmt) error {
}

func (e *SimpleExec) executeGrantRole(s *ast.GrantRoleStmt) error {
failedUsers := make([]string, 0, len(s.Users))
sessionVars := e.ctx.GetSessionVars()
for i, user := range s.Users {
if user.CurrentUser {
Expand Down Expand Up @@ -803,7 +802,6 @@ func (e *SimpleExec) executeGrantRole(s *ast.GrantRoleStmt) error {
for _, role := range s.Roles {
sql := fmt.Sprintf(`INSERT IGNORE INTO %s.%s (FROM_HOST, FROM_USER, TO_HOST, TO_USER) VALUES ('%s','%s','%s','%s')`, mysql.SystemDB, mysql.RoleEdgeTable, role.Hostname, role.Username, user.Hostname, user.Username)
if _, err := sqlExecutor.Execute(context.Background(), sql); err != nil {
failedUsers = append(failedUsers, user.String())
logutil.BgLogger().Error(fmt.Sprintf("Error occur when executing %s", sql))
if _, err := sqlExecutor.Execute(context.Background(), "rollback"); err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion server/sql_info_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ func (sh *sqlInfoFetcher) getExplainAnalyze(ctx context.Context, sql string, res
rows, err := session.ResultSetToStringSlice(ctx, sh.s, recordSets[0])
if err != nil {
terror.Log(err)
rows = nil
return
}
resultChan <- &explainAnalyzeResult{rows: rows}
Expand Down