mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-06 05:30:57 +00:00
Enable gosimple and ineffasign linters
This commit is contained in:
+2
-7
@@ -103,11 +103,7 @@ func (c *Changes) VerifyAndParse(acceptUnsigned, ignoreSignature bool, verifier
|
||||
c.Architectures = strings.Fields(c.Stanza["Architecture"])
|
||||
|
||||
c.Files, err = c.Files.ParseSumFields(c.Stanza)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// Prepare creates temporary directory, copies file there and verifies checksums
|
||||
@@ -181,8 +177,7 @@ func (c *Changes) PackageQuery() (PackageQuery, error) {
|
||||
if len(c.Binary) > 0 {
|
||||
binaryQuery = &FieldQuery{Field: "Name", Relation: VersionEqual, Value: c.Binary[0]}
|
||||
// matching debug ddeb packages, they're not present in the Binary field
|
||||
var ddebQuery PackageQuery
|
||||
ddebQuery = &FieldQuery{Field: "Name", Relation: VersionEqual, Value: fmt.Sprintf("%s-dbgsym", c.Binary[0])}
|
||||
var ddebQuery PackageQuery = &FieldQuery{Field: "Name", Relation: VersionEqual, Value: fmt.Sprintf("%s-dbgsym", c.Binary[0])}
|
||||
|
||||
for _, binary := range c.Binary[1:] {
|
||||
binaryQuery = &OrQuery{
|
||||
|
||||
+1
-3
@@ -175,9 +175,7 @@ func GetContentsFromDeb(file aptly.ReadSeekerCloser, packageFile string) ([]stri
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.HasPrefix(tarHeader.Name, "./") {
|
||||
tarHeader.Name = tarHeader.Name[2:]
|
||||
}
|
||||
tarHeader.Name = strings.TrimPrefix(tarHeader.Name[2:], "./")
|
||||
results = append(results, tarHeader.Name)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -344,7 +344,7 @@ func (p *Package) GetDependencies(options int) (dependencies []string) {
|
||||
if source == "" {
|
||||
source = p.Name
|
||||
}
|
||||
if strings.Index(source, ")") != -1 {
|
||||
if strings.Contains(source, ")") {
|
||||
dependencies = append(dependencies, fmt.Sprintf("%s {source}", source))
|
||||
} else {
|
||||
dependencies = append(dependencies, fmt.Sprintf("%s (= %s) {source}", source, p.Version))
|
||||
|
||||
+1
-1
@@ -299,7 +299,7 @@ func (s *PackageSuite) TestMatchesDependency(c *C) {
|
||||
// ~
|
||||
c.Check(
|
||||
p.MatchesDependency(Dependency{Pkg: "alien-arena-common", Architecture: "i386", Relation: VersionRegexp, Version: "7\\.40-.*",
|
||||
Regexp: regexp.MustCompile("7\\.40-.*")}), Equals, true)
|
||||
Regexp: regexp.MustCompile(`7\.40-.*`)}), Equals, true)
|
||||
c.Check(
|
||||
p.MatchesDependency(Dependency{Pkg: "alien-arena-common", Architecture: "i386", Relation: VersionRegexp, Version: "7\\.40-.*",
|
||||
Regexp: regexp.MustCompile("40")}), Equals, true)
|
||||
|
||||
+4
-15
@@ -226,12 +226,7 @@ func NewPublishedRepo(storage, prefix, distribution string, architectures []stri
|
||||
|
||||
// clean & verify prefix
|
||||
prefix = filepath.Clean(prefix)
|
||||
if strings.HasPrefix(prefix, "/") {
|
||||
prefix = prefix[1:]
|
||||
}
|
||||
if strings.HasSuffix(prefix, "/") {
|
||||
prefix = prefix[:len(prefix)-1]
|
||||
}
|
||||
prefix = strings.TrimPrefix(strings.TrimSuffix(prefix, "/"), "/")
|
||||
prefix = filepath.Clean(prefix)
|
||||
|
||||
for _, part := range strings.Split(prefix, "/") {
|
||||
@@ -252,7 +247,7 @@ func NewPublishedRepo(storage, prefix, distribution string, architectures []stri
|
||||
}
|
||||
}
|
||||
|
||||
if strings.Index(distribution, "/") != -1 {
|
||||
if strings.Contains(distribution, "/") {
|
||||
return nil, fmt.Errorf("invalid distribution %s, '/' is not allowed", distribution)
|
||||
}
|
||||
|
||||
@@ -474,8 +469,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
var e error
|
||||
e = tempDB.Close()
|
||||
e := tempDB.Close()
|
||||
if e != nil && progress != nil {
|
||||
progress.Printf("failed to close temp DB: %s", err)
|
||||
}
|
||||
@@ -730,12 +724,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
||||
return err
|
||||
}
|
||||
|
||||
err = indexes.RenameFiles()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return indexes.RenameFiles()
|
||||
}
|
||||
|
||||
// RemoveFiles removes files that were created by Publish
|
||||
|
||||
@@ -505,6 +505,7 @@ func (s *PublishedRepoCollectionSuite) TestAddByStoragePrefixDistribution(c *C)
|
||||
c.Assert(r.String(), Equals, s.repo1.String())
|
||||
|
||||
r, err = s.collection.ByStoragePrefixDistribution("files:other", "ppa", "precise")
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(r.String(), Equals, s.repo5.String())
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -204,7 +204,7 @@ func (q *FieldQuery) Fast(list PackageCatalog) bool {
|
||||
// String interface
|
||||
func (q *FieldQuery) String() string {
|
||||
escape := func(val string) string {
|
||||
if strings.IndexAny(val, "()|,!{} \t\n") != -1 {
|
||||
if strings.ContainsAny(val, "()|,!{} \t\n") {
|
||||
return "'" + strings.Replace(strings.Replace(val, "\\", "\\\\", -1), "'", "\\'", -1) + "'"
|
||||
}
|
||||
return val
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ func (l *PackageRefList) Has(p *Package) bool {
|
||||
key := p.Key("")
|
||||
|
||||
i := sort.Search(len(l.Refs), func(j int) bool { return bytes.Compare(l.Refs[j], key) >= 0 })
|
||||
return i < len(l.Refs) && bytes.Compare(l.Refs[i], key) == 0
|
||||
return i < len(l.Refs) && bytes.Equal(l.Refs[i], key)
|
||||
}
|
||||
|
||||
// Strings builds list of strings with package keys
|
||||
|
||||
+1
-3
@@ -331,9 +331,7 @@ ok:
|
||||
if strings.Contains(repo.Distribution, "/") {
|
||||
distributionLast := path.Base(repo.Distribution) + "/"
|
||||
for i := range components {
|
||||
if strings.HasPrefix(components[i], distributionLast) {
|
||||
components[i] = components[i][len(distributionLast):]
|
||||
}
|
||||
components[i] = strings.TrimPrefix(components[i], distributionLast)
|
||||
}
|
||||
}
|
||||
if len(repo.Components) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user