prysmaticlabs / prysm

Function with cyclomatic complexity higher than threshold GO-R1005
Anti-pattern
Minor
6 occurrences in this check
func handleBlockOperationEvents has a cyclomatic complexity of 26 with "very-high" risk
154	}
155}
156
157func handleBlockOperationEvents(w http.ResponseWriter, flusher http.Flusher, requestedTopics map[string]bool, event *feed.Event) error {158	switch event.Type {
159	case operation.AggregatedAttReceived:
160		if _, ok := requestedTopics[AttestationTopic]; !ok {
func CommitteeAssignments has a cyclomatic complexity of 16 with "high" risk
157// 2. Compute all committees.
158// 3. Determine the attesting slot for each committee.
159// 4. Construct a map of validator indices pointing to the respective committees.
160func CommitteeAssignments(161	ctx context.Context,
162	state state.BeaconState,
163	epoch primitives.Epoch,
func ProcessRegistryUpdates has a cyclomatic complexity of 16 with "high" risk
 91//	 for index in activation_queue[:get_validator_churn_limit(state)]:
 92//	     validator = state.validators[index]
 93//	     validator.activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
 94func ProcessRegistryUpdates(ctx context.Context, state state.BeaconState) (state.BeaconState, error) { 95	currentEpoch := time.CurrentEpoch(state)
 96	vals := state.Validators()
 97	var err error
func VerifyAttestationNoVerifySignature has a cyclomatic complexity of 22 with "high" risk
 43
 44// VerifyAttestationNoVerifySignature verifies the attestation without verifying the attestation signature. This is
 45// used before processing attestation with the beacon state.
 46func VerifyAttestationNoVerifySignature( 47	ctx context.Context,
 48	beaconState state.ReadOnlyBeaconState,
 49	att interfaces.Attestation,
func TranslateParticipation has a cyclomatic complexity of 23 with "high" risk
145//	    for index in get_attesting_indices(state, data, attestation.aggregation_bits):
146//	        for flag_index in participation_flag_indices:
147//	            epoch_participation[index] = add_flag(epoch_participation[index], flag_index)
148func TranslateParticipation(ctx context.Context, state state.BeaconState, atts []*ethpb.PendingAttestation) (state.BeaconState, error) {149	epochParticipation, err := state.PreviousEpochParticipation()
150	if err != nil {
151		return nil, err
func EpochParticipation has a cyclomatic complexity of 16 with "high" risk
180//	        if flag_index in participation_flag_indices and not has_flag(epoch_participation[index], flag_index):
181//	            epoch_participation[index] = add_flag(epoch_participation[index], flag_index)
182//	            proposer_reward_numerator += get_base_reward(state, index) * weight
183func EpochParticipation(beaconState state.BeaconState, indices []uint64, epochParticipation []byte, participatedFlags map[uint8]bool, totalBalance uint64) (uint64, []byte, error) {184	cfg := params.BeaconConfig()
185	sourceFlagIndex := cfg.TimelySourceFlagIndex
186	targetFlagIndex := cfg.TimelyTargetFlagIndex