Skip to content

feat: Add code quality findings support#4330

Open
Andrei-hub11 wants to merge 1 commit into
google:masterfrom
Andrei-hub11:feat/code-quality-findings
Open

feat: Add code quality findings support#4330
Andrei-hub11 wants to merge 1 commit into
google:masterfrom
Andrei-hub11:feat/code-quality-findings

Conversation

@Andrei-hub11

Copy link
Copy Markdown

Adds support for the REST Code Quality findings endpoints in go-github.

This includes ListFindings and GetFinding on CodeQualityService, the finding data models, unit tests, generated accessors, a pagination iterator, and manual metadata entries in openapi_operations.yaml so the change stays aligned with the project's documentation and code generation patterns.

Closes: #4327

@google-cla

google-cla Bot commented Jun 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gmlewis gmlewis changed the title feat: add code quality findings support feat: Add code quality findings support Jun 25, 2026
@Andrei-hub11 Andrei-hub11 force-pushed the feat/code-quality-findings branch from 1f70f5b to 2d481e2 Compare June 25, 2026 01:45
Comment thread openapi_operations.yaml
- name: POST /hub
documentation_url: https://docs.github.com/webhooks/about-webhooks-for-repositories#pubsubhubbub
- name: GET /organizations/{organization_id}
- name: GET /repos/{owner}/{repo}/code-quality/findings

@gmlewis gmlewis Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This file should not be hand-edited, so you will need to revert the changes to this file.

I'm on my phone now, but tomorrow I can update this file in a separate PR which you can then pull into this PR so we can move forward with it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I got confused because one of the CI scripts seems to require this. Maybe I missed something.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Jun 25, 2026
@Andrei-hub11 Andrei-hub11 force-pushed the feat/code-quality-findings branch from 2d481e2 to 681fa0f Compare June 25, 2026 02:18
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (595de3d) to head (681fa0f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4330   +/-   ##
=======================================
  Coverage   97.48%   97.48%           
=======================================
  Files         193      193           
  Lines       19400    19440   +40     
=======================================
+ Hits        18912    18952   +40     
  Misses        270      270           
  Partials      218      218           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Andrei-hub11 Andrei-hub11 force-pushed the feat/code-quality-findings branch from 681fa0f to c87d53b Compare June 25, 2026 03:09
Comment thread github/code_quality.go
Comment on lines +39 to +47
type CodeQualityFinding struct {
Number *int `json:"number,omitempty"`
State *string `json:"state,omitempty"`
URL *string `json:"url,omitempty"`
Rule *CodeQualityFindingRule `json:"rule,omitempty"`
Location *CodeQualityFindingLocation `json:"location,omitempty"`
Message *CodeQualityFindingMessage `json:"message,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Must match the schema:

{
  "type": "array",
  "items": {
    "description": "Code quality finding",
    "type": "object",
    "properties": {
      "number": {
        "description": "The finding number.",
        "type": "integer"
      },
      "state": {
        "description": "State of the code quality finding.",
        "type": "string",
        "enum": [
          "open",
          "dismissed"
        ]
      },
      "url": {
        "description": "The REST API URL of the code quality finding resource.",
        "type": "string",
        "format": "uri"
      },
      "rule": {
        "description": "Code quality rule",
        "type": "object",
        "properties": {
          "id": {
            "description": "A unique identifier for the rule used to detect the finding.",
            "type": "string"
          },
          "title": {
            "description": "The name of the rule used to detect the finding.",
            "type": "string"
          },
          "description": {
            "description": "A short description of the rule used to detect the finding.",
            "type": "string"
          },
          "help": {
            "description": "A detailed description of the rule used to detect the finding.",
            "type": "string"
          },
          "severity": {
            "description": "The severity of the rule used to detect the finding.",
            "type": "string",
            "enum": [
              "error",
              "warning",
              "note",
              "none"
            ]
          },
          "category": {
            "description": "The category of the rule used to detect the finding.",
            "type": "string",
            "enum": [
              "none",
              "maintainability",
              "reliability"
            ]
          }
        },
        "required": [
          "id",
          "title",
          "description",
          "severity",
          "category"
        ]
      },
      "location": {
        "description": "Code quality file location",
        "type": "object",
        "properties": {
          "path": {
            "description": "The file path where the finding was detected.",
            "type": "string"
          },
          "start_line": {
            "description": "The line number where the finding starts.",
            "type": "integer"
          },
          "start_column": {
            "description": "The column number where the finding starts.",
            "type": "integer"
          },
          "end_line": {
            "description": "The line number where the finding ends.",
            "type": "integer"
          },
          "end_column": {
            "description": "The column number where the finding ends.",
            "type": "integer"
          }
        },
        "required": [
          "path"
        ]
      },
      "message": {
        "description": "Code quality finding message",
        "type": "object",
        "properties": {
          "text": {
            "description": "The message text of the code quality finding.",
            "type": "string"
          },
          "markdown": {
            "description": "The message text of the code quality finding in markdown format.",
            "type": "string"
          }
        },
        "required": [
          "text",
          "markdown"
        ]
      },
      "created_at": {
        "description": "The time the code quality finding was created.",
        "type": "string",
        "format": "date-time"
      }
    },
    "required": [
      "number",
      "state",
      "url",
      "rule",
      "location",
      "message"
    ]
  }
}

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

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for code quality findings

3 participants