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

Please add an option to disable warnings from simplifycompositelit #227

Closed
rajatsing opened this issue Jun 16, 2020 · 8 comments
Closed
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@rajatsing
Copy link

If you have a question, please ask it on the #vscode or #vscode-go channels in Gophers Slack](https://invite.slack.golangbridge.org/messages/vscode).

Is your feature request related to a problem? Please describe.
I keep on getting warnings like this redundant type from array, slice, or map composite literal simplifycompositelit.

image

I don't know how to disable this warning.

Describe the solution you'd like
Please write a feature so that I can disable the warnings like above from the VScode's settings.json.

Describe alternatives you've considered
There is no fix to this problem AFAIK.

Additional context
There is no issue in the code's logic or any other error whatsoever. These warnings are pretty distracting.

@hyangah
Copy link
Contributor

hyangah commented Jun 16, 2020

@rajatsingh25aug Please share your go related settings.

If you are using the Go language server ("go.useLanguageServer": true), specific analysis can be turned off like the followings.

"gopls": {
   "analyses": {
      "simplifycompositelit": false, 
   }
}

See https://github.com/golang/tools/blob/master/gopls/doc/settings.md#analyses-mapstringbool
(also note the settings syntax may change in the future)

Even though I hope the default set of diagnostics can help writing more readable code,
if you think that's too distracting, you can completely turn off any diagnostics

    "go.languageServerExperimentalFeatures": {
        "diagnostics": false
    }

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 16, 2020
@rajatsing
Copy link
Author

@hyangah My settings.json looks like this.

{
    "go.useLanguageServer": true,
    "go.buildOnSave": "package",
    "go.lintFlags": ["--disable=all"],
    "terminal.integrated.fontFamily": "Source Code Pro for Powerline",
    "files.trimTrailingWhitespace": true,
    "files.insertFinalNewline": true,
    "files.trimFinalNewlines": true,
    "markdown.extension.toc.unorderedList.marker": "*",
    "markdown.extension.toc.levels": "2..2",
    "workbench.iconTheme": "eq-material-theme-icons-darker",
    "workbench.colorTheme": "Winter is Coming (Dark Black - No Italics)",
    "window.zoomLevel": 2,
    "python.jediEnabled": false,
    "workbench.editor.showTabs": true,
}

@hyangah
Copy link
Contributor

hyangah commented Jun 16, 2020

Thanks @rajatsingh25aug for sharing the settings.

You are using the language server ("go.useLanguageServer": true), so the settings change I described in my previous comment will do what you want.

We plan to improve the discoverability of the settings. (#197)

@hyangah hyangah closed this as completed Jun 16, 2020
@stamblerre
Copy link
Contributor

Just to add one more note here - you can configure your editor to automatically fix all of those errors on save by adding the following to your settings:

"[go]": {
	"editor.codeActionsOnSave": {
		"source.fixAll": true,
	}
}

@rajatsing
Copy link
Author

@hyangah The settings that you provided didn't work. :/

image

Am I doing something wrong?.

@hyangah hyangah reopened this Jun 18, 2020
@hyangah
Copy link
Contributor

hyangah commented Jun 18, 2020

@rajatsingh25aug That "unknown configuration setting" error is fine - that's working as intended and gopls will process it. We didn't promote the gopls section as a recognized setting yet because gopls is still in alpha.

Is the settings.json file saved?

From my quick testing, it should work.

Before:
Screen Shot 2020-06-18 at 7 02 36 AM

After:
Screen Shot 2020-06-18 at 7 02 01 AM

@rajatsing
Copy link
Author

rajatsing commented Jun 18, 2020

@hyangah So I have applied the settings again and restarted the vscode again. Killed all the running process related to vscode from the background and it worked. 💯

I was facing this issue for a long time. Thank you for being so prompt for helping out. 👍

@hyangah
Copy link
Contributor

hyangah commented Jun 18, 2020

@rajatsingh25aug good to hear that the problem solved.

Ideally gopls should pick up the new configuration automatically and the vscode restart shouldn't be necessary. If not, I hope the future release should handle this better.

Enjoy Go programming!

@hyangah hyangah closed this as completed Jun 18, 2020
@golang golang locked and limited conversation to collaborators Jun 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants