cleanup: resolve nlreturn linter issues

nlreturn linter requires a new line before return
and branch statements except when the return is alone
inside a statement group (such as an if statement) to
increase code clarity. This commit addresses such issues.

Updates: #1586

Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
Rakshith R
2021-07-22 11:15:17 +05:30
committed by mergify[bot]
parent 5c016b4b94
commit 43f753760b
74 changed files with 716 additions and 0 deletions

View File

@ -75,6 +75,7 @@ func (cs *DefaultControllerServer) ControllerGetCapabilities(
if cs.Driver == nil {
return nil, status.Error(codes.Unimplemented, "Controller server is not enabled")
}
return &csi.ControllerGetCapabilitiesResponse{
Capabilities: cs.Driver.capabilities,
}, nil

View File

@ -44,16 +44,19 @@ type CSIDriver struct {
func NewCSIDriver(name, v, nodeID string) *CSIDriver {
if name == "" {
klog.Errorf("Driver name missing")
return nil
}
if nodeID == "" {
klog.Errorf("NodeID missing")
return nil
}
// TODO version format and validation
if v == "" {
klog.Errorf("Version argument missing")
return nil
}
@ -78,6 +81,7 @@ func (d *CSIDriver) ValidateControllerServiceRequest(c csi.ControllerServiceCapa
return nil
}
}
return status.Error(codes.InvalidArgument, fmt.Sprintf("%s", c)) //nolint
}
@ -103,6 +107,7 @@ func (d *CSIDriver) AddVolumeCapabilityAccessModes(
vca = append(vca, NewVolumeCapabilityAccessMode(c))
}
d.vc = vca
return vca
}

View File

@ -61,6 +61,7 @@ func (ids *DefaultIdentityServer) GetPluginCapabilities(
ctx context.Context,
req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
util.TraceLog(ctx, "Using default capabilities")
return &csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{
{

View File

@ -104,6 +104,7 @@ func ConstructMountOptions(mountOptions []string, volCap *csi.VolumeCapability)
return true
}
}
return false
}
for _, f := range m.MountFlags {
@ -112,6 +113,7 @@ func ConstructMountOptions(mountOptions []string, volCap *csi.VolumeCapability)
}
}
}
return mountOptions
}
@ -122,5 +124,6 @@ func MountOptionContains(mountOptions []string, opt string) bool {
return true
}
}
return false
}

View File

@ -44,6 +44,7 @@ func parseEndpoint(ep string) (string, string, error) {
return s[0], s[1], nil
}
}
return "", "", fmt.Errorf("invalid endpoint: %v", ep)
}
@ -55,6 +56,7 @@ func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *c
// NewDefaultNodeServer initializes default node server.
func NewDefaultNodeServer(d *CSIDriver, t string, topology map[string]string) *DefaultNodeServer {
d.topology = topology
return &DefaultNodeServer{
Driver: d,
Type: t,
@ -98,6 +100,7 @@ func isReplicationRequest(req interface{}) bool {
default:
isReplicationRequest = false
}
return isReplicationRequest
}
@ -145,6 +148,7 @@ func getReqID(req interface{}) string {
case *replication.ResyncVolumeRequest:
reqID = r.VolumeId
}
return reqID
}
@ -160,6 +164,7 @@ func contextIDInjector(
if reqID := getReqID(req); reqID != "" {
ctx = context.WithValue(ctx, util.ReqID, reqID)
}
return handler(ctx, req)
}
@ -181,6 +186,7 @@ func logGRPC(
} else {
util.TraceLog(ctx, "GRPC response: %s", protosanitizer.StripSecrets(resp))
}
return resp, err
}
@ -196,6 +202,7 @@ func panicHandler(
err = status.Errorf(codes.Internal, "panic %v", r)
}
}()
return handler(ctx, req)
}
@ -209,6 +216,7 @@ func FilesystemNodeGetVolumeStats(ctx context.Context, targetPath string) (*csi.
if os.IsNotExist(err) {
return nil, status.Errorf(codes.InvalidArgument, "targetpath %s does not exist", targetPath)
}
return nil, status.Error(codes.Internal, err.Error())
}
if !isMnt {
@ -228,6 +236,7 @@ func FilesystemNodeGetVolumeStats(ctx context.Context, targetPath string) (*csi.
capacity, ok := (*(volMetrics.Capacity)).AsInt64()
if !ok {
util.ErrorLog(ctx, "failed to fetch capacity bytes")
return nil, status.Error(codes.Unknown, "failed to fetch capacity bytes")
}
used, ok := (*(volMetrics.Used)).AsInt64()
@ -237,6 +246,7 @@ func FilesystemNodeGetVolumeStats(ctx context.Context, targetPath string) (*csi.
inodes, ok := (*(volMetrics.Inodes)).AsInt64()
if !ok {
util.ErrorLog(ctx, "failed to fetch available inodes")
return nil, status.Error(codes.Unknown, "failed to fetch available inodes")
}
inodesFree, ok := (*(volMetrics.InodesFree)).AsInt64()
@ -248,6 +258,7 @@ func FilesystemNodeGetVolumeStats(ctx context.Context, targetPath string) (*csi.
if !ok {
util.ErrorLog(ctx, "failed to fetch used inodes")
}
return &csi.NodeGetVolumeStatsResponse{
Usage: []*csi.VolumeUsage{
{