-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix(runner): add suggested edit text from linter in display issue text #2135
fix(runner): add suggested edit text from linter in display issue text #2135
Conversation
Hey, thank you for opening your first Pull Request ! |
Could you please show the examples of printed suggestions? |
5b7cebe
to
4519931
Compare
@ldez what do you think about this as temporary solution, it is really needed? |
4519931
to
b527a26
Compare
@ifaisalalam please also run using |
For me, it's the same idea as #1778 |
yes, but the implementation is simpler |
b527a26
to
27eaa51
Compare
@SVilgelm Output after the latest changes. |
IMO, this approach is not viable:
I'm still convinced that the real solution is to add support for SuggestedFixes (#1779) to replace the old system. I'm still working on it but, for me, it's a part of the v2. I'll need to take time to define a v2 plan. |
The tool did not print suggested edits by the linter when displaying the issues. If there is suggested edits by the linter, it should be displayed along with the issue. Closes golangci#2134
27eaa51
to
34d4b45
Compare
e437bcb
to
abc3f26
Compare
d7c4b11
to
8a08c5e
Compare
Here are the outputs from the printers. HTMLJSON{
"Issues": [
{
"FromLinter": "govet",
"Text": "fieldalignment: struct with 80 pointer bytes could be 64",
"SuggestedFixes": [
{
"Message": "Rearrange fields",
"TextEdits": [
{
"Pos": 46401357,
"End": 46401522,
"NewText": "struct {\n\tvalidator Validator\n\tfilter map[string]interface{}\n\tcontext map[string]interface{}\n\trelations map[string]Query\n\tName string\n\tfields []string\n}"
}
]
}
],
"Severity": "",
"SourceLines": [
"type query struct {"
],
"Replacement": null,
"Pos": {
"Filename": "query/query.go",
"Offset": 517,
"Line": 23,
"Column": 12
},
"ExpectNoLint": false,
"ExpectedNoLintLinter": ""
}
],
"Report": {
"Linters": [
{
"Name": "govet",
"Enabled": true,
"EnabledByDefault": true
},
{
"Name": "bodyclose"
},
{
"Name": "noctx"
},
{
"Name": "errcheck",
"Enabled": true,
"EnabledByDefault": true
},
{
"Name": "golint"
},
{
"Name": "rowserrcheck"
},
{
"Name": "staticcheck",
"Enabled": true,
"EnabledByDefault": true
},
{
"Name": "unused",
"EnabledByDefault": true
},
{
"Name": "gosimple",
"Enabled": true,
"EnabledByDefault": true
},
{
"Name": "stylecheck"
},
{
"Name": "gosec"
},
{
"Name": "structcheck",
"Enabled": true,
"EnabledByDefault": true
},
{
"Name": "varcheck",
"EnabledByDefault": true
},
{
"Name": "interfacer"
},
{
"Name": "unconvert"
},
{
"Name": "ineffassign",
"Enabled": true,
"EnabledByDefault": true
},
{
"Name": "dupl"
},
{
"Name": "goconst"
},
{
"Name": "deadcode",
"Enabled": true,
"EnabledByDefault": true
},
{
"Name": "gocyclo"
},
{
"Name": "cyclop"
},
{
"Name": "gocognit"
},
{
"Name": "typecheck",
"EnabledByDefault": true
},
{
"Name": "asciicheck"
},
{
"Name": "gofmt"
},
{
"Name": "gofumpt"
},
{
"Name": "goimports",
"Enabled": true
},
{
"Name": "goheader"
},
{
"Name": "gci"
},
{
"Name": "maligned"
},
{
"Name": "depguard"
},
{
"Name": "misspell"
},
{
"Name": "lll"
},
{
"Name": "unparam"
},
{
"Name": "dogsled"
},
{
"Name": "nakedret"
},
{
"Name": "prealloc"
},
{
"Name": "scopelint"
},
{
"Name": "gocritic"
},
{
"Name": "gochecknoinits"
},
{
"Name": "gochecknoglobals"
},
{
"Name": "godox"
},
{
"Name": "funlen"
},
{
"Name": "whitespace"
},
{
"Name": "wsl"
},
{
"Name": "goprintffuncname"
},
{
"Name": "gomnd"
},
{
"Name": "goerr113"
},
{
"Name": "gomodguard"
},
{
"Name": "godot"
},
{
"Name": "testpackage"
},
{
"Name": "nestif"
},
{
"Name": "exportloopref"
},
{
"Name": "exhaustive"
},
{
"Name": "sqlclosecheck"
},
{
"Name": "nlreturn"
},
{
"Name": "wrapcheck"
},
{
"Name": "thelper"
},
{
"Name": "tparallel"
},
{
"Name": "exhaustivestruct"
},
{
"Name": "errorlint"
},
{
"Name": "paralleltest"
},
{
"Name": "makezero"
},
{
"Name": "forbidigo"
},
{
"Name": "ifshort"
},
{
"Name": "predeclared"
},
{
"Name": "revive",
"Enabled": true
},
{
"Name": "durationcheck"
},
{
"Name": "wastedassign"
},
{
"Name": "importas"
},
{
"Name": "nilerr"
},
{
"Name": "forcetypeassert"
},
{
"Name": "gomoddirectives"
},
{
"Name": "promlinter"
},
{
"Name": "tagliatelle"
},
{
"Name": "nolintlint"
}
]
}
} TextTabJUnit XMLCodeClimate[
{
"description": "govet: fieldalignment: struct with 80 pointer bytes could be 64",
"content": "Rearrange fields\n```\nstruct {\n\tvalidator Validator\n\tfilter map[string]interface{}\n\tcontext map[string]interface{}\n\trelations map[string]Query\n\tName string\n\tfields []string\n}\n```\n",
"fingerprint": "82010A31125F82A5AD347C003E45E6D5",
"location": {
"path": "query/query.go",
"lines": {
"begin": 23
}
}
},
{
"description": "govet: fieldalignment: struct with 464 pointer bytes could be 400",
"content": "Rearrange fields\n```\nstruct {\n\tLastName string `json:\"last_name,omitempty\" type:\"field\"`\n\tFullName string `json:\"full_name,omitempty\" type:\"field\"`\n\tEmail string `json:\"email,omitempty\" type:\"field\"`\n\tDateJoined string `json:\"date_joined,omitempty\" type:\"field\"`\n\tFirstName string `json:\"first_name,omitempty\" type:\"field\"`\n\tUsername string `json:\"username,omitempty\" type:\"field\"`\n\tProfile Profile `json:\"profile\" type:\"relation\"`\n\tUserID int64 `json:\"user_id,omitempty\" type:\"field\"`\n\tID int64 `json:\"id,omitempty\" type:\"field\"`\n}\n```\n",
"fingerprint": "6CB0720E8248039688D9966B74111915",
"location": {
"path": "user/user.go",
"lines": {
"begin": 3
}
}
}
] GitHub and CheckStyle printers remain now. |
Text string | ||
FromLinter string | ||
Text string | ||
SuggestedFixes []SuggestedFix |
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.
Using custom SuggestedFix
struct because analysis.SuggestedFix.TextEdits[i].NewText
is type []byte
which is not serialized properly to JSON/XML.
Any progress on getting this in? I tested it out and it was extremely useful. |
No "visible" progress, but the support of suggested fixes is still an important topic: |
Can we at least get this fix merged with only the text printer? This will help developers fix issues in their projects when developing locally. I also think that maybe we can pass a flag via the command line or the config YAML file, and the suggestion will only be printed when this flag is enabled. |
If we merge something we have to handle it, to maintain it, add we will have to fight again when we will want to create the right thing. I still agree with myself #2135 (comment) |
no changes in two years. close it |
The tool did not print suggested edits by the linter when displaying
the issues. If there is suggested edits by the linter, it should
be displayed along with the issue.
Closes #2134