manager/state/raft/testutils/testutils.go
File testutils.go
has 533 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package testutils
import (
"context"
"net"
Function WaitForCluster
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
Open
func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode) {
err := testutils.PollFunc(clockSource, func() error {
var prev *etcdraft.Status
var leadNode *TestNode
nodeLoop:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function CheckValuesOnNodes
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func CheckValuesOnNodes(t *testing.T, clockSource *fakeclock.FakeClock, checkNodes map[uint64]*TestNode, ids []string, values []*api.Node) {
iteration := 0
for checkNodeID, node := range checkNodes {
assert.NoError(t, testutils.PollFunc(clockSource, func() error {
var err error
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function CopyNode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func CopyNode(t *testing.T, clockSource *fakeclock.FakeClock, oldNode *TestNode, forceNewCluster bool, kr *SimpleKeyRotator) (*TestNode, context.Context) {
Function CheckValuesOnNodes
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func CheckValuesOnNodes(t *testing.T, clockSource *fakeclock.FakeClock, checkNodes map[uint64]*TestNode, ids []string, values []*api.Node) {
Function NewJoinNode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewJoinNode(t *testing.T, clockSource *fakeclock.FakeClock, join string, tc *cautils.TestCA, opts ...raft.NodeOptions) *TestNode {
Function AddRaftNode
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func AddRaftNode(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode, tc *cautils.TestCA, opts ...raft.NodeOptions) {
Function CheckValuesOnNodes
has 5 return statements (exceeds 4 allowed). Open
Open
func CheckValuesOnNodes(t *testing.T, clockSource *fakeclock.FakeClock, checkNodes map[uint64]*TestNode, ids []string, values []*api.Node) {
iteration := 0
for checkNodeID, node := range checkNodes {
assert.NoError(t, testutils.PollFunc(clockSource, func() error {
var err error
Function WaitForCluster
has 5 return statements (exceeds 4 allowed). Open
Open
func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode) {
err := testutils.PollFunc(clockSource, func() error {
var prev *etcdraft.Status
var leadNode *TestNode
nodeLoop: