Repository: google/go-github
Pull request #2013 (2021-07-16 20:55:26)

Add New Github Code scanning Alert fields
This PR adds new fields to the Github Code scanning `Alert` struct to keep the client library updated with the new Github API response.
Github API: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository



codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/2013?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2013](https://codecov.io/gh/google/go-github/pull/2013?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (d9524bd) into [master](https://codecov.io/gh/google/go-github/commit/4cbd718ca8b0dc4fbab05604a92e4479c8740068?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (4cbd718) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/2013/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)](https://codecov.io/gh/google/go-github/pull/2013?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)

```diff
@@           Coverage Diff           @@
##           master    #2013   +/-   ##
=======================================
  Coverage   97.86%   97.86%           
=======================================
  Files         107      107           
  Lines        6897     6897           
=======================================
  Hits         6750     6750           
  Misses         81       81           
  Partials       66       66           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/2013?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/code-scanning.go](https://codecov.io/gh/google/go-github/pull/2013/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2NvZGUtc2Nhbm5pbmcuZ28=) | `100.00% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/2013?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/2013?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Last update [4cbd718...d9524bd](https://codecov.io/gh/google/go-github/pull/2013?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

ganeshkumarsv: @gmlewis Yes, the PR is in draft right now. Thanks a lot anyways for your review comments. I have changed the desciption of the PR to `Add deprecated alert fields` as you mentioned. will address your other comments next week.

Patch:
diff --git a/github/code-scanning.go b/github/code-scanning.go
index 8602c446..640ec899 100644
--- a/github/code-scanning.go
+++ b/github/code-scanning.go
@@ -18,9 +18,44 @@ import (
 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/
 type CodeScanningService service
 
+// Rule represents the complete details of GitHub Code Scanning alert type.
+type Rule struct {
+	ID              *string  `json:"id,omitempty"`
+	Severity        *string  `json:"severity,omitempty"`
+	Description     *string  `json:"description,omitempty"`
+	Name            *string  `json:"name,omitempty"`
+	FullDescription *string  `json:"full_description,omitempty"`
+	Tags            []string `json:"tags,omitempty"`
+	Help            *string  `json:"help,omitempty"`
+}
+
+// Location represents the exact location of the GitHub Code Scanning Alert in the scanned project.
+type Location struct {
+	Path        *string `json:"path,omitempty"`
+	StartLine   *int    `json:"start_line,omitempty"`
+	EndLine     *int    `json:"end_line,omitempty"`
+	StartColumn *int    `json:"start_column,omitempty"`
+	EndColumn   *int    `json:"end_column,omitempty"`
+}
+
+// Message is a part of MostRecentInstance struct which provides the appropriate message when any action is performed on the analysis object.
+type Message struct {
+	Text *string `json:"text,omitempty"`
+}
+
+// MostRecentInstance provides details of the most recent instance of this alert for the default branch or for the specified Git reference.
+type MostRecentInstance struct {
+	Ref             *string   `json:"ref,omitempty"`
+	AnalysisKey     *string   `json:"analysis_key,omitempty"`
+	Environment     *string   `json:"environment,omitempty"`
+	State           *string   `json:"state,omitempty"`
+	CommitSHA       *string   `json:"commit_sha,omitempty"`
+	Message         *Message  `json:"message,omitempty"`
+	Location        *Location `json:"location,omitempty"`
+	Classifications []string  `json:"classifications,omitempty"`
+}
+
 // Tool represents the tool used to generate a GitHub Code Scanning Alert.
-//
-// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository
 type Tool struct {
 	Name    *string `json:"name,omitempty"`
 	GUID    *string `json:"guid,omitempty"`
@@ -31,16 +66,22 @@ type Tool struct {
 //
 // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository
 type Alert struct {
-	RuleID          *string    `json:"rule_id,omitempty"`
-	RuleSeverity    *string    `json:"rule_severity,omitempty"`
-	RuleDescription *string    `json:"rule_description,omitempty"`
-	Tool            *Tool      `json:"tool,omitempty"`
-	CreatedAt       *Timestamp `json:"created_at,omitempty"`
-	Open            *bool      `json:"open,omitempty"`
-	ClosedBy        *User      `json:"closed_by,omitempty"`
-	ClosedAt        *Timestamp `json:"closed_at,omitempty"`
-	URL             *string    `json:"url,omitempty"`
-	HTMLURL         *string    `json:"html_url,omitempty"`
+	RuleID             *string             `json:"rule_id,omitempty"`
+	RuleSeverity       *string             `json:"rule_severity,omitempty"`
+	RuleDescription    *string             `json:"rule_description,omitempty"`
+	Rule               *Rule               `json:"rule,omitempty"`
+	Tool               *Tool               `json:"tool,omitempty"`
+	CreatedAt          *Timestamp          `json:"created_at,omitempty"`
+	Open               *bool               `json:"open,omitempty"`
+	ClosedBy           *User               `json:"closed_by,omitempty"`
+	ClosedAt           *Timestamp          `json:"closed_at,omitempty"`
+	URL                *string             `json:"url,omitempty"`
+	HTMLURL            *string             `json:"html_url,omitempty"`
+	MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"`
+	DismissedBy        *User               `json:"dismissed_by,omitempty"`
+	DismissedAt        *Timestamp          `json:"dismissed_at,omitempty"`
+	DismissedReason    *string             `json:"dismissed_reason,omitempty"`
+	InstancesURL       *string             `json:"instances_url,omitempty"`
 }
 
 // ID returns the ID associated with an alert. It is the number at the end of the security alert's URL.
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 3dcb9a4e..2d51bfdf 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -172,6 +172,30 @@ func (a *Alert) GetCreatedAt() Timestamp {
 	return *a.CreatedAt
 }
 
+// GetDismissedAt returns the DismissedAt field if it's non-nil, zero value otherwise.
+func (a *Alert) GetDismissedAt() Timestamp {
+	if a == nil || a.DismissedAt == nil {
+		return Timestamp{}
+	}
+	return *a.DismissedAt
+}
+
+// GetDismissedBy returns the DismissedBy field.
+func (a *Alert) GetDismissedBy() *User {
+	if a == nil {
+		return nil
+	}
+	return a.DismissedBy
+}
+
+// GetDismissedReason returns the DismissedReason field if it's non-nil, zero value otherwise.
+func (a *Alert) GetDismissedReason() string {
+	if a == nil || a.DismissedReason == nil {
+		return ""
+	}
+	return *a.DismissedReason
+}
+
 // GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise.
 func (a *Alert) GetHTMLURL() string {
 	if a == nil || a.HTMLURL == nil {
@@ -180,6 +204,22 @@ func (a *Alert) GetHTMLURL() string {
 	return *a.HTMLURL
 }
 
+// GetInstancesURL returns the InstancesURL field if it's non-nil, zero value otherwise.
+func (a *Alert) GetInstancesURL() string {
+	if a == nil || a.InstancesURL == nil {
+		return ""
+	}
+	return *a.InstancesURL
+}
+
+// GetMostRecentInstance returns the MostRecentInstance field.
+func (a *Alert) GetMostRecentInstance() *MostRecentInstance {
+	if a == nil {
+		return nil
+	}
+	return a.MostRecentInstance
+}
+
 // GetOpen returns the Open field if it's non-nil, zero value otherwise.
 func (a *Alert) GetOpen() bool {
 	if a == nil || a.Open == nil {
@@ -188,6 +228,14 @@ func (a *Alert) GetOpen() bool {
 	return *a.Open
 }
 
+// GetRule returns the Rule field.
+func (a *Alert) GetRule() *Rule {
+	if a == nil {
+		return nil
+	}
+	return a.Rule
+}
+
 // GetRuleDescription returns the RuleDescription field if it's non-nil, zero value otherwise.
 func (a *Alert) GetRuleDescription() string {
 	if a == nil || a.RuleDescription == nil {
@@ -7116,6 +7164,46 @@ func (l *ListRepositories) GetTotalCount() int {
 	return *l.TotalCount
 }
 
+// GetEndColumn returns the EndColumn field if it's non-nil, zero value otherwise.
+func (l *Location) GetEndColumn() int {
+	if l == nil || l.EndColumn == nil {
+		return 0
+	}
+	return *l.EndColumn
+}
+
+// GetEndLine returns the EndLine field if it's non-nil, zero value otherwise.
+func (l *Location) GetEndLine() int {
+	if l == nil || l.EndLine == nil {
+		return 0
+	}
+	return *l.EndLine
+}
+
+// GetPath returns the Path field if it's non-nil, zero value otherwise.
+func (l *Location) GetPath() string {
+	if l == nil || l.Path == nil {
+		return ""
+	}
+	return *l.Path
+}
+
+// GetStartColumn returns the StartColumn field if it's non-nil, zero value otherwise.
+func (l *Location) GetStartColumn() int {
+	if l == nil || l.StartColumn == nil {
+		return 0
+	}
+	return *l.StartColumn
+}
+
+// GetStartLine returns the StartLine field if it's non-nil, zero value otherwise.
+func (l *Location) GetStartLine() int {
+	if l == nil || l.StartLine == nil {
+		return 0
+	}
+	return *l.StartLine
+}
+
 // GetEffectiveDate returns the EffectiveDate field if it's non-nil, zero value otherwise.
 func (m *MarketplacePendingChange) GetEffectiveDate() Timestamp {
 	if m == nil || m.EffectiveDate == nil {
@@ -7564,6 +7652,14 @@ func (m *MembershipEvent) GetTeam() *Team {
 	return m.Team
 }
 
+// GetText returns the Text field if it's non-nil, zero value otherwise.
+func (m *Message) GetText() string {
+	if m == nil || m.Text == nil {
+		return ""
+	}
+	return *m.Text
+}
+
 // GetAction returns the Action field if it's non-nil, zero value otherwise.
 func (m *MetaEvent) GetAction() string {
 	if m == nil || m.Action == nil {
@@ -7892,6 +7988,62 @@ func (m *MilestoneStats) GetTotalMilestones() int {
 	return *m.TotalMilestones
 }
 
+// GetAnalysisKey returns the AnalysisKey field if it's non-nil, zero value otherwise.
+func (m *MostRecentInstance) GetAnalysisKey() string {
+	if m == nil || m.AnalysisKey == nil {
+		return ""
+	}
+	return *m.AnalysisKey
+}
+
+// GetCommitSHA returns the CommitSHA field if it's non-nil, zero value otherwise.
+func (m *MostRecentInstance) GetCommitSHA() string {
+	if m == nil || m.CommitSHA == nil {
+		return ""
+	}
+	return *m.CommitSHA
+}
+
+// GetEnvironment returns the Environment field if it's non-nil, zero value otherwise.
+func (m *MostRecentInstance) GetEnvironment() string {
+	if m == nil || m.Environment == nil {
+		return ""
+	}
+	return *m.Environment
+}
+
+// GetLocation returns the Location field.
+func (m *MostRecentInstance) GetLocation() *Location {
+	if m == nil {
+		return nil
+	}
+	return m.Location
+}
+
+// GetMessage returns the Message field.
+func (m *MostRecentInstance) GetMessage() *Message {
+	if m == nil {
+		return nil
+	}
+	return m.Message
+}
+
+// GetRef returns the Ref field if it's non-nil, zero value otherwise.
+func (m *MostRecentInstance) GetRef() string {
+	if m == nil || m.Ref == nil {
+		return ""
+	}
+	return *m.Ref
+}
+
+// GetState returns the State field if it's non-nil, zero value otherwise.
+func (m *MostRecentInstance) GetState() string {
+	if m == nil || m.State == nil {
+		return ""
+	}
+	return *m.State
+}
+
 // GetBase returns the Base field if it's non-nil, zero value otherwise.
 func (n *NewPullRequest) GetBase() string {
 	if n == nil || n.Base == nil {
@@ -14164,6 +14316,54 @@ func (r *ReviewersRequest) GetNodeID() string {
 	return *r.NodeID
 }
 
+// GetDescription returns the Description field if it's non-nil, zero value otherwise.
+func (r *Rule) GetDescription() string {
+	if r == nil || r.Description == nil {
+		return ""
+	}
+	return *r.Description
+}
+
+// GetFullDescription returns the FullDescription field if it's non-nil, zero value otherwise.
+func (r *Rule) GetFullDescription() string {
+	if r == nil || r.FullDescription == nil {
+		return ""
+	}
+	return *r.FullDescription
+}
+
+// GetHelp returns the Help field if it's non-nil, zero value otherwise.
+func (r *Rule) GetHelp() string {
+	if r == nil || r.Help == nil {
+		return ""
+	}
+	return *r.Help
+}
+
+// GetID returns the ID field if it's non-nil, zero value otherwise.
+func (r *Rule) GetID() string {
+	if r == nil || r.ID == nil {
+		return ""
+	}
+	return *r.ID
+}
+
+// GetName returns the Name field if it's non-nil, zero value otherwise.
+func (r *Rule) GetName() string {
+	if r == nil || r.Name == nil {
+		return ""
+	}
+	return *r.Name
+}
+
+// GetSeverity returns the Severity field if it's non-nil, zero value otherwise.
+func (r *Rule) GetSeverity() string {
+	if r == nil || r.Severity == nil {
+		return ""
+	}
+	return *r.Severity
+}
+
 // GetBusy returns the Busy field if it's non-nil, zero value otherwise.
 func (r *Runner) GetBusy() bool {
 	if r == nil || r.Busy == nil {


Test patch:
diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go
index efbc9bd6..7403582f 100644
--- a/github/code-scanning_test.go
+++ b/github/code-scanning_test.go
@@ -69,6 +69,32 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
 					"guid": null,
 					"version": "1.4.0"
 				},
+				"rule": {
+					"id": "js/trivial-conditional",
+					"severity": "warning",
+					"description": "Useless conditional",
+					"name": "js/trivial-conditional",
+					"full_description": "Expression has no effect",
+					"help": "Expression has no effect"
+				},
+				"most_recent_instance": {
+					"ref": "refs/heads/main",
+					"state": "open",
+					"commit_sha": "abcdefg12345",
+					"message": {
+						"text": "This path depends on a user-provided value."
+					},
+					"location": {
+						"path": "spec-main/api-session-spec.ts",
+						"start_line": 917,
+						"end_line": 917,
+						"start_column": 7,
+						"end_column": 18
+					},
+					"classifications": [
+						"test"
+					]
+				},
 				"created_at":"2020-05-06T12:00:00Z",
 				"open":true,
 				"closed_by":null,
@@ -85,6 +111,32 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
 					"guid": null,
 					"version": "1.4.0"
 				},
+				"rule": {
+					"id": "js/useless-expression",
+					"severity": "warning",
+					"description": "Expression has no effect",
+					"name": "js/useless-expression",
+					"full_description": "Expression has no effect",
+					"help": "Expression has no effect"
+				},
+				"most_recent_instance": {
+					"ref": "refs/heads/main",
+					"state": "open",
+					"commit_sha": "abcdefg12345",
+					"message": {
+						"text": "This path depends on a user-provided value."
+					},
+					"location": {
+						"path": "spec-main/api-session-spec.ts",
+						"start_line": 917,
+						"end_line": 917,
+						"start_column": 7,
+						"end_column": 18
+					},
+					"classifications": [
+						"test"
+					]
+				},
 				"created_at":"2020-05-06T12:00:00Z",
 				"open":true,
 				"closed_by":null,
@@ -108,24 +160,72 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
 			RuleSeverity:    String("warning"),
 			RuleDescription: String("Useless conditional"),
 			Tool:            &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")},
-			CreatedAt:       &date,
-			Open:            Bool(true),
-			ClosedBy:        nil,
-			ClosedAt:        nil,
-			URL:             String("https://api.github.com/repos/o/r/code-scanning/alerts/25"),
-			HTMLURL:         String("https://github.com/o/r/security/code-scanning/25"),
+			Rule: &Rule{
+				ID:              String("js/trivial-conditional"),
+				Severity:        String("warning"),
+				Description:     String("Useless conditional"),
+				Name:            String("js/trivial-conditional"),
+				FullDescription: String("Expression has no effect"),
+				Help:            String("Expression has no effect"),
+			},
+			CreatedAt: &date,
+			Open:      Bool(true),
+			ClosedBy:  nil,
+			ClosedAt:  nil,
+			URL:       String("https://api.github.com/repos/o/r/code-scanning/alerts/25"),
+			HTMLURL:   String("https://github.com/o/r/security/code-scanning/25"),
+			MostRecentInstance: &MostRecentInstance{
+				Ref:       String("refs/heads/main"),
+				State:     String("open"),
+				CommitSHA: String("abcdefg12345"),
+				Message: &Message{
+					Text: String("This path depends on a user-provided value."),
+				},
+				Location: &Location{
+					Path:        String("spec-main/api-session-spec.ts"),
+					StartLine:   Int(917),
+					EndLine:     Int(917),
+					StartColumn: Int(7),
+					EndColumn:   Int(18),
+				},
+				Classifications: []string{"test"},
+			},
 		},
 		{
 			RuleID:          String("js/useless-expression"),
 			RuleSeverity:    String("warning"),
 			RuleDescription: String("Expression has no effect"),
 			Tool:            &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")},
-			CreatedAt:       &date,
-			Open:            Bool(true),
-			ClosedBy:        nil,
-			ClosedAt:        nil,
-			URL:             String("https://api.github.com/repos/o/r/code-scanning/alerts/88"),
-			HTMLURL:         String("https://github.com/o/r/security/code-scanning/88"),
+			Rule: &Rule{
+				ID:              String("js/useless-expression"),
+				Severity:        String("warning"),
+				Description:     String("Expression has no effect"),
+				Name:            String("js/useless-expression"),
+				FullDescription: String("Expression has no effect"),
+				Help:            String("Expression has no effect"),
+			},
+			CreatedAt: &date,
+			Open:      Bool(true),
+			ClosedBy:  nil,
+			ClosedAt:  nil,
+			URL:       String("https://api.github.com/repos/o/r/code-scanning/alerts/88"),
+			HTMLURL:   String("https://github.com/o/r/security/code-scanning/88"),
+			MostRecentInstance: &MostRecentInstance{
+				Ref:       String("refs/heads/main"),
+				State:     String("open"),
+				CommitSHA: String("abcdefg12345"),
+				Message: &Message{
+					Text: String("This path depends on a user-provided value."),
+				},
+				Location: &Location{
+					Path:        String("spec-main/api-session-spec.ts"),
+					StartLine:   Int(917),
+					EndLine:     Int(917),
+					StartColumn: Int(7),
+					EndColumn:   Int(18),
+				},
+				Classifications: []string{"test"},
+			},
 		},
 	}
 	if !cmp.Equal(alerts, want) {
@@ -161,6 +261,32 @@ func TestActionsService_GetAlert(t *testing.T) {
 					"guid": null,
 					"version": "1.4.0"
 				},
+				"rule": {
+					"id": "useless expression",
+					"severity": "warning",
+					"description": "Expression has no effect",
+					"name": "useless expression",
+					"full_description": "Expression has no effect",
+					"help": "Expression has no effect"
+				},
+				"most_recent_instance": {
+					"ref": "refs/heads/main",
+					"state": "open",
+					"commit_sha": "abcdefg12345",
+					"message": {
+						"text": "This path depends on a user-provided value."
+					},
+					"location": {
+						"path": "spec-main/api-session-spec.ts",
+						"start_line": 917,
+						"end_line": 917,
+						"start_column": 7,
+						"end_column": 18
+					},
+					"classifications": [
+						"test"
+					]
+				},      
 				"created_at":"2019-01-02T15:04:05Z",
 				"open":true,
 				"closed_by":null,
@@ -181,12 +307,36 @@ func TestActionsService_GetAlert(t *testing.T) {
 		RuleSeverity:    String("warning"),
 		RuleDescription: String("Expression has no effect"),
 		Tool:            &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")},
-		CreatedAt:       &date,
-		Open:            Bool(true),
-		ClosedBy:        nil,
-		ClosedAt:        nil,
-		URL:             String("https://api.github.com/repos/o/r/code-scanning/alerts/88"),
-		HTMLURL:         String("https://github.com/o/r/security/code-scanning/88"),
+		Rule: &Rule{
+			ID:              String("useless expression"),
+			Severity:        String("warning"),
+			Description:     String("Expression has no effect"),
+			Name:            String("useless expression"),
+			FullDescription: String("Expression has no effect"),
+			Help:            String("Expression has no effect"),
+		},
+		CreatedAt: &date,
+		Open:      Bool(true),
+		ClosedBy:  nil,
+		ClosedAt:  nil,
+		URL:       String("https://api.github.com/repos/o/r/code-scanning/alerts/88"),
+		HTMLURL:   String("https://github.com/o/r/security/code-scanning/88"),
+		MostRecentInstance: &MostRecentInstance{
+			Ref:       String("refs/heads/main"),
+			State:     String("open"),
+			CommitSHA: String("abcdefg12345"),
+			Message: &Message{
+				Text: String("This path depends on a user-provided value."),
+			},
+			Location: &Location{
+				Path:        String("spec-main/api-session-spec.ts"),
+				StartLine:   Int(917),
+				EndLine:     Int(917),
+				StartColumn: Int(7),
+				EndColumn:   Int(18),
+			},
+			Classifications: []string{"test"},
+		},
 	}
 	if !cmp.Equal(alert, want) {
 		t.Errorf("CodeScanning.GetAlert returned %+v, want %+v", alert, want)
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index e0be0614..86bb6c3e 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -180,6 +180,33 @@ func TestAlert_GetCreatedAt(tt *testing.T) {
 	a.GetCreatedAt()
 }
 
+func TestAlert_GetDismissedAt(tt *testing.T) {
+	var zeroValue Timestamp
+	a := &Alert{DismissedAt: &zeroValue}
+	a.GetDismissedAt()
+	a = &Alert{}
+	a.GetDismissedAt()
+	a = nil
+	a.GetDismissedAt()
+}
+
+func TestAlert_GetDismissedBy(tt *testing.T) {
+	a := &Alert{}
+	a.GetDismissedBy()
+	a = nil
+	a.GetDismissedBy()
+}
+
+func TestAlert_GetDismissedReason(tt *testing.T) {
+	var zeroValue string
+	a := &Alert{DismissedReason: &zeroValue}
+	a.GetDismissedReason()
+	a = &Alert{}
+	a.GetDismissedReason()
+	a = nil
+	a.GetDismissedReason()
+}
+
 func TestAlert_GetHTMLURL(tt *testing.T) {
 	var zeroValue string
 	a := &Alert{HTMLURL: &zeroValue}
@@ -190,6 +217,23 @@ func TestAlert_GetHTMLURL(tt *testing.T) {
 	a.GetHTMLURL()
 }
 
+func TestAlert_GetInstancesURL(tt *testing.T) {
+	var zeroValue string
+	a := &Alert{InstancesURL: &zeroValue}
+	a.GetInstancesURL()
+	a = &Alert{}
+	a.GetInstancesURL()
+	a = nil
+	a.GetInstancesURL()
+}
+
+func TestAlert_GetMostRecentInstance(tt *testing.T) {
+	a := &Alert{}
+	a.GetMostRecentInstance()
+	a = nil
+	a.GetMostRecentInstance()
+}
+
 func TestAlert_GetOpen(tt *testing.T) {
 	var zeroValue bool
 	a := &Alert{Open: &zeroValue}
@@ -200,6 +244,13 @@ func TestAlert_GetOpen(tt *testing.T) {
 	a.GetOpen()
 }
 
+func TestAlert_GetRule(tt *testing.T) {
+	a := &Alert{}
+	a.GetRule()
+	a = nil
+	a.GetRule()
+}
+
 func TestAlert_GetRuleDescription(tt *testing.T) {
 	var zeroValue string
 	a := &Alert{RuleDescription: &zeroValue}
@@ -8356,6 +8407,56 @@ func TestListRepositories_GetTotalCount(tt *testing.T) {
 	l.GetTotalCount()
 }
 
+func TestLocation_GetEndColumn(tt *testing.T) {
+	var zeroValue int
+	l := &Location{EndColumn: &zeroValue}
+	l.GetEndColumn()
+	l = &Location{}
+	l.GetEndColumn()
+	l = nil
+	l.GetEndColumn()
+}
+
+func TestLocation_GetEndLine(tt *testing.T) {
+	var zeroValue int
+	l := &Location{EndLine: &zeroValue}
+	l.GetEndLine()
+	l = &Location{}
+	l.GetEndLine()
+	l = nil
+	l.GetEndLine()
+}
+
+func TestLocation_GetPath(tt *testing.T) {
+	var zeroValue string
+	l := &Location{Path: &zeroValue}
+	l.GetPath()
+	l = &Location{}
+	l.GetPath()
+	l = nil
+	l.GetPath()
+}
+
+func TestLocation_GetStartColumn(tt *testing.T) {
+	var zeroValue int
+	l := &Location{StartColumn: &zeroValue}
+	l.GetStartColumn()
+	l = &Location{}
+	l.GetStartColumn()
+	l = nil
+	l.GetStartColumn()
+}
+
+func TestLocation_GetStartLine(tt *testing.T) {
+	var zeroValue int
+	l := &Location{StartLine: &zeroValue}
+	l.GetStartLine()
+	l = &Location{}
+	l.GetStartLine()
+	l = nil
+	l.GetStartLine()
+}
+
 func TestMarketplacePendingChange_GetEffectiveDate(tt *testing.T) {
 	var zeroValue Timestamp
 	m := &MarketplacePendingChange{EffectiveDate: &zeroValue}
@@ -8859,6 +8960,16 @@ func TestMembershipEvent_GetTeam(tt *testing.T) {
 	m.GetTeam()
 }
 
+func TestMessage_GetText(tt *testing.T) {
+	var zeroValue string
+	m := &Message{Text: &zeroValue}
+	m.GetText()
+	m = &Message{}
+	m.GetText()
+	m = nil
+	m.GetText()
+}
+
 func TestMetaEvent_GetAction(tt *testing.T) {
 	var zeroValue string
 	m := &MetaEvent{Action: &zeroValue}
@@ -9245,6 +9356,70 @@ func TestMilestoneStats_GetTotalMilestones(tt *testing.T) {
 	m.GetTotalMilestones()
 }
 
+func TestMostRecentInstance_GetAnalysisKey(tt *testing.T) {
+	var zeroValue string
+	m := &MostRecentInstance{AnalysisKey: &zeroValue}
+	m.GetAnalysisKey()
+	m = &MostRecentInstance{}
+	m.GetAnalysisKey()
+	m = nil
+	m.GetAnalysisKey()
+}
+
+func TestMostRecentInstance_GetCommitSHA(tt *testing.T) {
+	var zeroValue string
+	m := &MostRecentInstance{CommitSHA: &zeroValue}
+	m.GetCommitSHA()
+	m = &MostRecentInstance{}
+	m.GetCommitSHA()
+	m = nil
+	m.GetCommitSHA()
+}
+
+func TestMostRecentInstance_GetEnvironment(tt *testing.T) {
+	var zeroValue string
+	m := &MostRecentInstance{Environment: &zeroValue}
+	m.GetEnvironment()
+	m = &MostRecentInstance{}
+	m.GetEnvironment()
+	m = nil
+	m.GetEnvironment()
+}
+
+func TestMostRecentInstance_GetLocation(tt *testing.T) {
+	m := &MostRecentInstance{}
+	m.GetLocation()
+	m = nil
+	m.GetLocation()
+}
+
+func TestMostRecentInstance_GetMessage(tt *testing.T) {
+	m := &MostRecentInstance{}
+	m.GetMessage()
+	m = nil
+	m.GetMessage()
+}
+
+func TestMostRecentInstance_GetRef(tt *testing.T) {
+	var zeroValue string
+	m := &MostRecentInstance{Ref: &zeroValue}
+	m.GetRef()
+	m = &MostRecentInstance{}
+	m.GetRef()
+	m = nil
+	m.GetRef()
+}
+
+func TestMostRecentInstance_GetState(tt *testing.T) {
+	var zeroValue string
+	m := &MostRecentInstance{State: &zeroValue}
+	m.GetState()
+	m = &MostRecentInstance{}
+	m.GetState()
+	m = nil
+	m.GetState()
+}
+
 func TestNewPullRequest_GetBase(tt *testing.T) {
 	var zeroValue string
 	n := &NewPullRequest{Base: &zeroValue}
@@ -16551,6 +16726,66 @@ func TestReviewersRequest_GetNodeID(tt *testing.T) {
 	r.GetNodeID()
 }
 
+func TestRule_GetDescription(tt *testing.T) {
+	var zeroValue string
+	r := &Rule{Description: &zeroValue}
+	r.GetDescription()
+	r = &Rule{}
+	r.GetDescription()
+	r = nil
+	r.GetDescription()
+}
+
+func TestRule_GetFullDescription(tt *testing.T) {
+	var zeroValue string
+	r := &Rule{FullDescription: &zeroValue}
+	r.GetFullDescription()
+	r = &Rule{}
+	r.GetFullDescription()
+	r = nil
+	r.GetFullDescription()
+}
+
+func TestRule_GetHelp(tt *testing.T) {
+	var zeroValue string
+	r := &Rule{Help: &zeroValue}
+	r.GetHelp()
+	r = &Rule{}
+	r.GetHelp()
+	r = nil
+	r.GetHelp()
+}
+
+func TestRule_GetID(tt *testing.T) {
+	var zeroValue string
+	r := &Rule{ID: &zeroValue}
+	r.GetID()
+	r = &Rule{}
+	r.GetID()
+	r = nil
+	r.GetID()
+}
+
+func TestRule_GetName(tt *testing.T) {
+	var zeroValue string
+	r := &Rule{Name: &zeroValue}
+	r.GetName()
+	r = &Rule{}
+	r.GetName()
+	r = nil
+	r.GetName()
+}
+
+func TestRule_GetSeverity(tt *testing.T) {
+	var zeroValue string
+	r := &Rule{Severity: &zeroValue}
+	r.GetSeverity()
+	r = &Rule{}
+	r.GetSeverity()
+	r = nil
+	r.GetSeverity()
+}
+
 func TestRunner_GetBusy(tt *testing.T) {
 	var zeroValue bool
 	r := &Runner{Busy: &zeroValue}
diff --git a/github/repos_deployments_test.go b/github/repos_deployments_test.go
index 2e12ec6f..c3d6637e 100644
--- a/github/repos_deployments_test.go
+++ b/github/repos_deployments_test.go
@@ -293,3 +293,216 @@ func TestRepositoriesService_CreateDeploymentStatus(t *testing.T) {
 		return resp, err
 	})
 }
+
+func TestDeploymentStatusRequest_Marshal(t *testing.T) {
+	testJSONMarshal(t, &DeploymentStatusRequest{}, "{}")
+
+	r := &DeploymentStatusRequest{
+		State:          String("state"),
+		LogURL:         String("logurl"),
+		Description:    String("desc"),
+		Environment:    String("env"),
+		EnvironmentURL: String("eurl"),
+		AutoInactive:   Bool(false),
+	}
+
+	want := `{
+		"state": "state",
+		"log_url": "logurl",
+		"description": "desc",
+		"environment": "env",
+		"environment_url": "eurl",
+		"auto_inactive": false
+	}`
+
+	testJSONMarshal(t, r, want)
+}
+
+func TestDeploymentStatus_Marshal(t *testing.T) {
+	testJSONMarshal(t, &DeploymentStatus{}, "{}")
+
+	r := &DeploymentStatus{
+		ID:    Int64(1),
+		State: String("state"),
+		Creator: &User{
+			Login:           String("l"),
+			ID:              Int64(1),
+			URL:             String("u"),
+			AvatarURL:       String("a"),
+			GravatarID:      String("g"),
+			Name:            String("n"),
+			Company:         String("c"),
+			Blog:            String("b"),
+			Location:        String("l"),
+			Email:           String("e"),
+			Hireable:        Bool(true),
+			Bio:             String("b"),
+			TwitterUsername: String("t"),
+			PublicRepos:     Int(1),
+			Followers:       Int(1),
+			Following:       Int(1),
+			CreatedAt:       &Timestamp{referenceTime},
+			SuspendedAt:     &Timestamp{referenceTime},
+		},
+		Description:    String("desc"),
+		Environment:    String("env"),
+		NodeID:         String("nid"),
+		CreatedAt:      &Timestamp{referenceTime},
+		UpdatedAt:      &Timestamp{referenceTime},
+		TargetURL:      String("turl"),
+		DeploymentURL:  String("durl"),
+		RepositoryURL:  String("rurl"),
+		EnvironmentURL: String("eurl"),
+		LogURL:         String("lurl"),
+		URL:            String("url"),
+	}
+
+	want := `{
+		"id": 1,
+		"state": "state",
+		"creator": {
+			"login": "l",
+			"id": 1,
+			"avatar_url": "a",
+			"gravatar_id": "g",
+			"name": "n",
+			"company": "c",
+			"blog": "b",
+			"location": "l",
+			"email": "e",
+			"hireable": true,
+			"bio": "b",
+			"twitter_username": "t",
+			"public_repos": 1,
+			"followers": 1,
+			"following": 1,
+			"created_at": ` + referenceTimeStr + `,
+			"suspended_at": ` + referenceTimeStr + `,
+			"url": "u"
+		},
+		"description": "desc",
+		"environment": "env",
+		"node_id": "nid",
+		"created_at": ` + referenceTimeStr + `,
+		"updated_at": ` + referenceTimeStr + `,
+		"target_url": "turl",
+		"deployment_url": "durl",
+		"repository_url": "rurl",
+		"environment_url": "eurl",
+		"log_url": "lurl",
+		"url": "url"
+	}`
+
+	testJSONMarshal(t, r, want)
+}
+
+func TestDeploymentRequest_Marshal(t *testing.T) {
+	testJSONMarshal(t, &DeploymentRequest{}, "{}")
+
+	r := &DeploymentRequest{
+		Ref:                   String("ref"),
+		Task:                  String("task"),
+		AutoMerge:             Bool(false),
+		RequiredContexts:      &[]string{"s"},
+		Payload:               "payload",
+		Environment:           String("environment"),
+		Description:           String("description"),
+		TransientEnvironment:  Bool(false),
+		ProductionEnvironment: Bool(false),
+	}
+
+	want := `{
+		"ref": "ref",
+		"task": "task",
+		"auto_merge": false,
+		"required_contexts": ["s"],
+		"payload": "payload",
+		"environment": "environment",
+		"description": "description",
+		"transient_environment": false,
+		"production_environment": false
+	}`
+
+	testJSONMarshal(t, r, want)
+}
+
+func TestDeployment_Marshal(t *testing.T) {
+	testJSONMarshal(t, &Deployment{}, "{}")
+
+	str := "s"
+	jsonMsg, _ := json.Marshal(str)
+
+	r := &Deployment{
+		URL:         String("url"),
+		ID:          Int64(1),
+		SHA:         String("sha"),
+		Ref:         String("ref"),
+		Task:        String("task"),
+		Payload:     jsonMsg,
+		Environment: String("env"),
+		Description: String("desc"),
+		Creator: &User{
+			Login:           String("l"),
+			ID:              Int64(1),
+			URL:             String("u"),
+			AvatarURL:       String("a"),
+			GravatarID:      String("g"),
+			Name:            String("n"),
+			Company:         String("c"),
+			Blog:            String("b"),
+			Location:        String("l"),
+			Email:           String("e"),
+			Hireable:        Bool(true),
+			Bio:             String("b"),
+			TwitterUsername: String("t"),
+			PublicRepos:     Int(1),
+			Followers:       Int(1),
+			Following:       Int(1),
+			CreatedAt:       &Timestamp{referenceTime},
+			SuspendedAt:     &Timestamp{referenceTime},
+		},
+		CreatedAt:     &Timestamp{referenceTime},
+		UpdatedAt:     &Timestamp{referenceTime},
+		StatusesURL:   String("surl"),
+		RepositoryURL: String("rurl"),
+		NodeID:        String("nid"),
+	}
+
+	want := `{
+		"url": "url",
+		"id": 1,
+		"sha": "sha",
+		"ref": "ref",
+		"task": "task",
+		"payload": "s",
+		"environment": "env",
+		"description": "desc",
+		"creator": {
+			"login": "l",
+			"id": 1,
+			"avatar_url": "a",
+			"gravatar_id": "g",
+			"name": "n",
+			"company": "c",
+			"blog": "b",
+			"location": "l",
+			"email": "e",
+			"hireable": true,
+			"bio": "b",
+			"twitter_username": "t",
+			"public_repos": 1,
+			"followers": 1,
+			"following": 1,
+			"created_at": ` + referenceTimeStr + `,
+			"suspended_at": ` + referenceTimeStr + `,
+			"url": "u"
+		},
+		"created_at": ` + referenceTimeStr + `,
+		"updated_at": ` + referenceTimeStr + `,
+		"statuses_url": "surl",
+		"repository_url": "rurl",
+		"node_id": "nid"
+	}`
+
+	testJSONMarshal(t, r, want)
+}