prysmaticlabs / prysm

Function with cyclomatic complexity higher than threshold GO-R1005
Anti-pattern
Minor
10 occurrences in this check
func Proto has a cyclomatic complexity of 24 with "high" risk
 308}
 309
 310// Proto converts the beacon block body to a protobuf object.
 311func (b *BeaconBlockBody) Proto() (proto.Message, error) { 312	if b == nil {
 313		return nil, nil
 314	}
func Proto has a cyclomatic complexity of 30 with "very-high" risk
 147}
 148
 149// Proto converts the beacon block to a protobuf object.
 150func (b *BeaconBlock) Proto() (proto.Message, error) { 151	if b == nil {
 152		return nil, nil
 153	}
func Proto has a cyclomatic complexity of 30 with "very-high" risk
  13)
  14
  15// Proto converts the signed beacon block to a protobuf object.
  16func (b *SignedBeaconBlock) Proto() (proto.Message, error) {  17	if b == nil {
  18		return nil, errNilBlock
  19	}
func UnmarshalSSZ has a cyclomatic complexity of 29 with "very-high" risk
 884}
 885
 886// UnmarshalSSZ unmarshals the beacon block from its relevant ssz form.
 887func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error { 888	var newBlock *BeaconBlock
 889	switch b.version {
 890	case version.Phase0:
func UnmarshalSSZ has a cyclomatic complexity of 29 with "very-high" risk
 564}
 565
 566// UnmarshalSSZ unmarshals the signed beacon block from its relevant ssz form.
 567func (b *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { 568	var newBlock *SignedBeaconBlock
 569	switch b.version {
 570	case version.Phase0:
func BuildSignedBeaconBlockFromExecutionPayload has a cyclomatic complexity of 23 with "high" risk
224
225// BuildSignedBeaconBlockFromExecutionPayload takes a signed, blinded beacon block and converts into
226// a full, signed beacon block by specifying an execution payload.
227func BuildSignedBeaconBlockFromExecutionPayload(228	blk interfaces.ReadOnlySignedBeaconBlock, payload interface{},
229) (interfaces.SignedBeaconBlock, error) {
230	if err := BeaconBlockIsNil(blk); err != nil {
func BuildSignedBeaconBlock has a cyclomatic complexity of 21 with "high" risk
153// BuildSignedBeaconBlock assembles a block.ReadOnlySignedBeaconBlock interface compatible struct from a
154// given beacon block and the appropriate signature. This method may be used to easily create a
155// signed beacon block.
156func BuildSignedBeaconBlock(blk interfaces.ReadOnlyBeaconBlock, signature []byte) (interfaces.SignedBeaconBlock, error) {157	pb, err := blk.Proto()
158	if err != nil {
159		return nil, err
func NewBeaconBlock has a cyclomatic complexity of 21 with "high" risk
 77}
 78
 79// NewBeaconBlock creates a beacon block from a protobuf beacon block.
 80func NewBeaconBlock(i interface{}) (interfaces.ReadOnlyBeaconBlock, error) { 81	switch b := i.(type) {
 82	case nil:
 83		return nil, ErrNilObject
func NewSignedBeaconBlock has a cyclomatic complexity of 21 with "high" risk
 31)
 32
 33// NewSignedBeaconBlock creates a signed beacon block from a protobuf signed beacon block.
 34func NewSignedBeaconBlock(i interface{}) (interfaces.SignedBeaconBlock, error) { 35	switch b := i.(type) {
 36	case nil:
 37		return nil, ErrNilObject
func TestGetSpec has a cyclomatic complexity of 152 with "critical" risk
 44	assert.Equal(t, "0x4242424242424242424242424242424242424242", response.Data.Address)
 45}
 46
 47func TestGetSpec(t *testing.T) { 48	params.SetupTestConfigCleanup(t)
 49	config := params.BeaconConfig().Copy()
 50