Showing 1,008 of 1,820 total issues
Method HealthCheckRequest.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *HealthCheckRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Function parseContainer
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
Open
func parseContainer(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
if flags.Changed("image") {
image, err := flags.GetString("image")
if err != nil {
return err
- 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 controller.Start
has 15 return statements (exceeds 4 allowed). Open
Open
func (r *controller) Start(ctx context.Context) error {
if err := r.checkClosed(); err != nil {
return err
}
Method NodeCertificateStatusRequest.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *NodeCertificateStatusRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method GetRootCACertificateResponse.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *GetRootCACertificateResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method DetachNetworkRequest.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *DetachNetworkRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method AttachNetworkResponse.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *AttachNetworkResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method TasksRequest.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *TasksRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method HeartbeatRequest.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *HeartbeatRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method AssignmentsRequest.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *AssignmentsRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method NetworkAttachmentSpec.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *NetworkAttachmentSpec) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method ReplicatedJob.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *ReplicatedJob) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method ContainerSpec_PullOptions.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *ContainerSpec_PullOptions) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Reconciler.ReconcileService
has 15 return statements (exceeds 4 allowed). Open
Open
func (r *Reconciler) ReconcileService(id string) error {
var (
service *api.Service
tasks []*api.Task
cluster *api.Cluster
Method JoinRequest.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *JoinRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method ResolveAddressResponse.Unmarshal
has 15 return statements (exceeds 4 allowed). Open
Open
func (m *ResolveAddressResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
Method Dispatcher.Assignments
has 15 return statements (exceeds 4 allowed). Open
Open
func (d *Dispatcher) Assignments(r *api.AssignmentsRequest, stream api.Dispatcher_AssignmentsServer) error {
d.rpcRW.RLock()
defer d.rpcRW.RUnlock()
dctx, err := d.isRunningLocked()
Method Server.UpdateVolume
has 15 return statements (exceeds 4 allowed). Open
Open
func (s *Server) UpdateVolume(ctx context.Context, request *api.UpdateVolumeRequest) (*api.UpdateVolumeResponse, error) {
if request.VolumeID == "" {
return nil, status.Errorf(codes.InvalidArgument, "VolumeID must not be empty")
}
if request.Spec == nil {
Method Node.Join
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
Open
func (n *Node) Join(ctx context.Context, req *api.JoinRequest) (*api.JoinResponse, error) {
nodeInfo, err := ca.RemoteNode(ctx)
if err != nil {
return nil, err
}
- 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 dumpWAL
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func dumpWAL(swarmdir, unlockKey string, start, end uint64, redact bool) error {
walData, _, err := loadData(swarmdir, unlockKey)
if err != nil {
return err
}