Repository navigation
refactor: remove dead code and duplicate constants; fix a data race in snark picking - #48
Merged
Merged
Conversation
…n snark picking - remove ErrUnsupportedReason, EvaluateKarmaAction, ParseMentionAction(s) and MentionAction, and GetReplyMode on the settings service and repository; their tests now exercise the functions the server uses - drop never-used fields from the Slack payload types; Blocks is any - the settings repository uses domain's snark level constants instead of its own copies - snark.go uses math/rand/v2. RandomSnarkPicker shared one *rand.Rand across all request goroutines, which is a data race; a new test catches it under -race
jordan-simonovski
force-pushed
the
refactor/dead-code-sweep
branch
from
November 14, 2026 09:57
18bc5e3 to
d23349d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
docs/backlog/15-dead-code-sweep.md(deleted in this PR, with its index row).A real bug, found on the way
RandomSnarkPickercreated one*rand.Randfrommath/rand, andcmd/servershares that single picker across every request goroutine.math/rand'sRandisn't safe for concurrent use, so concurrent rejections raced on its state. A new test,TestRandomSnarkPickerIsSafeForConcurrentUse, calls the picker and the other two snark helpers from 32 goroutines. Run with-raceit reports DATA RACE on currentmain, and passes here.snark.gonow usesmath/rand/v2's top-levelrand.IntN, which is goroutine-safe and needs no seeding. The per-call reseeding in the other two helpers, and the comment explaining it, are gone.Removed (each confirmed unused outside tests first)
internal/domainErrUnsupportedReason,EvaluateKarmaAction(the server callsEvaluateKarmaActionWithLimits)internal/parserParseMentionAction,ParseMentionActions,MentionAction(the server usesParseKarmaSegments)internal/slackChannelSettingsService.GetReplyMode; never-set payload fieldsSlashCommandPayload.{Token, ChannelName, EnterpriseID, EnterpriseName},EventEnvelope.Token,SlackEvent.ChannelID,MessageResponse.ThreadTS;Blocksis nowanyinternal/persistenceDynamoSettingsRepository.GetReplyMode; its own copies of the snark level constants, replaced bydomain's (the same 5, 1 and 10)Kept: the local
absinreaction_settings.go, as the brief says. Not in the brief's table, so left for a later pass:settings_blocks.gostill usesmap[string]interface{}.Tests
No coverage was lost.
TestEvaluateKarmaActionnow callsEvaluateKarmaActionWithLimitswith the same limits. The parser cases moved toTestParseUserMentionsusing test helpers overParseKarmaSegments, with the same cases and semantics. The settings-service test checks unknown modes still default to thread, viaGetChannelSettings.make checkpasses, includinggo vet -tags=integration. No changeset.Review
/ce-code-reviewran as a lite correctness and testing review. It found no defects. It confirmed:rand.IntNcovers the same ranges