Showing 1,008 of 1,820 total issues
Method TLSAuthorization.Unmarshal
has 18 return statements (exceeds 4 allowed). Open
func (m *TLSAuthorization) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Server.ListTasks
has 18 return statements (exceeds 4 allowed). Open
func (s *Server) ListTasks(ctx context.Context, request *api.ListTasksRequest) (*api.ListTasksResponse, error) {
var (
tasks []*api.Task
err error
)
Function parseContainer
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func parseContainer(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
if flags.Changed("image") {
image, err := flags.GetString("image")
if err != nil {
return err
Method HealthCheckResponse.Unmarshal
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *HealthCheckResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Network.MarshalToSizedBuffer
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *Network) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method StoreSnapshot.Size
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *StoreSnapshot) Size() (n int) {
if m == nil {
return 0
}
var l int
Method StoreAction.CopyFrom
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *StoreAction) CopyFrom(src interface{}) {
o := src.(*StoreAction)
*m = *o
if o.Target != nil {
Method ReplicatedService.Unmarshal
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *ReplicatedService) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Object.CopyFrom
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *Object) CopyFrom(src interface{}) {
o := src.(*Object)
*m = *o
if o.Object != nil {
Method ResolveAddressRequest.Unmarshal
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *ResolveAddressRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Updater.updateTask
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (u *Updater) updateTask(ctx context.Context, slot orchestrator.Slot, updated *api.Task, order api.UpdateConfig_UpdateOrder) error {
// Kick off the watch before even creating the updated task. This is in order to avoid missing any event.
taskUpdates, cancel := state.Watch(u.watchQueue, api.EventUpdateTask{
Task: &api.Task{ID: updated.ID},
Checks: []api.TaskCheckFunc{api.TaskCheckID},
Method Orchestrator.reconcileServices
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (g *Orchestrator) reconcileServices(ctx context.Context, serviceIDs []string) {
nodeTasks := make(map[string]map[string][]*api.Task)
g.store.View(func(tx store.ReadTx) {
for _, serviceID := range serviceIDs {
Method testSuite.TestServicePortAllocationIsRepeatable
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (suite *testSuite) TestServicePortAllocationIsRepeatable() {
alloc := func() []*api.PortConfig {
s := store.NewMemoryStore(nil)
suite.NotNil(s)
defer s.Close()
Method Server.UpdateRootCA
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) UpdateRootCA(ctx context.Context, cluster *api.Cluster, reconciler *rootRotationReconciler) error {
s.mu.Lock()
s.joinTokens = cluster.RootCA.JoinTokens.Copy()
s.mu.Unlock()
rCA := cluster.RootCA.Copy()
Method testSuite.TestDeallocateServiceAllocate
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (suite *testSuite) TestDeallocateServiceAllocate() {
s := store.NewMemoryStore(nil)
suite.NotNil(s)
defer s.Close()
Method statusReporter.run
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (sr *statusReporter) run(ctx context.Context) {
done := make(chan struct{})
defer close(done)
sr.mu.Lock() // released during wait, below.
- 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
Method TaskSpec.MarshalToSizedBuffer
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (m *TaskSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
- 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
Method rootRotationReconciler.runReconcilerLoop
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (r *rootRotationReconciler) runReconcilerLoop(ctx context.Context, loopRootCA *api.RootCA) {
defer r.wg.Done()
for {
r.mu.Lock()
if len(r.unconvergedNodes) == 0 {
- 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
Method Server.Run
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (s *Server) Run(ctx context.Context) error {
s.mu.Lock()
if s.isRunning() {
s.mu.Unlock()
return errors.New("CA signer is already running")
- 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
Method StoreObject.Unmarshal
has 17 return statements (exceeds 4 allowed). Open
func (m *StoreObject) Unmarshal(dAtA []byte) error {
var hasFields [1]uint64
l := len(dAtA)
iNdEx := 0
for iNdEx < l {