Skip to content

x/tools/gopls: Reports for redundant type conversion #58568

Open

Description

Problem
Sometimes you can miss redundant type conversion in your code.

var ids []int32
for _, groups := range groupsCollection {
    if len(groups) > 0 {
        ids = append(ids, int32(groups[0])) // groups[0] is already int32  so there is unnecessary conversion
    }
}

Solution
Could you add warnings about unnecessary type conversion as it is done in goland

Activity

  1. transferred this issue fromgolang/vscode-goon Feb 16, 2023
  2. changed the title [-]Reports for redundant type conversion[/-] [+]x/tools/gopls: Reports for redundant type conversion[/+] on Feb 16, 2023
  3. added
    FeatureRequestIssues asking for a new feature that does not need a proposal.
    on Feb 16, 2023
  4. added this to the gopls/later milestone on Feb 16, 2023
  5. added
    ToolsThis label describes issues relating to any tools in the x/tools repository.
    goplsIssues related to the Go language server, gopls.
    on Feb 16, 2023
  6. findleyr commented on Jul 27, 2023

    @findleyr
    Contributor

    See also dominikh/go-tools#936.

    The concern expressed there remains: if gopls is only considering a single set of build tags, this analyzer may produce false positives.

    I wonder how problematic those false positives would be. I also wonder how hard it would be to eliminate false positives by avoiding cases that could be affected by build tags.

    CC @dominikh @mdempsky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions