Browse Source

fix unused parameter lint warnings

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
Nicola Murino 3 years ago
parent
commit
7f5a13d185

+ 1 - 1
cmd/acme.go

@@ -40,7 +40,7 @@ Certificates are saved in the configured "certs_path".
 After this initial step, the certificates are automatically checked and
 renewed by the SFTPGo service
 `,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			logger.DisableLogger()
 			logger.EnableConsoleLogger(zerolog.DebugLevel)
 			configDir = util.CleanDirInput(configDir)

+ 1 - 1
cmd/awscontainer_disabled.go

@@ -21,4 +21,4 @@ import (
 	"github.com/spf13/cobra"
 )
 
-func addAWSContainerFlags(cmd *cobra.Command) {}
+func addAWSContainerFlags(_ *cobra.Command) {}

+ 1 - 1
cmd/genman.go

@@ -38,7 +38,7 @@ command-line interface.
 By default, it creates the man page files in the "man" directory under the
 current directory.
 `,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(cmd *cobra.Command, _ []string) {
 			logger.DisableLogger()
 			logger.EnableConsoleLogger(zerolog.DebugLevel)
 			if _, err := os.Stat(manDir); errors.Is(err, fs.ErrNotExist) {

+ 1 - 1
cmd/initprovider.go

@@ -49,7 +49,7 @@ To initialize/update the data provider from the configuration directory simply u
 $ sftpgo initprovider
 
 Please take a look at the usage below to customize the options.`,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			logger.DisableLogger()
 			logger.EnableConsoleLogger(zerolog.DebugLevel)
 			configDir = util.CleanDirInput(configDir)

+ 1 - 1
cmd/install_windows.go

@@ -35,7 +35,7 @@ line flags simply use:
 sftpgo service install
 
 Please take a look at the usage below to customize the startup options`,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			s := service.Service{
 				ConfigDir:     util.CleanDirInput(configDir),
 				ConfigFile:    configFile,

+ 1 - 1
cmd/portable.go

@@ -106,7 +106,7 @@ use:
 $ sftpgo portable
 
 Please take a look at the usage below to customize the serving parameters`,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			portableDir := directoryToServe
 			fsProvider := sdk.GetProviderByName(portableFsProvider)
 			if !filepath.IsAbs(portableDir) {

+ 1 - 1
cmd/reload_windows.go

@@ -27,7 +27,7 @@ var (
 	reloadCmd = &cobra.Command{
 		Use:   "reload",
 		Short: "Reload the SFTPGo Windows Service sending a \"paramchange\" request",
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			s := service.WindowsService{
 				Service: service.Service{
 					Shutdown: make(chan bool),

+ 1 - 1
cmd/resetprovider.go

@@ -39,7 +39,7 @@ configuration file and resets the provider by deleting all data and schemas.
 This command is not supported for the memory provider.
 
 Please take a look at the usage below to customize the options.`,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			logger.DisableLogger()
 			logger.EnableConsoleLogger(zerolog.DebugLevel)
 			configDir = util.CleanDirInput(configDir)

+ 1 - 1
cmd/revertprovider.go

@@ -37,7 +37,7 @@ configuration file and restore the provider schema and/or data to a previous ver
 This command is not supported for the memory provider.
 
 Please take a look at the usage below to customize the options.`,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			logger.DisableLogger()
 			logger.EnableConsoleLogger(zerolog.DebugLevel)
 			if revertProviderTargetVersion != 19 {

+ 1 - 1
cmd/rotatelogs_windows.go

@@ -27,7 +27,7 @@ var (
 	rotateLogCmd = &cobra.Command{
 		Use:   "rotatelogs",
 		Short: "Signal to the running service to rotate the logs",
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			s := service.WindowsService{
 				Service: service.Service{
 					Shutdown: make(chan bool),

+ 1 - 1
cmd/serve.go

@@ -33,7 +33,7 @@ use:
 $ sftpgo serve
 
 Please take a look at the usage below to customize the startup options`,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			service := service.Service{
 				ConfigDir:         util.CleanDirInput(configDir),
 				ConfigFile:        configFile,

+ 1 - 1
cmd/smtptest.go

@@ -33,7 +33,7 @@ var (
 		Short: "Test the SMTP configuration",
 		Long: `SFTPGo will try to send a test email to the specified recipient.
 If the SMTP configuration is correct you should receive this email.`,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			logger.DisableLogger()
 			logger.EnableConsoleLogger(zerolog.DebugLevel)
 			configDir = util.CleanDirInput(configDir)

+ 1 - 1
cmd/start_windows.go

@@ -29,7 +29,7 @@ var (
 	startCmd = &cobra.Command{
 		Use:   "start",
 		Short: "Start the SFTPGo Windows Service",
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			configDir = util.CleanDirInput(configDir)
 			if !filepath.IsAbs(logFilePath) && util.IsFileInputValid(logFilePath) {
 				logFilePath = filepath.Join(configDir, logFilePath)

+ 1 - 1
cmd/startsubsys.go

@@ -51,7 +51,7 @@ Subsystem	sftp	sftpgo startsubsys
 
 Command-line flags should be specified in the Subsystem declaration.
 `,
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			logSender := "startsubsys"
 			connectionID := xid.New().String()
 			var zeroLogLevel zerolog.Level

+ 1 - 1
cmd/status_windows.go

@@ -27,7 +27,7 @@ var (
 	statusCmd = &cobra.Command{
 		Use:   "status",
 		Short: "Retrieve the status for the SFTPGo Windows Service",
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			s := service.WindowsService{
 				Service: service.Service{
 					Shutdown: make(chan bool),

+ 1 - 1
cmd/stop_windows.go

@@ -27,7 +27,7 @@ var (
 	stopCmd = &cobra.Command{
 		Use:   "stop",
 		Short: "Stop the SFTPGo Windows Service",
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			s := service.WindowsService{
 				Service: service.Service{
 					Shutdown: make(chan bool),

+ 1 - 1
cmd/uninstall_windows.go

@@ -27,7 +27,7 @@ var (
 	uninstallCmd = &cobra.Command{
 		Use:   "uninstall",
 		Short: "Uninstall the SFTPGo Windows Service",
-		Run: func(cmd *cobra.Command, args []string) {
+		Run: func(_ *cobra.Command, _ []string) {
 			s := service.WindowsService{
 				Service: service.Service{
 					Shutdown: make(chan bool),

+ 1 - 1
common/tlsutils.go

@@ -97,7 +97,7 @@ func (m *CertManager) loadCertificates() error {
 
 // GetCertificateFunc returns the loaded certificate
 func (m *CertManager) GetCertificateFunc(certID string) func(*tls.ClientHelloInfo) (*tls.Certificate, error) {
-	return func(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) {
+	return func(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {
 		m.RLock()
 		defer m.RUnlock()
 

+ 1 - 1
dataprovider/bolt_disabled.go

@@ -27,6 +27,6 @@ func init() {
 	version.AddFeature("-bolt")
 }
 
-func initializeBoltProvider(basePath string) error {
+func initializeBoltProvider(_ string) error {
 	return errors.New("bolt disabled at build time")
 }

+ 1 - 1
dataprovider/sqlite_disabled.go

@@ -27,6 +27,6 @@ func init() {
 	version.AddFeature("-sqlite")
 }
 
-func initializeSQLiteProvider(basePath string) error {
+func initializeSQLiteProvider(_ string) error {
 	return errors.New("SQLite disabled at build time")
 }

File diff suppressed because it is too large
+ 2 - 2
httpd/httpd_test.go


+ 1 - 1
httpdtest/httpfsimpl.go

@@ -377,7 +377,7 @@ func (fs *httpFsImpl) dirsize(w http.ResponseWriter, r *http.Request) {
 	numFiles := 0
 	size := int64(0)
 	if info.IsDir() {
-		err = filepath.Walk(fsPath, func(path string, info os.FileInfo, err error) error {
+		err = filepath.Walk(fsPath, func(_ string, info os.FileInfo, err error) error {
 			if err != nil {
 				return err
 			}

+ 2 - 1
logger/logger.go

@@ -227,6 +227,7 @@ func CommandLog(command, path, target, user, fileMode, connectionID, protocol st
 	logger.Info().
 		Timestamp().
 		Str("sender", command).
+		Str("local_addr", localAddr).
 		Str("remote_addr", remoteAddr).
 		Str("username", user).
 		Str("file_path", path).
@@ -235,7 +236,7 @@ func CommandLog(command, path, target, user, fileMode, connectionID, protocol st
 		Int("uid", uid).
 		Int("gid", gid).
 		Str("access_time", atime).
-		Str("modification_time", atime).
+		Str("modification_time", mtime).
 		Int64("size", size).
 		Str("ssh_command", sshCommand).
 		Str("connection_id", connectionID).

+ 19 - 19
metric/metric_disabled.go

@@ -14,62 +14,62 @@ func init() {
 }
 
 // AddMetricsEndpoint exposes metrics to the specified endpoint
-func AddMetricsEndpoint(metricsPath string, handler chi.Router) {}
+func AddMetricsEndpoint(_ string, _ chi.Router) {}
 
 // TransferCompleted updates metrics after an upload or a download
-func TransferCompleted(bytesSent, bytesReceived int64, transferKind int, err error, isSFTPFs bool) {}
+func TransferCompleted(_, _ int64, _ int, _ error, _ bool) {}
 
 // S3TransferCompleted updates metrics after an S3 upload or a download
-func S3TransferCompleted(bytes int64, transferKind int, err error) {}
+func S3TransferCompleted(_ int64, _ int, _ error) {}
 
 // S3ListObjectsCompleted updates metrics after an S3 list objects request terminates
-func S3ListObjectsCompleted(err error) {}
+func S3ListObjectsCompleted(_ error) {}
 
 // S3CopyObjectCompleted updates metrics after an S3 copy object request terminates
-func S3CopyObjectCompleted(err error) {}
+func S3CopyObjectCompleted(_ error) {}
 
 // S3DeleteObjectCompleted updates metrics after an S3 delete object request terminates
-func S3DeleteObjectCompleted(err error) {}
+func S3DeleteObjectCompleted(_ error) {}
 
 // S3HeadBucketCompleted updates metrics after an S3 head bucket request terminates
-func S3HeadBucketCompleted(err error) {}
+func S3HeadBucketCompleted(_ error) {}
 
 // GCSTransferCompleted updates metrics after a GCS upload or a download
-func GCSTransferCompleted(bytes int64, transferKind int, err error) {}
+func GCSTransferCompleted(_ int64, _ int, _ error) {}
 
 // GCSListObjectsCompleted updates metrics after a GCS list objects request terminates
-func GCSListObjectsCompleted(err error) {}
+func GCSListObjectsCompleted(_ error) {}
 
 // GCSCopyObjectCompleted updates metrics after a GCS copy object request terminates
-func GCSCopyObjectCompleted(err error) {}
+func GCSCopyObjectCompleted(_ error) {}
 
 // GCSDeleteObjectCompleted updates metrics after a GCS delete object request terminates
-func GCSDeleteObjectCompleted(err error) {}
+func GCSDeleteObjectCompleted(_ error) {}
 
 // GCSHeadBucketCompleted updates metrics after a GCS head bucket request terminates
-func GCSHeadBucketCompleted(err error) {}
+func GCSHeadBucketCompleted(_ error) {}
 
 // HTTPFsTransferCompleted updates metrics after an HTTPFs upload or a download
-func HTTPFsTransferCompleted(bytes int64, transferKind int, err error) {}
+func HTTPFsTransferCompleted(_ int64, _ int, _ error) {}
 
 // SSHCommandCompleted update metrics after an SSH command terminates
-func SSHCommandCompleted(err error) {}
+func SSHCommandCompleted(_ error) {}
 
 // UpdateDataProviderAvailability updates the metric for the data provider availability
-func UpdateDataProviderAvailability(err error) {}
+func UpdateDataProviderAvailability(_ error) {}
 
 // AddLoginAttempt increments the metrics for login attempts
-func AddLoginAttempt(authMethod string) {}
+func AddLoginAttempt(_ string) {}
 
 // AddLoginResult increments the metrics for login results
-func AddLoginResult(authMethod string, err error) {}
+func AddLoginResult(_ string, _ error) {}
 
 // AddNoAuthTryed increments the metric for clients disconnected
 // for inactivity before trying to login
 func AddNoAuthTryed() {}
 
 // HTTPRequestServed increments the metrics for HTTP requests
-func HTTPRequestServed(status int) {}
+func HTTPRequestServed(_ int) {}
 
 // UpdateActiveConnectionsSize sets the metric for active connections
-func UpdateActiveConnectionsSize(size int) {}
+func UpdateActiveConnectionsSize(_ int) {}

+ 1 - 1
service/awscontainer_disabled.go

@@ -17,6 +17,6 @@
 
 package service
 
-func registerAWSContainer(disableAWSInstallationCode bool) error {
+func registerAWSContainer(_ bool) error {
 	return nil
 }

+ 1 - 1
sftpd/cmd_windows.go

@@ -18,6 +18,6 @@ import (
 	"os/exec"
 )
 
-func wrapCmd(cmd *exec.Cmd, uid, gid int) *exec.Cmd {
+func wrapCmd(cmd *exec.Cmd, _, _ int) *exec.Cmd {
 	return cmd
 }

+ 2 - 2
sftpd/httpfs_test.go

@@ -247,7 +247,7 @@ func TestHTTPFsWalk(t *testing.T) {
 	assert.NoError(t, err)
 
 	var walkedPaths []string
-	err = httpFs.Walk("/", func(walkedPath string, info fs.FileInfo, err error) error {
+	err = httpFs.Walk("/", func(walkedPath string, _ fs.FileInfo, err error) error {
 		if err != nil {
 			return err
 		}
@@ -269,7 +269,7 @@ func TestHTTPFsWalk(t *testing.T) {
 		}
 	}
 	walkedPaths = nil
-	err = httpFs.Walk("/", func(walkedPath string, info fs.FileInfo, err error) error {
+	err = httpFs.Walk("/", func(walkedPath string, _ fs.FileInfo, err error) error {
 		if err != nil {
 			return err
 		}

+ 2 - 2
sftpd/sftpd_test.go

@@ -2719,7 +2719,7 @@ func TestInteractiveLoginWithPasscode(t *testing.T) {
 	passwordAsked := false
 	passcodeAsked := false
 	authMethods := []ssh.AuthMethod{
-		ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
+		ssh.KeyboardInteractive(func(_, _ string, questions []string, _ []bool) ([]string, error) {
 			var answers []string
 			if strings.HasPrefix(questions[0], "Password") {
 				answers = append(answers, defaultPassword)
@@ -2768,7 +2768,7 @@ func TestInteractiveLoginWithPasscode(t *testing.T) {
 	_, _, err = getCustomAuthSftpClient(user, authMethods, "")
 	assert.Error(t, err)
 	authMethods = []ssh.AuthMethod{
-		ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {
+		ssh.KeyboardInteractive(func(_, _ string, questions []string, _ []bool) ([]string, error) {
 			var answers []string
 			if strings.HasPrefix(questions[0], "Password") {
 				answers = append(answers, defaultPassword)

+ 1 - 1
vfs/azblobfs_disabled.go

@@ -28,6 +28,6 @@ func init() {
 }
 
 // NewAzBlobFs returns an error, Azure Blob storage is disabled
-func NewAzBlobFs(connectionID, localTempDir, mountPath string, config AzBlobFsConfig) (Fs, error) {
+func NewAzBlobFs(_, _, _ string, _ AzBlobFsConfig) (Fs, error) {
 	return nil, errors.New("Azure Blob Storage disabled at build time")
 }

+ 1 - 1
vfs/gcsfs_disabled.go

@@ -28,6 +28,6 @@ func init() {
 }
 
 // NewGCSFs returns an error, GCS is disabled
-func NewGCSFs(connectionID, localTempDir, mountPath string, config GCSFsConfig) (Fs, error) {
+func NewGCSFs(_, _, _ string, _ GCSFsConfig) (Fs, error) {
 	return nil, errors.New("Google Cloud Storage disabled at build time")
 }

+ 2 - 2
vfs/httpfs.go

@@ -216,7 +216,7 @@ func NewHTTPFs(connectionID, localTempDir, mountPath string, config HTTPFsConfig
 				return nil, fmt.Errorf("httpfs: invalid unix domain socket path: %q", socketPath)
 			}
 			if endpointURL.Scheme == "https" {
-				transport.DialTLSContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
+				transport.DialTLSContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
 					var tlsConfig *tls.Config
 					var d tls.Dialer
 					if config.SkipTLSVerify {
@@ -226,7 +226,7 @@ func NewHTTPFs(connectionID, localTempDir, mountPath string, config HTTPFsConfig
 					return d.DialContext(ctx, "unix", socketPath)
 				}
 			} else {
-				transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
+				transport.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
 					var d net.Dialer
 					return d.DialContext(ctx, "unix", socketPath)
 				}

+ 1 - 1
vfs/osfs.go

@@ -372,7 +372,7 @@ func (fs *OsFs) GetDirSize(dirname string) (int, int64, error) {
 	size := int64(0)
 	isDir, err := IsDirectory(fs, dirname)
 	if err == nil && isDir {
-		err = filepath.Walk(dirname, func(path string, info os.FileInfo, err error) error {
+		err = filepath.Walk(dirname, func(_ string, info os.FileInfo, err error) error {
 			if err != nil {
 				return err
 			}

+ 1 - 1
vfs/s3fs_disabled.go

@@ -28,6 +28,6 @@ func init() {
 }
 
 // NewS3Fs returns an error, S3 is disabled
-func NewS3Fs(connectionID, localTempDir, mountPath string, config S3FsConfig) (Fs, error) {
+func NewS3Fs(_, _, _ string, _ S3FsConfig) (Fs, error) {
 	return nil, errors.New("S3 disabled at build time")
 }

+ 1 - 1
vfs/sftpfs.go

@@ -827,7 +827,7 @@ func (fs *SFTPFs) createConnection() error {
 	var err error
 	clientConfig := &ssh.ClientConfig{
 		User: fs.config.Username,
-		HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
+		HostKeyCallback: func(_ string, _ net.Addr, key ssh.PublicKey) error {
 			fp := ssh.FingerprintSHA256(key)
 			if util.Contains(sftpFingerprints, fp) {
 				if util.Contains(fs.config.forbiddenSelfUsernames, fs.config.Username) {

Some files were not shown because too many files changed in this diff