Repository: google/go-github
Pull request #3331 (2024-10-21 16:52:29)

feat!: Rename code scanning params from plural to singular
BREAKING CHANGE: Rename `RuleRequiredCodeScanningTools` to `RuleRequiredCodeScanningTool`.

Some improvements for #3256

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3331?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 93.01%. Comparing base [(`2b8c7fa`)](https://app.codecov.io/gh/google/go-github/commit/2b8c7fa86fcd1cb4a89a44c8e7b5a49fe4be8a45?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`2f478d2`)](https://app.codecov.io/gh/google/go-github/commit/2f478d27952994608f0269c19faea70ceb3776ce?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> Report is 157 commits behind head on master.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #3331      +/-   ##
==========================================
- Coverage   97.72%   93.01%   -4.71%     
==========================================
  Files         153      172      +19     
  Lines       13390    14848    +1458     
==========================================
+ Hits        13085    13811     +726     
- Misses        215      944     +729     
- Partials       90       93       +3     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3331?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

ihor-hrytskiv: @air-hand Could you review please?
gmlewis: Thank you, @air-hand !
Merging.

Patch:
diff --git a/github/repos_rules.go b/github/repos_rules.go
index bb8aa121..07e8afad 100644
--- a/github/repos_rules.go
+++ b/github/repos_rules.go
@@ -159,8 +159,8 @@ type RequiredWorkflowsRuleParameters struct {
 	RequiredWorkflows    []*RuleRequiredWorkflow `json:"workflows"`
 }
 
-// RuleRequiredCodeScanningTools represents the RequiredCodeScanningTools for the RequiredCodeScanningParameters object.
-type RuleRequiredCodeScanningTools struct {
+// RuleRequiredCodeScanningTool represents a single required code-scanning tool for the RequiredCodeScanningParameters object.
+type RuleRequiredCodeScanningTool struct {
 	AlertsThreshold         string `json:"alerts_threshold"`
 	SecurityAlertsThreshold string `json:"security_alerts_threshold"`
 	Tool                    string `json:"tool"`
@@ -168,7 +168,7 @@ type RuleRequiredCodeScanningTools struct {
 
 // RequiredCodeScanningRuleParameters represents the code_scanning rule parameters.
 type RequiredCodeScanningRuleParameters struct {
-	RequiredCodeScanningTools []*RuleRequiredCodeScanningTools `json:"code_scanning_tools"`
+	RequiredCodeScanningTools []*RuleRequiredCodeScanningTool `json:"code_scanning_tools"`
 }
 
 // RepositoryRule represents a GitHub Rule.


Test patch:
diff --git a/github/orgs_rules_test.go b/github/orgs_rules_test.go
index 353705fe..ac391dae 100644
--- a/github/orgs_rules_test.go
+++ b/github/orgs_rules_test.go
@@ -301,7 +301,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T)
 				Pattern:  "github",
 			}),
 			NewRequiredCodeScanningRule(&RequiredCodeScanningRuleParameters{
-				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTools{
+				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTool{
 					{
 						Tool:                    "CodeQL",
 						SecurityAlertsThreshold: "high_or_higher",
@@ -396,7 +396,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T)
 				Pattern:  "github",
 			}),
 			NewRequiredCodeScanningRule(&RequiredCodeScanningRuleParameters{
-				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTools{
+				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTool{
 					{
 						Tool:                    "CodeQL",
 						SecurityAlertsThreshold: "high_or_higher",
@@ -660,7 +660,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoProperty(t *testing.
 				Pattern:  "github",
 			}),
 			NewRequiredCodeScanningRule(&RequiredCodeScanningRuleParameters{
-				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTools{
+				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTool{
 					{
 						Tool:                    "CodeQL",
 						SecurityAlertsThreshold: "high_or_higher",
@@ -762,7 +762,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoProperty(t *testing.
 				Pattern:  "github",
 			}),
 			NewRequiredCodeScanningRule(&RequiredCodeScanningRuleParameters{
-				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTools{
+				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTool{
 					{
 						Tool:                    "CodeQL",
 						SecurityAlertsThreshold: "high_or_higher",
@@ -1009,7 +1009,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) {
 				Pattern:  "github",
 			}),
 			NewRequiredCodeScanningRule(&RequiredCodeScanningRuleParameters{
-				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTools{
+				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTool{
 					{
 						Tool:                    "CodeQL",
 						SecurityAlertsThreshold: "high_or_higher",
@@ -1102,7 +1102,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) {
 				Pattern:  "github",
 			}),
 			NewRequiredCodeScanningRule(&RequiredCodeScanningRuleParameters{
-				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTools{
+				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTool{
 					{
 						Tool:                    "CodeQL",
 						SecurityAlertsThreshold: "high_or_higher",
diff --git a/github/repos_rules_test.go b/github/repos_rules_test.go
index 4af486aa..3f7f6721 100644
--- a/github/repos_rules_test.go
+++ b/github/repos_rules_test.go
@@ -316,7 +316,7 @@ func TestRepositoryRule_UnmarshalJSON(t *testing.T) {
 		"Valid Required code_scanning params": {
 			data: `{"type":"code_scanning","parameters":{"code_scanning_tools":[{"tool": "CodeQL", "security_alerts_threshold": "high_or_higher", "alerts_threshold": "errors"}]}}`,
 			want: NewRequiredCodeScanningRule(&RequiredCodeScanningRuleParameters{
-				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTools{
+				RequiredCodeScanningTools: []*RuleRequiredCodeScanningTool{
 					{
 						Tool:                    "CodeQL",
 						SecurityAlertsThreshold: "high_or_higher",