Showing 1,904 of 1,904 total issues
Avoid deeply nested control flow statements. Open
Open
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
Method driver.CreateEndpoint
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
var err error
if err = validateID(nid, eid); 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 Client.ContainerCreate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) {
Method VolumesService.Prune
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *VolumesService) Prune(ctx context.Context, filter filters.Args) (*volumetypes.PruneReport, error) {
if !s.pruneRunning.CompareAndSwap(false, true) {
return nil, errdefs.Conflict(errors.New("a prune operation is already running"))
}
defer s.pruneRunning.Store(false)
Function parseEndpointOptions
has 7 return statements (exceeds 4 allowed). Open
Open
func parseEndpointOptions(epOptions map[string]interface{}) (*endpointOption, error) {
if epOptions == nil {
return nil, nil
}
Avoid deeply nested control flow statements. Open
Open
if shift >= 64 {
return 0, ErrIntOverflowOverlay
}
Method cnmNetworkAllocator.IsServiceAllocated
has 7 return statements (exceeds 4 allowed). Open
Open
func (na *cnmNetworkAllocator) IsServiceAllocated(s *api.Service, flags ...func(*networkallocator.ServiceAllocationOpts)) bool {
specNetworks := serviceNetworks(s)
// If endpoint mode is VIP and allocator does not have the
// service in VIP allocated set then it needs to be allocated.
Method windowsParser.splitRawSpec
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (p *windowsParser) splitRawSpec(raw string, splitRegexp *regexp.Regexp) ([]string, error) {
match := splitRegexp.FindStringSubmatch(strings.ToLower(raw))
if len(match) == 0 {
return nil, errInvalidSpec(raw)
}
- 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
Avoid deeply nested control flow statements. Open
Open
if b < 0x80 {
break
}
Method driver.peerAdd
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, updateDb bool) error {
Method driver.peerDelete
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, updateDb bool) error {
Method requestReader.Read
has 7 return statements (exceeds 4 allowed). Open
Open
func (r *requestReader) Read(p []byte) (n int, err error) {
if r.client == nil || r.request == nil {
return 0, fmt.Errorf("client and request can't be nil")
}
isFreshRequest := false
Method driver.peerAdd
has 7 return statements (exceeds 4 allowed). Open
Open
func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, peerMac net.HardwareAddr, vtep net.IP, updateDb bool) error {
log.G(context.TODO()).Debugf("WINOVERLAY: Enter peerAdd for ca ip %s with ca mac %s", peerIP.String(), peerMac.String())
if err := validateID(nid, eid); err != nil {
return err
Method Client.ContainerCreate
has 7 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) {
var response container.CreateResponse
// Make sure we negotiated (if the client is configured to do so),
// as code below contains API-version specific handling of options.
Function createVlanLink
has 7 return statements (exceeds 4 allowed). Open
Open
func createVlanLink(parentName string) error {
if strings.Contains(parentName, ".") {
parent, vidInt, err := parseVlan(parentName)
if err != nil {
return err
Method Store.lookup
has 7 return statements (exceeds 4 allowed). Open
Open
func (s *Store) lookup(name string, mode int) (volume.Driver, error) {
if name == "" {
return nil, errdefs.InvalidParameter(errors.New("driver name cannot be empty"))
}
s.driverLock.Lock(name)
Function ExecT
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func ExecT(ctx context.Context, t testing.TB, apiClient client.APIClient, id string, cmd []string, ops ...func(*container.ExecOptions)) ExecResult {
Function ReadCertsDirectory
has 7 return statements (exceeds 4 allowed). Open
Open
func ReadCertsDirectory(tlsConfig *tls.Config, directory string) error {
fs, err := os.ReadDir(directory)
if err != nil && !os.IsNotExist(err) {
return invalidParam(err)
}
Function dispatchRun
has 7 return statements (exceeds 4 allowed). Open
Open
func dispatchRun(ctx context.Context, d dispatchRequest, c *instructions.RunCommand) error {
if err := image.CheckOS(d.state.operatingSystem); err != nil {
return err
}
Method swarmRouter.updateCluster
has 7 return statements (exceeds 4 allowed). Open
Open
func (sr *swarmRouter) updateCluster(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
var swarm types.Spec
if err := httputils.ReadJSON(r, &swarm); err != nil {
return err
}