Skip to content

Commit 87a8034

Browse files
authored
Issue - 3697 - GitHub analyzer panic (#4113)
* bug: add safeGetString and safeGetBool functions for nil pointer handling * refactor: use package methods instead of custom methods
1 parent 6e99a9a commit 87a8034

File tree

1 file changed

+12
-4
lines changed
  • pkg/analyzer/analyzers/github/common

1 file changed

+12
-4
lines changed

pkg/analyzer/analyzers/github/common/github.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,20 @@ func PrintGists(gists []*gh.Gist, showAll bool) {
176176
t.SetOutputMirror(os.Stdout)
177177
t.AppendHeader(table.Row{"Gist ID", "Gist Link", "Description", "Private"})
178178
for _, gist := range gists {
179-
if showAll && *gist.Public {
180-
t.AppendRow([]interface{}{*gist.ID, *gist.HTMLURL, *gist.Description, "false"})
181-
} else if !*gist.Public {
179+
if gist == nil {
180+
continue
181+
}
182+
gistID := gist.GetID()
183+
gistLink := gist.GetHTMLURL()
184+
gistDescription := gist.GetDescription()
185+
isPublic := gist.GetPublic()
186+
187+
if showAll && isPublic {
188+
t.AppendRow([]any{gistID, gistLink, gistDescription, "false"})
189+
} else if !isPublic {
182190
privateCount++
183191
green := color.New(color.FgGreen).SprintFunc()
184-
t.AppendRow([]interface{}{green(*gist.ID), green(*gist.HTMLURL), green(*gist.Description), green("true")})
192+
t.AppendRow([]any{green(gistID), green(gistLink), green(gistDescription), green("true")})
185193
}
186194
}
187195
if showAll && len(gists) == 0 {

0 commit comments

Comments
 (0)