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

x/tools/go/analysis: include RelatedInformation in JSON output #64548

Closed
didebughu opened this issue Dec 5, 2023 · 9 comments
Closed

x/tools/go/analysis: include RelatedInformation in JSON output #64548

didebughu opened this issue Dec 5, 2023 · 9 comments

Comments

@didebughu
Copy link

Proposal Details

pass.Report like this

pass.Report(analysis.Diagnostic{
    Pos:     n.Pos(),
    Message: "error msg",
    Related: []analysis.RelatedInformation{{
        Pos:     n.Pos(),
        Message: "relatedinformation",
    }},
})

-json output like this

{
    "package_name": {
        "rule_name": [
            {
                "posn": "main.go:34:2",
                "message": "error msg",
                "Related": [
                    {
                        "posn": "main.go:34:2",
                        "message": "relatedinformation"
                    }
                ]
            }
        ]
    }
}
@gopherbot gopherbot added this to the Proposal milestone Dec 5, 2023
@adonovan adonovan changed the title proposal: x/tools/go/analysis: checker report output contain RelatedInformation proposal: x/tools/go/analysis: include RelatedInformation in JSON output Dec 22, 2023
@adonovan
Copy link
Member

There is very scant documentation on RelatedInformation and it isn't currently used by any of the analyzers in golang.org/x/tools, but it corresponds to the concept of the same name in the https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic, and gopls connects them.

This proposal seems reasonable to me.

@didebughu
Copy link
Author

Thank you for your attention and looking forward to it.

@rsc
Copy link
Contributor

rsc commented Jan 10, 2024

It's too bad we dont use json to write this json, but we should use a consistent casing for the names, whatever it is. The example says posn/message (lowercase) but then Related (uppercase).

@adonovan
Copy link
Member

Agreed, will make the case consistent.

@rsc
Copy link
Contributor

rsc commented Jan 10, 2024

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc
Copy link
Contributor

rsc commented Jan 19, 2024

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

Proposal is to add a new field “related” (lower case) in the JSON object describing each error:

{
    "package_name": {
        "rule_name": [
            {
                "posn": "main.go:34:2",
                "message": "error msg",
                "related": [
                    {
                        "posn": "main.go:34:2",
                        "message": "relatedinformation"
                    }
                ]
            }
        ]
    }
}

@gopherbot
Copy link

Change https://go.dev/cl/556820 mentions this issue: go/analysis/internal/analysisflags: add RelatedInformation JSON

@didebughu
Copy link
Author

Nice!Waiting for release

@rsc
Copy link
Contributor

rsc commented Jan 26, 2024

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

Proposal is to add a new field “related” (lower case) in the JSON object describing each error:

{
    "package_name": {
        "rule_name": [
            {
                "posn": "main.go:34:2",
                "message": "error msg",
                "related": [
                    {
                        "posn": "main.go:34:2",
                        "message": "relatedinformation"
                    }
                ]
            }
        ]
    }
}

@rsc rsc changed the title proposal: x/tools/go/analysis: include RelatedInformation in JSON output x/tools/go/analysis: include RelatedInformation in JSON output Jan 26, 2024
@rsc rsc modified the milestones: Proposal, Backlog Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Accepted
Development

No branches or pull requests

4 participants