Showing 1,468 of 1,914 total issues
Method Client.callWithRetry
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func (c *Client) callWithRetry(serviceMethod string, data io.Reader, retry bool, reqOpts ...func(*RequestOpts)) (io.ReadCloser, error) {
var retries int
start := time.Now()
var opts RequestOpts
- 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 Daemon.fillRootlessVersion
has 13 return statements (exceeds 4 allowed). Open
Open
func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
if !rootless.RunningWithRootlessKit() {
return nil
}
rlc, err := getRootlessKitClient()
Function pullEndpoints
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func pullEndpoints(ctx context.Context, registryService RegistryResolver, ref reference.Named,
f func(context.Context, registry.RepositoryInfo, registry.APIEndpoint) error,
) (*registry.RepositoryInfo, error) {
// Resolve the Repository name from fqn to RepositoryInfo
repoInfo, err := registryService.ResolveRepository(ref)
Function Client
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func Client(args []string) {
log.G(context.TODO()).Infof("[CLIENT] Starting with arguments %v", args)
command := args[0]
if len(args) < cmdArgCheck[command] {
Method Namespace.AddNeighbor
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (n *Namespace) AddNeighbor(dstIP net.IP, dstMac net.HardwareAddr, force bool, options ...NeighOption) error {
var (
iface netlink.Link
err error
neighborAlreadyPresent bool
Function bindTCPOrUDP
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func bindTCPOrUDP(cfg portBindingReq, port, typ, proto int) (_ portBinding, retErr error) {
pb := portBinding{PortBinding: cfg.PortBinding.GetCopy()}
pb.HostPort = uint16(port)
pb.HostPortEnd = pb.HostPort
pb.childHostIP = cfg.childHostIP
Method VolumeStore.restore
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *VolumeStore) restore() {
var ls []volumeMetadata
s.db.View(func(tx *bolt.Tx) error {
ls = listMeta(tx)
return nil
Function adjustForAPIVersion
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func adjustForAPIVersion(cliVersion string, service *swarm.ServiceSpec) {
if cliVersion == "" {
return
}
if versions.LessThan(cliVersion, "1.46") {
Method containerRouter.postContainersAttach
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *containerRouter) postContainersAttach(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
err := httputils.ParseForm(r)
if err != nil {
return err
}
Method Cluster.Leave
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *Cluster) Leave(ctx context.Context, force bool) error {
c.controlMutex.Lock()
defer c.controlMutex.Unlock()
c.mu.Lock()
Function validateEndpointSettings
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func validateEndpointSettings(nw *libnetwork.Network, nwName string, epConfig *networktypes.EndpointSettings) error {
if epConfig == nil {
return nil
}
Method Daemon.CreateImageFromContainer
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (daemon *Daemon) CreateImageFromContainer(ctx context.Context, name string, c *backend.CreateImageConfig) (string, error) {
start := time.Now()
container, err := daemon.GetContainer(name)
if err != nil {
Method Client.callWithRetry
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *Client) callWithRetry(serviceMethod string, data io.Reader, retry bool, reqOpts ...func(*RequestOpts)) (io.ReadCloser, error) {
var retries int
start := time.Now()
var opts RequestOpts
Function computePrivileges
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func computePrivileges(c types.PluginConfig) types.PluginPrivileges {
var privileges types.PluginPrivileges
if c.Network.Type != "null" && c.Network.Type != "bridge" && c.Network.Type != "" {
privileges = append(privileges, types.PluginPrivilege{
Name: "network",
Method NetworkDB.handleTableEvent
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (nDB *NetworkDB) handleTableEvent(tEvent *TableEvent, isBulkSync bool) bool {
// Update our local clock if the received messages has newer time.
nDB.tableClock.Witness(tEvent.LTime)
// Ignore the table events for networks that are in the process of going away
Method PortAllocator.RequestPortsInRange
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *PortAllocator) RequestPortsInRange(ips []net.IP, proto string, portStart, portEnd int) (int, error) {
if proto != "tcp" && proto != "udp" && proto != "sctp" {
return 0, ErrUnknownProtocol
}
Function programSA
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func programSA(localIP, remoteIP net.IP, spi *spi, k *key, dir int, add bool) (fSA *netlink.XfrmState, rSA *netlink.XfrmState, err error) {
var (
action = "Removing"
xfrmProgram = ns.NlHandle().XfrmStateDel
)
Method driver.CreateEndpoint
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (d *driver) CreateEndpoint(_ context.Context, nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) (retErr error) {
if ifInfo == nil {
return errors.New("must not be called with nil InterfaceInfo")
}
Method TableEvent.MarshalToSizedBuffer
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m *TableEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
Method linuxParser.ParseMountRaw
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *linuxParser) ParseMountRaw(raw, volumeDriver string) (*MountPoint, error) {
arr := strings.SplitN(raw, ":", 4)
if arr[0] == "" {
return nil, errInvalidSpec(raw)
}