Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions internal/horoscope/horoscope.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package horoscope

import (
"fmt"
"strings"
"time"
)

// ZodiacSign represents an astrological zodiac sign.
type ZodiacSign struct {
Name string
StartDay int
StartMonth time.Month
EndDay int
EndMonth time.Month
Element string
Ruler string
Lucky int
}

var signs = []ZodiacSign{
{"Aries", 21, time.March, 19, time.April, "Fire", "Mars", 9},
{"Taurus", 20, time.April, 20, time.May, "Earth", "Venus", 6},
{"Gemini", 21, time.May, 20, time.June, "Air", "Mercury", 5},
{"Cancer", 21, time.June, 22, time.July, "Water", "Moon", 2},
{"Leo", 23, time.July, 22, time.August, "Fire", "Sun", 1},
{"Virgo", 23, time.August, 22, time.September, "Earth", "Mercury", 5},
{"Libra", 23, time.September, 22, time.October, "Air", "Venus", 6},
{"Scorpio", 23, time.October, 21, time.November, "Water", "Pluto", 8},
{"Sagittarius", 22, time.November, 21, time.December, "Fire", "Jupiter", 3},
{"Capricorn", 22, time.December, 19, time.January, "Earth", "Saturn", 7},
{"Aquarius", 20, time.January, 18, time.February, "Air", "Uranus", 4},
{"Pisces", 19, time.February, 20, time.March, "Water", "Neptune", 7},
}

var fortunes = []string{
"Your Kubernetes pods will achieve perfect harmony today.",
"A mysterious YAML indentation error will reveal hidden truths.",
"The stars suggest you should rebase before pushing.",
"Mercury is in retrograde — avoid force-pushing to main.",
"Today is an auspicious day for container orchestration.",
"A rogue init container will bring unexpected joy.",
"Your PersistentVolumeClaim will be fulfilled by the cosmos.",
"Beware of ConfigMaps created during a full moon.",
"The alignment of Jupiter and Saturn favors blue-green deployments.",
"An unexpected OOMKill will teach you the value of resource limits.",
"Your service mesh will untangle itself by Thursday.",
"A CrashLoopBackOff in your chart signals personal growth.",
}

// ForToday returns the horoscope for today's date.
func ForToday() string {
return ForDate(time.Now())
}

// ForDate returns the horoscope for a given date.
func ForDate(t time.Time) string {
sign := signForDate(t)
fortune := pickFortune(t, sign)

var b strings.Builder
b.WriteString(fmt.Sprintf("Your Daily ACS Horoscope (%s)\n", t.Format("January 2, 2006")))

Check failure on line 62 in internal/horoscope/horoscope.go

View workflow job for this annotation

GitHub Actions / Code Quality Checks

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix staticcheck violations blocking the pipeline.

The code uses b.WriteString(fmt.Sprintf(...)) which is inefficient and causes pipeline failures. strings.Builder implements io.Writer, so use fmt.Fprintf directly.

🔧 Proposed fix to use fmt.Fprintf
 	var b strings.Builder
-	b.WriteString(fmt.Sprintf("Your Daily ACS Horoscope (%s)\n", t.Format("January 2, 2006")))
+	fmt.Fprintf(&b, "Your Daily ACS Horoscope (%s)\n", t.Format("January 2, 2006"))
 	b.WriteString(strings.Repeat("*", 42) + "\n\n")
-	b.WriteString(fmt.Sprintf("  Sign:    %s\n", sign.Name))
-	b.WriteString(fmt.Sprintf("  Element: %s\n", sign.Element))
-	b.WriteString(fmt.Sprintf("  Ruler:   %s\n", sign.Ruler))
-	b.WriteString(fmt.Sprintf("  Lucky #: %d\n\n", sign.Lucky))
-	b.WriteString(fmt.Sprintf("  %s\n\n", fortune))
+	fmt.Fprintf(&b, "  Sign:    %s\n", sign.Name)
+	fmt.Fprintf(&b, "  Element: %s\n", sign.Element)
+	fmt.Fprintf(&b, "  Ruler:   %s\n", sign.Ruler)
+	fmt.Fprintf(&b, "  Lucky #: %d\n\n", sign.Lucky)
+	fmt.Fprintf(&b, "  %s\n\n", fortune)
 	b.WriteString(cosmicAdvice(sign))
 	return b.String()

As per static analysis hints, staticcheck reported QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)).

Also applies to: 64-68

🧰 Tools
🪛 GitHub Actions: Code Quality / 0_Code Quality Checks.txt

[error] 62-62: golangci-lint (staticcheck) reported QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)).

🪛 GitHub Actions: Code Quality / Code Quality Checks

[error] 62-62: golangci-lint (staticcheck) reported QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...))

🪛 GitHub Check: Code Quality Checks

[failure] 62-62:
QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/horoscope/horoscope.go` at line 62, Replace inefficient
b.WriteString(fmt.Sprintf(...)) calls by writing directly to the builder with
fmt.Fprintf(b, ...). Locate the uses where the strings.Builder variable b calls
WriteString with a fmt.Sprintf argument (e.g., the line
b.WriteString(fmt.Sprintf("Your Daily ACS Horoscope (%s)\n", t.Format("January
2, 2006")))) and change them to fmt.Fprintf(b, "Your Daily ACS Horoscope
(%s)\n", t.Format("January 2, 2006")). Apply the same replacement for the other
occurrences around the same block (the subsequent lines originally at 64–68) so
all WriteString(fmt.Sprintf(...)) patterns use fmt.Fprintf(b, ...) instead.

b.WriteString(strings.Repeat("*", 42) + "\n\n")
b.WriteString(fmt.Sprintf(" Sign: %s\n", sign.Name))

Check failure on line 64 in internal/horoscope/horoscope.go

View workflow job for this annotation

GitHub Actions / Code Quality Checks

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
b.WriteString(fmt.Sprintf(" Element: %s\n", sign.Element))

Check failure on line 65 in internal/horoscope/horoscope.go

View workflow job for this annotation

GitHub Actions / Code Quality Checks

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
b.WriteString(fmt.Sprintf(" Ruler: %s\n", sign.Ruler))

Check failure on line 66 in internal/horoscope/horoscope.go

View workflow job for this annotation

GitHub Actions / Code Quality Checks

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
b.WriteString(fmt.Sprintf(" Lucky #: %d\n\n", sign.Lucky))

Check failure on line 67 in internal/horoscope/horoscope.go

View workflow job for this annotation

GitHub Actions / Code Quality Checks

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
b.WriteString(fmt.Sprintf(" %s\n\n", fortune))

Check failure on line 68 in internal/horoscope/horoscope.go

View workflow job for this annotation

GitHub Actions / Code Quality Checks

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
b.WriteString(cosmicAdvice(sign))
return b.String()
}

func signForDate(t time.Time) ZodiacSign {
day := t.Day()
month := t.Month()
for _, s := range signs {
if month == s.StartMonth && day >= s.StartDay {
return s
}
if month == s.EndMonth && day <= s.EndDay {
return s
}
}
return signs[9]
}

func pickFortune(t time.Time, sign ZodiacSign) string {
idx := (t.YearDay() + sign.Lucky) % len(fortunes)
return fortunes[idx]
}

func cosmicAdvice(sign ZodiacSign) string {
var b strings.Builder
b.WriteString(" Cosmic Deployment Advice:\n")
switch sign.Element {
case "Fire":
b.WriteString(" Deploy boldly. Scale horizontally. Ignore the linter.\n")
case "Earth":
b.WriteString(" Pin your image tags. Rotate your secrets. Trust the operator.\n")
case "Air":
b.WriteString(" Let your microservices breathe. Embrace eventual consistency.\n")
case "Water":
b.WriteString(" Go with the flow of GitOps. Let ArgoCD guide your path.\n")
}
b.WriteString(fmt.Sprintf("\n Auspicious namespaces: %s\n", auspiciousNamespace(sign)))

Check failure on line 105 in internal/horoscope/horoscope.go

View workflow job for this annotation

GitHub Actions / Code Quality Checks

QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix staticcheck violation blocking the pipeline.

Same issue as in ForDate: use fmt.Fprintf instead of WriteString(fmt.Sprintf(...)).

🔧 Proposed fix
 	case "Water":
 		b.WriteString("  Go with the flow of GitOps. Let ArgoCD guide your path.\n")
 	}
-	b.WriteString(fmt.Sprintf("\n  Auspicious namespaces: %s\n", auspiciousNamespace(sign)))
+	fmt.Fprintf(&b, "\n  Auspicious namespaces: %s\n", auspiciousNamespace(sign))
 	return b.String()

As per static analysis hints, staticcheck reported QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
b.WriteString(fmt.Sprintf("\n Auspicious namespaces: %s\n", auspiciousNamespace(sign)))
case "Water":
b.WriteString(" Go with the flow of GitOps. Let ArgoCD guide your path.\n")
}
fmt.Fprintf(&b, "\n Auspicious namespaces: %s\n", auspiciousNamespace(sign))
return b.String()
🧰 Tools
🪛 GitHub Check: Code Quality Checks

[failure] 105-105:
QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/horoscope/horoscope.go` at line 105, Replace the
WriteString(fmt.Sprintf(...)) call with fmt.Fprintf to fix the staticcheck
QF1012 violation: change the call that writes the auspicious namespaces
(currently b.WriteString(fmt.Sprintf("\n  Auspicious namespaces: %s\n",
auspiciousNamespace(sign)))) to use fmt.Fprintf with the same format and
arguments (write to b), mirroring the same fix applied in ForDate; ensure you
import fmt if not already imported.

return b.String()
}

func auspiciousNamespace(sign ZodiacSign) string {
namespaces := map[string]string{
"Aries": "stackrox-blaze",
"Taurus": "stackrox-steady",
"Gemini": "stackrox-twin-a, stackrox-twin-b",
"Cancer": "stackrox-sanctuary",
"Leo": "stackrox-royal",
"Virgo": "stackrox-pristine",
"Libra": "stackrox-balanced",
"Scorpio": "stackrox-shadow",
"Sagittarius": "stackrox-adventure",
"Capricorn": "stackrox-summit",
"Aquarius": "stackrox-innovation",
"Pisces": "stackrox-drift",
}
if ns, ok := namespaces[sign.Name]; ok {
return ns
}
return "stackrox-unknown"
}
Loading