Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Repository ruleset rule type `code_quality` is not modelled

未关闭
#4,520 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@etifontaine 已经在做这个了。

开始于 2026年9月4日。

评估

这个 Issue 还没有评估数据。

描述

Summary

The repository ruleset rule type code_quality is not modelled by RepositoryRule / the ruleset rule types, so it cannot be read or written through this library. It corresponds to the "Require code quality results" checkbox on a branch ruleset, which reached general availability on 2026-07-20.

API shape

GET /repos/{owner}/{repo}/rulesets/{id} returns it as a rule alongside the existing types:

{
  "id": 16352232,
  "name": "Project branch",
  "target": "branch",
  "enforcement": "active",
  "rules": [
    { "type": "code_quality", "parameters": { "severity": "errors" } },
    { "type": "copilot_code_review", "parameters": { "review_on_push": true, "review_draft_pull_requests": false } }
  ]
}

severity is the lowest severity level at which code quality results block a merge. I have only observed "errors" on the wire, so the full accepted set is worth confirming against the docs before fixing an enum — note the existing code_scanning rule's security_alerts_threshold already uses "errors" / "errors_and_warnings" style values in rules.go, which may or may not be the same vocabulary here.

Why it matters beyond a missing field

PUT /repos/{owner}/{repo}/rulesets/{id} replaces the entire rules array. Because the rule cannot be represented, any consumer that round-trips a ruleset — read, modify one unrelated attribute, write back — will silently drop code_quality and remove a merge gate, with nothing in the request or response to indicate it happened.

That is not hypothetical. integrations/terraform-provider-github builds its github_repository_ruleset resource on this library, and a ruleset carrying this rule imports cleanly, plans cleanly, and would lose the rule on the first apply that touched any other attribute of the resource. We ended up dropping the affected ruleset from Terraform management entirely rather than hold that risk. Modelling the type here unblocks the provider side (there is no provider-side workaround, since there is nothing to serialise).

Environment
  • go-github: absent as of current mastergithub/rules.go models copilot_code_review, required_code_scanning, required_status_checks et al., and contains no occurrence of code_quality or CodeQuality
  • Observed against: GitHub.com, private repository in an organisation on the Team plan
Willing to contribute

Happy to open a PR adding the rule type if a maintainer confirms the preferred shape — in particular whether severity should be a plain string or a typed constant set.

主要语言
Go
星标
11.3k
派生
2.5k
平均合并
1 天 16 小时
30 天内合并 PR
51

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

google/go-github 的其他 Issue

查看 google/go-github 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。