52 // job.Name can be same for different jobs, so using job.Name+CreationTimeStamp for checking
53 // uniqueness of the job. so that duplicated messages to slack can be avoided
54 jobUniqueHash := job.Name + job.CreationTimestamp.String()
55 if pastJobs[jobUniqueHash] == false {56 if level == "all" {
57 // Send success notifications.
58 if job.Status.Succeeded > 0 && (job.Status.CompletionTime.Add(20*time.Minute).Unix() > time.Now().Unix()) {
Prefer using good name for boolean variable and omit comparison with boolean constant.
If the boolean variable being compared is named correctly (e.g., isUserHere
instead of userIsHere
), this would make the code more readable and avoid
redundancy issues. Also, omit comparison with boolean constant as
if x == true { }
is same as if x { }
but the latter is more idiomatic.
if isUserLoggedIn == true {}
if unnecessaryComparison {}
After:
if isUserLoggedIn {}
if isComparisonUnnecessary {}