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

The sarif output should somehow let users know about the linter #13

Open
praiskup opened this issue Jan 31, 2023 · 5 comments
Open

The sarif output should somehow let users know about the linter #13

praiskup opened this issue Jan 31, 2023 · 5 comments

Comments

@praiskup
Copy link
Member

Experimenting with the SARIF upload, it seems that it is not obvious what tool generates the error message:
Screenshot_20230131_093911

The output from vcs-diff-lint now supports at least MYPY_ERROR, MYPY_WARNING, PYLINT_WARNING types.

@praiskup
Copy link
Member Author

@jmacku fyi

@praiskup praiskup transferred this issue from fedora-copr/vcs-diff-lint Jan 31, 2023
@praiskup
Copy link
Member Author

Nah, I meant @jamacku, sorry.

@jamacku
Copy link
Collaborator

jamacku commented Jan 31, 2023

This has to be dealt with in vcs-diff-lint itself. In Differential ShellCheck, we are using the following syntax suggested by @kdudka:

# The sed part ensures that cstools will recognize the output as being produced by ShellCheck and not GCC.
local output
output=$(shellcheck "${shellcheck_args[@]}" 2> /dev/null | sed -e 's|$| <--[shellcheck]|')

But this wouldn't be the complete solution. Ideally, we should generate SARIF so that each tool has its own section.

/cc @lzaoral

For reference, SARIF with defects detected by vcs-diff-lint:

{
    "$schema": "https://json.schemastore.org/sarif-2.1.0.json",
    "version": "2.1.0",
    "inlineExternalProperties": [
        {
            "externalizedProperties": {
                "tool": "vcs-diff-lint",
                "tool-url": "https://github.com/fedora-copr/vcs-diff-lint#readme"
            }
        }
    ],
    "runs": [
        {
            "tool": {
                "driver": {
                    "name": "vcs-diff-lint",
                    "informationUri": "https://github.com/fedora-copr/vcs-diff-lint#readme"
                }
            },
            "results": [
                {
                    "ruleId": "PYLINT_WARNING: W0402[deprecated-module]",
                    "locations": [
                        {
                            "id": 0,
                            "physicalLocation": {
                                "artifactLocation": {
                                    "uri": "mock/py/mock.py"
                                },
                                "region": {
                                    "startLine": 60
                                }
                            }
                        }
                    ],
                    "message": {
                        "text": "Deprecated module 'pipes'"
                    },
                    "codeFlows": [
                        {
                            "threadFlows": [
                                {
                                    "locations": [
                                        {
                                            "location": {
                                                "id": 0,
                                                "physicalLocation": {
                                                    "artifactLocation": {
                                                        "uri": "mock/py/mock.py"
                                                    },
                                                    "region": {
                                                        "startLine": 60
                                                    }
                                                },
                                                "message": {
                                                    "text": "Deprecated module 'pipes'"
                                                }
                                            },
                                            "nestingLevel": 0,
                                            "kinds": [
                                                "W0402[deprecated-module]"
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                {
                    "ruleId": "PYLINT_WARNING: W0611[unused-import]",
                    "locations": [
                        {
                            "id": 0,
                            "physicalLocation": {
                                "artifactLocation": {
                                    "uri": "mock/py/mock.py"
                                },
                                "region": {
                                    "startLine": 60
                                }
                            }
                        }
                    ],
                    "message": {
                        "text": "Unused import pipes"
                    },
                    "codeFlows": [
                        {
                            "threadFlows": [
                                {
                                    "locations": [
                                        {
                                            "location": {
                                                "id": 0,
                                                "physicalLocation": {
                                                    "artifactLocation": {
                                                        "uri": "mock/py/mock.py"
                                                    },
                                                    "region": {
                                                        "startLine": 60
                                                    }
                                                },
                                                "message": {
                                                    "text": "Unused import pipes"
                                                }
                                            },
                                            "nestingLevel": 0,
                                            "kinds": [
                                                "W0611[unused-import]"
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

@praiskup
Copy link
Member Author

Aha, thank you!

So there are no other useful metadata fields
we could use to affect the web-UI report appearance.
Obviously GitHub knows the ruleId string (that would be useful in
web-UI) though there might be good reason why it is not displayed.
Not sure if we can do something about this.

@jamacku
Copy link
Collaborator

jamacku commented Jan 31, 2023

The ruleId is visible once you click on Show more details in the report, but this link is visible only for members of the repository.

There is opened PR on csdiff that is adding links to documentation, but I don't know if it will be possible to use it with linters supported by vcs-diff-lint. But it's again visible only to members.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants