Skip to content

Add GitLab Code Quality report format to lint/breaking file annotations output #3939

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

doriable
Copy link
Member

@doriable doriable commented Jul 29, 2025

This adds gitlab-code-quality as an option to buf {lint,breaking} --error-format, e.g.

$ buf lint --error-format=gitlab-code-quality | jq .
[
  {
    "description": "Files must have a package defined.",
    "check_name": "PACKAGE_DEFINED",
    "fingerprint": "f8c457c94c905148d8a60653f612faf64f2a5a412d73a5e520e3ffceecce38b2a0602d65cda99e1f976ddb3cf36c18033bae39a27e49b4798332af33c66e8f6e",
    "location": {
      "path": "main/main.proto",
      "positions": {
        "begin": {
          "line": 1,
          "column": 1
        },
        "end": {
          "line": 1,
          "column": 1
        }
      }
    },
    "severity": "minor"
  },
  {
    "description": "Import \"google/protobuf/timestamp.proto\" is unused.",
    "check_name": "IMPORT_USED",
    "fingerprint": "2df05dc6fa275d42b75b6d944b21e8633e3ea1073ff957091020aa293711aba2635707100fef418c475e5eda8eee96c0acc980cb8ea985f3944fb83e9046f7ca",
    "location": {
      "path": "main/main.proto",
      "positions": {
        "begin": {
          "line": 5,
          "column": 1
        },
        "end": {
          "line": 5,
          "column": 47
        }
      }
    },
    "severity": "minor"
  },
  {
    "description": "Files must have a package defined.",
    "check_name": "PACKAGE_DEFINED",
    "fingerprint": "08e55d130a39cc578affe0cf1825a1acff2792e46bf98e9e7b147bc77cd19e6be59808798046548c93a87642942db7e9f88a02f8c7097ae752ea607b8116a556",
    "location": {
      "path": "test/test.proto",
      "positions": {
        "begin": {
          "line": 1,
          "column": 1
        },
        "end": {
          "line": 1,
          "column": 1
        }
      }
    },
    "severity": "minor"
  }
]

It is important to note that GitLab Code Quality report expects a single JSON array.
Based on the documentation, GitLab Code Quality report also always expects a relative
path based on the repository in the location, and if the location/path is missing, this could
result in Code Quality issues being dropped from report view. It is up to the user to ensure
that their buf {lint, breaking} invocations are configured accordingly with their repositories.
GitLab Code Quality report also always expects all fields to be present.

Fixes #3926

Copy link
Contributor

github-actions bot commented Jul 29, 2025

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedAug 5, 2025, 6:28 PM

Comment on lines +344 to +345
// Fingerprint is a unique identifier for the specific code quality violation. This maps
// to a shake256 digest of the JSON FileAnnotation.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the shake256 digest of the JSON FileAnnotation for the hash, but open to suggestions on this!

@doriable doriable requested review from emcfarlane and bufdev July 29, 2025 21:21
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

Successfully merging this pull request may close these issues.

Provide GitLab code quality output format for file annotations
2 participants