prysmaticlabs / prysm

Function with cyclomatic complexity higher than threshold GO-R1005
Anti-pattern
Minor
2 hours ago8 months old
func marshalState has a cyclomatic complexity of 24 with "high" risk
602}
603
604// marshal versioned state from struct type down to bytes.
605func marshalState(ctx context.Context, st state.ReadOnlyBeaconState) ([]byte, error) {606	switch st.ToProtoUnsafe().(type) {
607	case *ethpb.BeaconState:
608		rState, ok := st.ToProtoUnsafe().(*ethpb.BeaconState)
func unmarshalState has a cyclomatic complexity of 26 with "very-high" risk
508}
509
510// unmarshal state from marshaled proto state bytes to versioned state struct type.
511func (s *Store) unmarshalState(_ context.Context, enc []byte, validatorEntries []*ethpb.Validator) (state.BeaconState, error) {512	var err error
513	enc, err = snappy.Decode(nil, enc)
514	if err != nil {
func saveStatesEfficientInternal has a cyclomatic complexity of 16 with "high" risk
213	return validatorKeys, validatorsEntries, nil
214}
215
216func (s *Store) saveStatesEfficientInternal(ctx context.Context, tx *bolt.Tx, blockRoots [][32]byte, states []state.ReadOnlyBeaconState, validatorKeys [][]byte, validatorsEntries map[string]*ethpb.Validator) error {217	bucket := tx.Bucket(stateBucket)
218	valIdxBkt := tx.Bucket(blockRootValidatorHashesBucket)
219	for i, rt := range blockRoots {
func unmarshalBlock has a cyclomatic complexity of 22 with "high" risk
769}
770
771// unmarshal block from marshaled proto beacon block bytes to versioned beacon block struct type.
772func unmarshalBlock(_ context.Context, enc []byte) (interfaces.ReadOnlySignedBeaconBlock, error) {773	var err error
774	enc, err = snappy.Decode(nil, enc)
775	if err != nil {
func deepValueEqualExportedOnly has a cyclomatic complexity of 35 with "very-high" risk
121	}
122}
123
124func deepValueEqualExportedOnly(v1, v2 reflect.Value, visited map[visit]bool, depth int) bool {125	if !v1.IsValid() || !v2.IsValid() {
126		return v1.IsValid() == v2.IsValid()
127	}