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
linter: support lll to avoid too long line #42718
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/retest |
1b1c341
to
451474b
Compare
760fd9f
to
cf7a5ce
Compare
/retest |
"golang.org/x/tools/go/analysis" | ||
) | ||
|
||
const lllName = "lll" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the meaning of lll?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lll
is from https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/lll.go
.
build/linter/lll/analyzer.go
Outdated
} | ||
|
||
for _, i := range lintIssues { | ||
pass.Reportf(pass.Files[idx].Pos(), "%s:%d too long", i.Filename, i.Line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idx comes from fileNames, but fileNames is less than pass.Files because we don't count failpoint files. Please use correct idx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
continue | ||
} | ||
|
||
if strings.HasPrefix(line, "import") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use related position of ast.File.Imports to skip import part
"dumpling/export": "ignore export code", | ||
"ddl/placement/": "ignore placement code" | ||
}, | ||
"only_files": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it only for these directories? If the left work is for following PRs, this one should not close the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much problem is in the TiDB repo so I have to enable the part to avoid producing more problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Then it should ref #42570 instead of closing it.
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
/merge |
This pull request has been accepted and is ready to merge. Commit hash: d82d5f9
|
/retest |
3 similar comments
/retest |
/retest |
/retest |
/test all |
/retest |
@hawkingrei: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: close #42570
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.