mirror of
https://github.com/minio/mc.git
synced 2025-11-10 13:42:32 +03:00
add new linters and fix unnecessary type conversions (#3835)
This commit is contained in:
@@ -8,15 +8,20 @@ linters-settings:
|
|||||||
linters:
|
linters:
|
||||||
disable-all: true
|
disable-all: true
|
||||||
enable:
|
enable:
|
||||||
- revive
|
|
||||||
- typecheck
|
- typecheck
|
||||||
- goimports
|
- goimports
|
||||||
- misspell
|
- misspell
|
||||||
- govet
|
- govet
|
||||||
|
- revive
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- gosimple
|
- gosimple
|
||||||
- deadcode
|
- deadcode
|
||||||
- structcheck
|
- structcheck
|
||||||
|
- gomodguard
|
||||||
|
- gofmt
|
||||||
|
- unused
|
||||||
|
- structcheck
|
||||||
|
- varcheck
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
@@ -24,5 +29,6 @@ issues:
|
|||||||
- instead of using struct literal
|
- instead of using struct literal
|
||||||
- should have a package comment
|
- should have a package comment
|
||||||
- error strings should not be capitalized or end with punctuation or a newline
|
- error strings should not be capitalized or end with punctuation or a newline
|
||||||
|
|
||||||
service:
|
service:
|
||||||
golangci-lint-version: 1.20.0 # use the fixed version to not introduce new linters unexpectedly
|
golangci-lint-version: 1.20.0 # use the fixed version to not introduce new linters unexpectedly
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ func (u clusterStruct) String() (msg string) {
|
|||||||
|
|
||||||
// Summary on used space, total no of buckets and
|
// Summary on used space, total no of buckets and
|
||||||
// total no of objects at the Cluster level
|
// total no of objects at the Cluster level
|
||||||
usedTotal := humanize.IBytes(uint64(u.Info.Usage.Size))
|
usedTotal := humanize.IBytes(u.Info.Usage.Size)
|
||||||
if u.Info.Buckets.Count > 0 {
|
if u.Info.Buckets.Count > 0 {
|
||||||
msg += fmt.Sprintf("%s Used, %s, %s\n", usedTotal,
|
msg += fmt.Sprintf("%s Used, %s, %s\n", usedTotal,
|
||||||
english.Plural(int(u.Info.Buckets.Count), "Bucket", ""),
|
english.Plural(int(u.Info.Buckets.Count), "Bucket", ""),
|
||||||
@@ -281,7 +281,7 @@ func mainAdminInfo(ctx *cli.Context) error {
|
|||||||
clusterInfo.Error = ""
|
clusterInfo.Error = ""
|
||||||
}
|
}
|
||||||
clusterInfo.Info = admInfo
|
clusterInfo.Info = admInfo
|
||||||
printMsg(clusterStruct(clusterInfo))
|
printMsg(clusterInfo)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ func mainAdminPolicyAdd(ctx *cli.Context) error {
|
|||||||
client, err := newAdminClient(aliasedURL)
|
client, err := newAdminClient(aliasedURL)
|
||||||
fatalIf(err, "Unable to initialize admin connection.")
|
fatalIf(err, "Unable to initialize admin connection.")
|
||||||
|
|
||||||
fatalIf(probe.NewError(client.AddCannedPolicy(globalContext, args.Get(1), []byte(policy))).Trace(args...), "Unable to add new policy")
|
fatalIf(probe.NewError(client.AddCannedPolicy(globalContext, args.Get(1), policy)).Trace(args...), "Unable to add new policy")
|
||||||
|
|
||||||
printMsg(userPolicyMessage{
|
printMsg(userPolicyMessage{
|
||||||
op: "add",
|
op: "add",
|
||||||
|
|||||||
@@ -86,10 +86,10 @@ func (s speedTestResult) String() (msg string) {
|
|||||||
if globalSpeedTestVerbose {
|
if globalSpeedTestVerbose {
|
||||||
msg += "\n"
|
msg += "\n"
|
||||||
}
|
}
|
||||||
msg += fmt.Sprintf("PUT: %s/s, %d objs/s\n", humanize.IBytes(uint64(s.PUTStats.ThroughputPerSec)), s.PUTStats.ObjectsPerSec)
|
msg += fmt.Sprintf("PUT: %s/s, %d objs/s\n", humanize.IBytes(s.PUTStats.ThroughputPerSec), s.PUTStats.ObjectsPerSec)
|
||||||
if globalSpeedTestVerbose {
|
if globalSpeedTestVerbose {
|
||||||
for _, node := range s.PUTStats.Servers {
|
for _, node := range s.PUTStats.Servers {
|
||||||
msg += fmt.Sprintf(" * %s:, %s/s, %d objs/s", node.Endpoint, humanize.IBytes(uint64(node.ThroughputPerSec)), node.ObjectsPerSec)
|
msg += fmt.Sprintf(" * %s:, %s/s, %d objs/s", node.Endpoint, humanize.IBytes(node.ThroughputPerSec), node.ObjectsPerSec)
|
||||||
if node.Err != "" {
|
if node.Err != "" {
|
||||||
msg += " error: " + node.Err
|
msg += " error: " + node.Err
|
||||||
}
|
}
|
||||||
@@ -100,10 +100,10 @@ func (s speedTestResult) String() (msg string) {
|
|||||||
if globalSpeedTestVerbose {
|
if globalSpeedTestVerbose {
|
||||||
msg += "\n"
|
msg += "\n"
|
||||||
}
|
}
|
||||||
msg += fmt.Sprintf("GET: %s/s, %d objs/s\n", humanize.IBytes(uint64(s.GETStats.ThroughputPerSec)), s.GETStats.ObjectsPerSec)
|
msg += fmt.Sprintf("GET: %s/s, %d objs/s\n", humanize.IBytes(s.GETStats.ThroughputPerSec), s.GETStats.ObjectsPerSec)
|
||||||
if globalSpeedTestVerbose {
|
if globalSpeedTestVerbose {
|
||||||
for _, node := range s.GETStats.Servers {
|
for _, node := range s.GETStats.Servers {
|
||||||
msg += fmt.Sprintf(" * %s:, %s/s, %d objs/s", node.Endpoint, humanize.IBytes(uint64(node.ThroughputPerSec)), node.ObjectsPerSec)
|
msg += fmt.Sprintf(" * %s:, %s/s, %d objs/s", node.Endpoint, humanize.IBytes(node.ThroughputPerSec), node.ObjectsPerSec)
|
||||||
if node.Err != "" {
|
if node.Err != "" {
|
||||||
msg += " error: " + node.Err
|
msg += " error: " + node.Err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ func uploadHealthReport(alias string, filename string, reqURL string, headers ma
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg := "MinIO Health data was successfully uploaded to SUBNET."
|
msg := "MinIO Health data was successfully uploaded to SUBNET."
|
||||||
clusterURL, _ := url.PathUnescape(gjson.Get(string(resp), "cluster_url").String())
|
clusterURL, _ := url.PathUnescape(gjson.Get(resp, "cluster_url").String())
|
||||||
if len(clusterURL) > 0 {
|
if len(clusterURL) > 0 {
|
||||||
msg += fmt.Sprintf(" Can be viewed at: %s", clusterURL)
|
msg += fmt.Sprintf(" Can be viewed at: %s", clusterURL)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ func colorizedNodeName(nodeName string) string {
|
|||||||
nodeHash := fnv.New32a()
|
nodeHash := fnv.New32a()
|
||||||
nodeHash.Write([]byte(nodeName))
|
nodeHash.Write([]byte(nodeName))
|
||||||
nHashSum := nodeHash.Sum32()
|
nHashSum := nodeHash.Sum32()
|
||||||
idx := uint32(nHashSum) % uint32(len(colors))
|
idx := nHashSum % uint32(len(colors))
|
||||||
return console.Colorize(fmt.Sprintf("Node%d", colors[idx]), nodeName)
|
return console.Colorize(fmt.Sprintf("Node%d", colors[idx]), nodeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ type anonymousLinksMessage struct {
|
|||||||
|
|
||||||
// String colorized access message.
|
// String colorized access message.
|
||||||
func (s anonymousLinksMessage) String() string {
|
func (s anonymousLinksMessage) String() string {
|
||||||
return console.Colorize("Anonymous", string(s.URL))
|
return console.Colorize("Anonymous", s.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON jsonified anonymous message.
|
// JSON jsonified anonymous message.
|
||||||
@@ -203,7 +203,7 @@ func checkAnonymousSyntax(ctx *cli.Context) {
|
|||||||
accessPerms(secondArg) != accessPrivate &&
|
accessPerms(secondArg) != accessPrivate &&
|
||||||
accessPerms(secondArg) != accessPublic {
|
accessPerms(secondArg) != accessPublic {
|
||||||
fatalIf(errDummy().Trace(),
|
fatalIf(errDummy().Trace(),
|
||||||
"Unrecognized permission `"+string(secondArg)+"`. Allowed values are [private, public, download, upload].")
|
"Unrecognized permission `"+secondArg+"`. Allowed values are [private, public, download, upload].")
|
||||||
}
|
}
|
||||||
|
|
||||||
case "set-json":
|
case "set-json":
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ func isNotSupported(e error) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if filesystem supports extended attributes
|
// check if filesystem supports extended attributes
|
||||||
return errno.Err == syscall.Errno(syscall.ENOTSUP) || errno.Err == syscall.Errno(syscall.EOPNOTSUPP)
|
return errno.Err == syscall.ENOTSUP || errno.Err == syscall.EOPNOTSUPP
|
||||||
}
|
}
|
||||||
|
|
||||||
// isIgnoredFile returns true if 'filename' is on the exclude list.
|
// isIgnoredFile returns true if 'filename' is on the exclude list.
|
||||||
|
|||||||
@@ -1900,26 +1900,6 @@ func (c *S3Client) listIncompleteRecursiveInRoutine(ctx context.Context, content
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert objectMultipartInfo to ClientContent
|
|
||||||
func (c *S3Client) objectMultipartInfo2ClientContent(bucket string, entry minio.ObjectMultipartInfo) ClientContent {
|
|
||||||
|
|
||||||
content := ClientContent{}
|
|
||||||
url := c.targetURL.Clone()
|
|
||||||
// Join bucket and incoming object key.
|
|
||||||
url.Path = c.joinPath(bucket, entry.Key)
|
|
||||||
content.URL = url
|
|
||||||
content.Size = entry.Size
|
|
||||||
content.Time = entry.Initiated
|
|
||||||
|
|
||||||
if strings.HasSuffix(entry.Key, string(c.targetURL.Separator)) {
|
|
||||||
content.Type = os.ModeDir
|
|
||||||
} else {
|
|
||||||
content.Type = os.ModeTemporary
|
|
||||||
}
|
|
||||||
|
|
||||||
return content
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns new path by joining path segments with URL path separator.
|
// Returns new path by joining path segments with URL path separator.
|
||||||
func (c *S3Client) joinPath(bucket string, objects ...string) string {
|
func (c *S3Client) joinPath(bucket string, objects ...string) string {
|
||||||
p := string(c.targetURL.Separator) + bucket
|
p := string(c.targetURL.Separator) + bucket
|
||||||
|
|||||||
@@ -158,9 +158,9 @@ func (h objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// Test bucket operations.
|
// Test bucket operations.
|
||||||
func (s *TestSuite) TestBucketOperations(c *C) {
|
func (s *TestSuite) TestBucketOperations(c *C) {
|
||||||
bucket := bucketHandler(bucketHandler{
|
bucket := bucketHandler{
|
||||||
resource: "/bucket/",
|
resource: "/bucket/",
|
||||||
})
|
}
|
||||||
server := httptest.NewServer(bucket)
|
server := httptest.NewServer(bucket)
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -205,10 +205,10 @@ func (s *TestSuite) TestBucketOperations(c *C) {
|
|||||||
|
|
||||||
// Test all object operations.
|
// Test all object operations.
|
||||||
func (s *TestSuite) TestObjectOperations(c *C) {
|
func (s *TestSuite) TestObjectOperations(c *C) {
|
||||||
object := objectHandler(objectHandler{
|
object := objectHandler{
|
||||||
resource: "/bucket/object",
|
resource: "/bucket/object",
|
||||||
data: []byte("Hello, World"),
|
data: []byte("Hello, World"),
|
||||||
})
|
}
|
||||||
server := httptest.NewServer(object)
|
server := httptest.NewServer(object)
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ func uploadSourceToTargetURL(ctx context.Context, urls URLs, progress io.Reader,
|
|||||||
md5: urls.MD5,
|
md5: urls.MD5,
|
||||||
disableMultipart: urls.DisableMultipart,
|
disableMultipart: urls.DisableMultipart,
|
||||||
isPreserve: preserve,
|
isPreserve: preserve,
|
||||||
multipartSize: uint64(multipartSize),
|
multipartSize: multipartSize,
|
||||||
multipartThreads: uint(multipartThreads),
|
multipartThreads: uint(multipartThreads),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ type policyLinksMessage struct {
|
|||||||
|
|
||||||
// String colorized access message.
|
// String colorized access message.
|
||||||
func (s policyLinksMessage) String() string {
|
func (s policyLinksMessage) String() string {
|
||||||
return console.Colorize("Policy", string(s.URL))
|
return console.Colorize("Policy", s.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON jsonified policy message.
|
// JSON jsonified policy message.
|
||||||
@@ -200,7 +200,7 @@ func checkPolicySyntax(ctx *cli.Context) {
|
|||||||
accessPerms(secondArg) != accessUpload &&
|
accessPerms(secondArg) != accessUpload &&
|
||||||
accessPerms(secondArg) != accessPublic {
|
accessPerms(secondArg) != accessPublic {
|
||||||
fatalIf(errDummy().Trace(),
|
fatalIf(errDummy().Trace(),
|
||||||
"Unrecognized permission `"+string(secondArg)+"`. Allowed values are [none, download, upload, public].")
|
"Unrecognized permission `"+secondArg+"`. Allowed values are [none, download, upload, public].")
|
||||||
}
|
}
|
||||||
|
|
||||||
case "set-json":
|
case "set-json":
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ func parseAtimeMtime(attr map[string]string) (atime, mtime time.Time, err *probe
|
|||||||
return atime, mtime, probe.NewError(e)
|
return atime, mtime, probe.NewError(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
atime = time.Unix(int64(atim), int64(atimnsec))
|
atime = time.Unix(atim, atimnsec)
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := attr["mtime"]; ok {
|
if val, ok := attr["mtime"]; ok {
|
||||||
@@ -359,7 +359,7 @@ func parseAtimeMtime(attr map[string]string) (atime, mtime time.Time, err *probe
|
|||||||
return atime, mtime, probe.NewError(e)
|
return atime, mtime, probe.NewError(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mtime = time.Unix(int64(mtim), int64(mtimnsec))
|
mtime = time.Unix(mtim, mtimnsec)
|
||||||
}
|
}
|
||||||
return atime, mtime, nil
|
return atime, mtime, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user