Showing 1,468 of 1,914 total issues
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.PluginInstall
has 7 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (rc io.ReadCloser, err error) {
query := url.Values{}
if _, err := reference.ParseNormalizedNamed(options.RemoteRef); err != nil {
return nil, errors.Wrap(err, "invalid remote reference")
}
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)
Avoid deeply nested control flow statements. Open
Open
if shift >= 64 {
return 0, ErrIntOverflowOverlay
}
Avoid deeply nested control flow statements. Open
Open
if b < 0x80 {
break
}
Method Client.ImagePush
has 7 return statements (exceeds 4 allowed). Open
Open
func (cli *Client) ImagePush(ctx context.Context, image string, options image.PushOptions) (io.ReadCloser, error) {
ref, err := reference.ParseNormalizedNamed(image)
if err != nil {
return nil, err
}
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
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) {
Avoid deeply nested control flow statements. Open
Open
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
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 {
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
}
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 {
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 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
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 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 patchImageConfig
has 7 return statements (exceeds 4 allowed). Open
Open
func patchImageConfig(dt []byte, dps []digest.Digest, history []ocispec.History, cache *exptypes.InlineCacheEntry) ([]byte, error) {
m := map[string]json.RawMessage{}
if err := json.Unmarshal(dt, &m); err != nil {
return nil, errors.Wrap(err, "failed to parse image config for patch")
}
Method buildRouter.postBuild
has 7 return statements (exceeds 4 allowed). Open
Open
func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
var (
notVerboseBuffer = bytes.NewBuffer(nil)
version = httputils.VersionFromContext(ctx)
)
Method Service.Search
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (s *Service) Search(ctx context.Context, searchFilters filters.Args, term string, limit int, authConfig *registry.AuthConfig, headers map[string][]string) ([]registry.SearchResult, error) {
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
}