Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nydusify: utilize golangci-lint to perform static check #258

Merged
merged 2 commits into from
Jan 7, 2022
Merged

nydusify: utilize golangci-lint to perform static check #258

merged 2 commits into from
Jan 7, 2022

Conversation

changweige
Copy link
Contributor

@changweige changweige commented Jan 6, 2022

Add golangci-lint rules definition into

This also partly addresses #255

func (p *Parser) matchImagePlatform(desc *ocispec.Descriptor) bool {
if p.interestedArch == desc.Platform.Architecture && desc.Platform.OS == "linux" {
func (parser *Parser) matchImagePlatform(desc *ocispec.Descriptor) bool {
if parser.interestedArch == desc.Platform.Architecture && desc.Platform.OS == "linux" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this suggestion from golangci-lint, we are never using single char as a variable name.

Add golangci-lint rules definition into.

Signed-off-by: Changwei Ge <chge@linux.alibaba.com>
As golangci-lint reports:

pkg/checker/tool/builder.go:35:2: S1021: should merge variable declaration with assignment on next line (gosimple)
    var args []string
    ^
pkg/checker/tool/nydusd.go:160:2: S1021: should merge variable declaration with assignment on next line (gosimple)
    var args []string
    ^
pkg/backend/backend.go:38:27: var-naming: func parameter blobId should be blobID (revive)
func blobDesc(size int64, blobId string) ocispec.Descriptor {
                          ^
pkg/backend/backend.go:31:6: exported: type name will be used as backend.BackendType by other packages, and that stutters; consider calling this Type (revive)
type BackendType = int
     ^
pkg/backend/oss.go:123:21: var-declaration: should omit type bool from declaration of var needMultiparts; it will be inferred from the right-hand side (revive)
    var needMultiparts bool = false
                       ^
pkg/backend/oss.go:130:21: var-declaration: should drop = 0 from declaration of var crc64; it is the zero value (revive)
    var crc64 uint64 = 0
                       ^
pkg/backend/oss.go:240:1: receiver-naming: receiver name r should be consistent with previous receiver name b for OSSBackend (revive)
func (r *OSSBackend) Type() BackendType {
    return OssBackend
}
pkg/metrics/file_exporter/file_exporter.go:5:1: var-naming: don't use an underscore in package name (revive)
package file_exporter

import (
    "github.com/prometheus/client_golang/prometheus"

    "github.com/dragonflyoss/image-service/contrib/nydusify/pkg/metrics"
)

type FileExporter struct{ name string }

func New(name string) *FileExporter {
    return &FileExporter{
        name: name,
    }
}

func (exp *FileExporter) Export() {
    prometheus.WriteToTextfile(exp.name, metrics.Registry)
}
cmd/nydusify.go:314:14: ineffectual assignment to err (ineffassign)
                _, arch, err := provider.ExtractOsArch(c.String("platform"))
                         ^
pkg/cache/spec.go:12:6: exported: type name will be used as cache.CacheManifest by other packages, and that stutters; consider calling this Manifest (revive)
type CacheManifest struct {
     ^
pkg/cache/spec.go:17:6: exported: type name will be used as cache.CacheRecord by other packages, and that stutters; consider calling this Record (revive)
type CacheRecord struct {
     ^
pkg/converter/cache.go:81:50: `diffrent` is a misspelling of `different` (misspell)
        // because the blob data is not shared between diffrent namespaces in registry,
                                                       ^
tests/registry.go:51:27: `Destory` is a misspelling of `Destroy` (misspell)
func (registry *Registry) Destory(t *testing.T) {
                          ^
pkg/parser/parser.go:167:1: receiver-naming: receiver name p should be consistent with previous receiver name parser for Parser (revive)
func (p *Parser) matchImagePlatform(desc *ocispec.Descriptor) bool {
    if p.interestedArch == desc.Platform.Architecture && desc.Platform.OS == "linux" {
        return true
    }
    return false

Signed-off-by: Changwei Ge <chge@linux.alibaba.com>
@imeoer imeoer merged commit 27f7db0 into dragonflyoss:master Jan 7, 2022
@changweige changweige deleted the add-golangci-lint-nydusify branch January 18, 2022 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants