Skip to content

Commit

Permalink
Fix: Implement golangci-lint suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
reglim committed Sep 21, 2023
1 parent f4a152a commit ae61706
Show file tree
Hide file tree
Showing 27 changed files with 51 additions and 62 deletions.
4 changes: 2 additions & 2 deletions azure/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (storage *PublishedStorage) String() string {
}

// MkDir creates directory recursively under public path
func (storage *PublishedStorage) MkDir(path string) error {
func (storage *PublishedStorage) MkDir(_ string) error {
// no op for Azure
return nil
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func (storage *PublishedStorage) putFile(path string, source io.Reader, sourceMD
}

// RemoveDirs removes directory structure under public path
func (storage *PublishedStorage) RemoveDirs(path string, progress aptly.Progress) error {
func (storage *PublishedStorage) RemoveDirs(path string, _ aptly.Progress) error {
filelist, err := storage.Filelist(path)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/config_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/smira/commander"
)

func aptlyConfigShow(cmd *commander.Command, args []string) error {
func aptlyConfigShow(_ *commander.Command, _ []string) error {

config := context.Config()
prettyJSON, err := json.MarshalIndent(config, "", " ")
Expand Down
4 changes: 2 additions & 2 deletions cmd/mirror_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func aptlyMirrorList(cmd *commander.Command, args []string) error {
return aptlyMirrorListTxt(cmd, args)
}

func aptlyMirrorListTxt(cmd *commander.Command, args []string) error {
func aptlyMirrorListTxt(cmd *commander.Command, _ []string) error {
var err error

raw := cmd.Flag.Lookup("raw").Value.Get().(bool)
Expand Down Expand Up @@ -65,7 +65,7 @@ func aptlyMirrorListTxt(cmd *commander.Command, args []string) error {
return err
}

func aptlyMirrorListJSON(cmd *commander.Command, args []string) error {
func aptlyMirrorListJSON(_ *commander.Command, _ []string) error {
var err error

repos := make([]*deb.RemoteRepo, context.NewCollectionFactory().RemoteRepoCollection().Len())
Expand Down
4 changes: 2 additions & 2 deletions cmd/mirror_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func aptlyMirrorShow(cmd *commander.Command, args []string) error {
return aptlyMirrorShowTxt(cmd, args)
}

func aptlyMirrorShowTxt(cmd *commander.Command, args []string) error {
func aptlyMirrorShowTxt(_ *commander.Command, args []string) error {
var err error

name := args[0]
Expand Down Expand Up @@ -93,7 +93,7 @@ func aptlyMirrorShowTxt(cmd *commander.Command, args []string) error {
return err
}

func aptlyMirrorShowJSON(cmd *commander.Command, args []string) error {
func aptlyMirrorShowJSON(_ *commander.Command, args []string) error {
var err error

name := args[0]
Expand Down
4 changes: 2 additions & 2 deletions cmd/publish_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func aptlyPublishList(cmd *commander.Command, args []string) error {
return aptlyPublishListTxt(cmd, args)
}

func aptlyPublishListTxt(cmd *commander.Command, args []string) error {
func aptlyPublishListTxt(cmd *commander.Command, _ []string) error {
var err error

raw := cmd.Flag.Lookup("raw").Value.Get().(bool)
Expand Down Expand Up @@ -77,7 +77,7 @@ func aptlyPublishListTxt(cmd *commander.Command, args []string) error {
return err
}

func aptlyPublishListJSON(cmd *commander.Command, args []string) error {
func aptlyPublishListJSON(_ *commander.Command, _ []string) error {
var err error

repos := make([]*deb.PublishedRepo, 0, context.NewCollectionFactory().PublishedRepoCollection().Len())
Expand Down
4 changes: 2 additions & 2 deletions cmd/publish_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func aptlyPublishShow(cmd *commander.Command, args []string) error {
return aptlyPublishShowTxt(cmd, args)
}

func aptlyPublishShowTxt(cmd *commander.Command, args []string) error {
func aptlyPublishShowTxt(_ *commander.Command, args []string) error {
var err error

distribution := args[0]
Expand Down Expand Up @@ -76,7 +76,7 @@ func aptlyPublishShowTxt(cmd *commander.Command, args []string) error {
return err
}

func aptlyPublishShowJSON(cmd *commander.Command, args []string) error {
func aptlyPublishShowJSON(_ *commander.Command, args []string) error {
var err error

distribution := args[0]
Expand Down
4 changes: 2 additions & 2 deletions cmd/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func aptlyRepoList(cmd *commander.Command, args []string) error {
return aptlyRepoListTxt(cmd, args)
}

func aptlyRepoListTxt(cmd *commander.Command, args []string) error {
func aptlyRepoListTxt(cmd *commander.Command, _ []string) error {
var err error

raw := cmd.Flag.Lookup("raw").Value.Get().(bool)
Expand Down Expand Up @@ -71,7 +71,7 @@ func aptlyRepoListTxt(cmd *commander.Command, args []string) error {
return err
}

func aptlyRepoListJSON(cmd *commander.Command, args []string) error {
func aptlyRepoListJSON(_ *commander.Command, _ []string) error {
var err error

repos := make([]*deb.LocalRepo, context.NewCollectionFactory().LocalRepoCollection().Len())
Expand Down
4 changes: 2 additions & 2 deletions cmd/repo_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func aptlyRepoShow(cmd *commander.Command, args []string) error {
return aptlyRepoShowTxt(cmd, args)
}

func aptlyRepoShowTxt(cmd *commander.Command, args []string) error {
func aptlyRepoShowTxt(_ *commander.Command, args []string) error {
var err error

name := args[0]
Expand Down Expand Up @@ -58,7 +58,7 @@ func aptlyRepoShowTxt(cmd *commander.Command, args []string) error {
return err
}

func aptlyRepoShowJSON(cmd *commander.Command, args []string) error {
func aptlyRepoShowJSON(_ *commander.Command, args []string) error {
var err error

name := args[0]
Expand Down
4 changes: 2 additions & 2 deletions cmd/snapshot_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func aptlySnapshotList(cmd *commander.Command, args []string) error {
return aptlySnapshotListTxt(cmd, args)
}

func aptlySnapshotListTxt(cmd *commander.Command, args []string) error {
func aptlySnapshotListTxt(cmd *commander.Command, _ []string) error {
var err error

raw := cmd.Flag.Lookup("raw").Value.Get().(bool)
Expand Down Expand Up @@ -59,7 +59,7 @@ func aptlySnapshotListTxt(cmd *commander.Command, args []string) error {
return err
}

func aptlySnapshotListJSON(cmd *commander.Command, args []string) error {
func aptlySnapshotListJSON(cmd *commander.Command, _ []string) error {
var err error

sortMethodString := cmd.Flag.Lookup("sort").Value.Get().(string)
Expand Down
4 changes: 2 additions & 2 deletions cmd/snapshot_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func aptlySnapshotShow(cmd *commander.Command, args []string) error {
return aptlySnapshotShowTxt(cmd, args)
}

func aptlySnapshotShowTxt(cmd *commander.Command, args []string) error {
func aptlySnapshotShowTxt(_ *commander.Command, args []string) error {
var err error
name := args[0]
collectionFactory := context.NewCollectionFactory()
Expand Down Expand Up @@ -85,7 +85,7 @@ func aptlySnapshotShowTxt(cmd *commander.Command, args []string) error {
return err
}

func aptlySnapshotShowJSON(cmd *commander.Command, args []string) error {
func aptlySnapshotShowJSON(_ *commander.Command, args []string) error {
var err error

name := args[0]
Expand Down
7 changes: 3 additions & 4 deletions cmd/task_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ func aptlyTaskRun(cmd *commander.Command, args []string) error {
text, _ = reader.ReadString('\n')
if text == "\n" {
break
} else {
text = strings.TrimSpace(text) + ","
parsedArgs, _ := shellwords.Parse(text)
cmdArgs = append(cmdArgs, parsedArgs...)
}
text = strings.TrimSpace(text) + ","
parsedArgs, _ := shellwords.Parse(text)
cmdArgs = append(cmdArgs, parsedArgs...)
}

if len(cmdArgs) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion console/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (p *Progress) Flush() {
}

// InitBar starts progressbar for count bytes or count items
func (p *Progress) InitBar(count int64, isBytes bool, barType aptly.BarType) {
func (p *Progress) InitBar(count int64, isBytes bool, _ aptly.BarType) {
if p.bar != nil {
panic("bar already initialized")
}
Expand Down
6 changes: 3 additions & 3 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func (context *AptlyContext) pgpProvider() string {
return provider
}

func (context *AptlyContext) getGPGFinder(provider string) pgp.GPGFinder {
func (context *AptlyContext) getGPGFinder() pgp.GPGFinder {
switch context.pgpProvider() {
case "gpg1":
return pgp.GPG1Finder()
Expand All @@ -480,7 +480,7 @@ func (context *AptlyContext) GetSigner() pgp.Signer {
return &pgp.GoSigner{}
}

return pgp.NewGpgSigner(context.getGPGFinder(provider))
return pgp.NewGpgSigner(context.getGPGFinder())
}

// GetVerifier returns Verifier with respect to provider
Expand All @@ -493,7 +493,7 @@ func (context *AptlyContext) GetVerifier() pgp.Verifier {
return &pgp.GoVerifier{}
}

return pgp.NewGpgVerifier(context.getGPGFinder(provider))
return pgp.NewGpgVerifier(context.getGPGFinder())
}

// UpdateFlags sets internal copy of flags in the context
Expand Down
4 changes: 2 additions & 2 deletions deb/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ func (c *Changes) GetField(field string) string {
}

// MatchesDependency implements PackageLike interface
func (c *Changes) MatchesDependency(d Dependency) bool {
func (c *Changes) MatchesDependency(_ Dependency) bool {
return false
}

// MatchesArchitecture implements PackageLike interface
func (c *Changes) MatchesArchitecture(arch string) bool {
func (c *Changes) MatchesArchitecture(_ string) bool {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion deb/package_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (collection *PackageCollection) Scan(q PackageQuery) (result *PackageList)
}

// Search is not implemented
func (collection *PackageCollection) Search(dep Dependency, allMatches bool) (searchResults []*Package) {
func (collection *PackageCollection) Search(_ Dependency, _ bool) (searchResults []*Package) {
panic("Not implemented")
}

Expand Down
10 changes: 5 additions & 5 deletions deb/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (q *NotQuery) Matches(pkg PackageLike) bool {
}

// Fast is false
func (q *NotQuery) Fast(list PackageCatalog) bool {
func (q *NotQuery) Fast(_ PackageCatalog) bool {
return false
}

Expand Down Expand Up @@ -197,7 +197,7 @@ func (q *FieldQuery) Query(list PackageCatalog) (result *PackageList) {
}

// Fast depends on the query
func (q *FieldQuery) Fast(list PackageCatalog) bool {
func (q *FieldQuery) Fast(_ PackageCatalog) bool {
return false
}

Expand Down Expand Up @@ -265,7 +265,7 @@ func (q *PkgQuery) Matches(pkg PackageLike) bool {
}

// Fast is always true for package query
func (q *PkgQuery) Fast(list PackageCatalog) bool {
func (q *PkgQuery) Fast(_ PackageCatalog) bool {
return true
}

Expand All @@ -280,12 +280,12 @@ func (q *PkgQuery) String() string {
}

// Matches on specific properties
func (q *MatchAllQuery) Matches(pkg PackageLike) bool {
func (q *MatchAllQuery) Matches(_ PackageLike) bool {
return true
}

// Fast is always true for match all query
func (q *MatchAllQuery) Fast(list PackageCatalog) bool {
func (q *MatchAllQuery) Fast(_ PackageCatalog) bool {
return true
}

Expand Down
2 changes: 1 addition & 1 deletion deb/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ ok:
}

// DownloadPackageIndexes downloads & parses package index files
func (repo *RemoteRepo) DownloadPackageIndexes(progress aptly.Progress, d aptly.Downloader, verifier pgp.Verifier, collectionFactory *CollectionFactory,
func (repo *RemoteRepo) DownloadPackageIndexes(progress aptly.Progress, d aptly.Downloader, verifier pgp.Verifier, _ *CollectionFactory,
ignoreMismatch bool) error {
if repo.packageList != nil {
panic("packageList != nil")
Expand Down
2 changes: 1 addition & 1 deletion http/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func NewDownloader(downLimit int64, maxTries int, progress aptly.Progress) aptly
return downloader
}

func (downloader *downloaderImpl) checkRedirect(req *http.Request, via []*http.Request) error {
func (downloader *downloaderImpl) checkRedirect(req *http.Request, _ []*http.Request) error {
if downloader.progress != nil {
downloader.progress.Printf("Following redirect to %s...\n", req.URL)
}
Expand Down
4 changes: 2 additions & 2 deletions http/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (f *FakeDownloader) Empty() bool {
}

// GetLength returns content length of given url
func (f *FakeDownloader) GetLength(ctx context.Context, url string) (int64, error) {
func (f *FakeDownloader) GetLength(_ context.Context, url string) (int64, error) {
expectation, err := f.getExpectedRequest(url)
if err != nil {
return -1, err
Expand Down Expand Up @@ -89,7 +89,7 @@ func (f *FakeDownloader) getExpectedRequest(url string) (*expectedRequest, error
}

// DownloadWithChecksum performs fake download by matching against first expectation in the queue or any expectation, with cheksum verification
func (f *FakeDownloader) DownloadWithChecksum(ctx context.Context, url string, filename string, expected *utils.ChecksumInfo, ignoreMismatch bool) error {
func (f *FakeDownloader) DownloadWithChecksum(_ context.Context, url string, filename string, expected *utils.ChecksumInfo, ignoreMismatch bool) error {
expectation, err := f.getExpectedRequest(url)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions http/grab.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (d *GrabDownloader) maybeSetupChecksum(req *grab.Request, expected *utils.C
return nil
}

func (d *GrabDownloader) download(ctx context.Context, url string, destination string, expected *utils.ChecksumInfo, ignoreMismatch bool) error {
func (d *GrabDownloader) download(_ context.Context, url string, destination string, expected *utils.ChecksumInfo, ignoreMismatch bool) error {
// TODO clean up dest dir on permanent failure
d.log("Download %s -> %s\n", url, destination)

Expand Down Expand Up @@ -155,7 +155,7 @@ func (d *GrabDownloader) GetProgress() aptly.Progress {
return d.progress
}

func (d *GrabDownloader) GetLength(ctx context.Context, url string) (int64, error) {
func (d *GrabDownloader) GetLength(_ context.Context, url string) (int64, error) {
resp, err := http.Head(url)
if err != nil {
return -1, err
Expand Down
4 changes: 0 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package main

import (
"math/rand"
"os"
"time"

"github.com/aptly-dev/aptly/aptly"
"github.com/aptly-dev/aptly/cmd"
Expand All @@ -22,7 +20,5 @@ func main() {

aptly.Version = Version

rand.Seed(time.Now().UnixNano())

os.Exit(cmd.Run(cmd.RootCommand(), os.Args[1:], true))
}
3 changes: 0 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package main
import (
"flag"
"fmt"
"math/rand"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -53,8 +52,6 @@ func TestRunMain(t *testing.T) {

aptly.Version = Version

rand.Seed(time.Now().UnixNano())

args := filterOutTestArgs(os.Args[1:])
root := cmd.RootCommand()
root.UsageLine = "aptly"
Expand Down
4 changes: 2 additions & 2 deletions s3/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (storage *PublishedStorage) String() string {
}

// MkDir creates directory recursively under public path
func (storage *PublishedStorage) MkDir(path string) error {
func (storage *PublishedStorage) MkDir(_ string) error {
// no op for S3
return nil
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func (storage *PublishedStorage) Remove(path string) error {
}

// RemoveDirs removes directory structure under public path
func (storage *PublishedStorage) RemoveDirs(path string, progress aptly.Progress) error {
func (storage *PublishedStorage) RemoveDirs(path string, _ aptly.Progress) error {
const page = 1000

filelist, _, err := storage.internalFilelist(path, false)
Expand Down
Loading

0 comments on commit ae61706

Please sign in to comment.