mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-02 04:50:49 +00:00
Switch to gometalinter
Only small amount of required checks is enabled, plan is to enable more linters as issues are fixed in the code.
This commit is contained in:
+3
-2
@@ -2,13 +2,14 @@ package deb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
)
|
||||
|
||||
// Changes is a result of .changes file parsing
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package deb
|
||||
|
||||
import (
|
||||
. "gopkg.in/check.v1"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
type ChangesSuite struct {
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package deb
|
||||
|
||||
import (
|
||||
"github.com/smira/aptly/utils"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/smira/aptly/utils"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
|
||||
+12
-11
@@ -2,8 +2,9 @@ package deb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/awalterschulze/gographviz"
|
||||
"strings"
|
||||
|
||||
"github.com/awalterschulze/gographviz"
|
||||
)
|
||||
|
||||
// BuildGraph generates graph contents from aptly object database
|
||||
@@ -18,15 +19,15 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
var labelEnd string
|
||||
|
||||
switch layout {
|
||||
case "vertical":
|
||||
graph.AddAttr("aptly", "rankdir", "LR")
|
||||
labelStart = ""
|
||||
labelEnd = ""
|
||||
case "horizontal":
|
||||
fallthrough
|
||||
default:
|
||||
labelStart = "{"
|
||||
labelEnd = "}"
|
||||
case "vertical":
|
||||
graph.AddAttr("aptly", "rankdir", "LR")
|
||||
labelStart = ""
|
||||
labelEnd = ""
|
||||
case "horizontal":
|
||||
fallthrough
|
||||
default:
|
||||
labelStart = "{"
|
||||
labelEnd = "}"
|
||||
}
|
||||
|
||||
existingNodes := map[string]bool{}
|
||||
@@ -94,7 +95,7 @@ func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz
|
||||
"shape": "Mrecord",
|
||||
"style": "filled",
|
||||
"fillcolor": "cadetblue1",
|
||||
"label": fmt.Sprintf("%sSnapshot %s|%s|pkgs: %d%s", labelStart,
|
||||
"label": fmt.Sprintf("%sSnapshot %s|%s|pkgs: %d%s", labelStart,
|
||||
snapshot.Name, description, snapshot.NumPackages(), labelEnd),
|
||||
})
|
||||
|
||||
|
||||
+3
-2
@@ -1,12 +1,13 @@
|
||||
package deb
|
||||
|
||||
import (
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
)
|
||||
|
||||
// CollectPackageFiles walks filesystem collecting all candidates for package files
|
||||
|
||||
+3
-2
@@ -3,11 +3,12 @@ package deb
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
)
|
||||
|
||||
type indexFiles struct {
|
||||
|
||||
+3
-2
@@ -3,11 +3,12 @@ package deb
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/smira/aptly/database"
|
||||
"github.com/smira/go-uuid/uuid"
|
||||
"github.com/ugorji/go/codec"
|
||||
"log"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// LocalRepo is a collection of packages created locally
|
||||
|
||||
@@ -2,6 +2,7 @@ package deb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/smira/aptly/database"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
|
||||
+4
-3
@@ -3,11 +3,12 @@ package deb
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
)
|
||||
|
||||
// Package is single instance of Debian package
|
||||
@@ -317,7 +318,7 @@ func (p *Package) GetArchitecture() string {
|
||||
return p.Architecture
|
||||
}
|
||||
|
||||
// GetDependencies compiles list of dependenices by flags from options
|
||||
// GetDependencies compiles list of dependncies by flags from options
|
||||
func (p *Package) GetDependencies(options int) (dependencies []string) {
|
||||
deps := p.Deps()
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ package deb
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/database"
|
||||
"github.com/ugorji/go/codec"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// PackageCollection does management of packages in DB
|
||||
|
||||
@@ -3,14 +3,15 @@ package deb
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"hash/fnv"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
)
|
||||
|
||||
// PackageFile is a single file entry in package
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package deb
|
||||
|
||||
import (
|
||||
"github.com/smira/aptly/files"
|
||||
"github.com/smira/aptly/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/smira/aptly/files"
|
||||
"github.com/smira/aptly/utils"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
|
||||
+3
-2
@@ -2,12 +2,13 @@ package deb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/smira/aptly/files"
|
||||
"github.com/smira/aptly/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
||||
"github.com/smira/aptly/files"
|
||||
"github.com/smira/aptly/utils"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
|
||||
+2
-1
@@ -2,10 +2,11 @@ package deb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/smira/aptly/utils"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/smira/aptly/utils"
|
||||
)
|
||||
|
||||
var ppaRegexp = regexp.MustCompile("^ppa:([^/]+)/(.+)$")
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ type PublishedRepo struct {
|
||||
// Map of sources by each component: component name -> source UUID
|
||||
Sources map[string]string
|
||||
|
||||
// Legacy fields for compatibily with old published repositories (< 0.6)
|
||||
// Legacy fields for compatibility with old published repositories (< 0.6)
|
||||
Component string
|
||||
// SourceUUID is UUID of either snapshot or local repo
|
||||
SourceUUID string `codec:"SnapshotUUID"`
|
||||
|
||||
+4
-3
@@ -4,13 +4,14 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/database"
|
||||
"github.com/smira/aptly/files"
|
||||
"github.com/ugorji/go/codec"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
+4
-4
@@ -110,8 +110,8 @@ func (l *PackageRefList) Strings() []string {
|
||||
return result
|
||||
}
|
||||
|
||||
// Substract returns all packages in l that are not in r
|
||||
func (l *PackageRefList) Substract(r *PackageRefList) *PackageRefList {
|
||||
// Subtract returns all packages in l that are not in r
|
||||
func (l *PackageRefList) Subtract(r *PackageRefList) *PackageRefList {
|
||||
result := &PackageRefList{Refs: make([][]byte, 0, 128)}
|
||||
|
||||
// pointer to left and right reflists
|
||||
@@ -271,7 +271,7 @@ func (l *PackageRefList) Diff(r *PackageRefList, packageCollection *PackageColle
|
||||
|
||||
// Merge merges reflist r into current reflist. If overrideMatching, merge
|
||||
// replaces matching packages (by architecture/name) with reference from r.
|
||||
// If ignoreConflicting is set, all packages are preserved, otherwise conflciting
|
||||
// If ignoreConflicting is set, all packages are preserved, otherwise conflicting
|
||||
// packages are overwritten with packages from "right" snapshot.
|
||||
func (l *PackageRefList) Merge(r *PackageRefList, overrideMatching, ignoreConflicting bool) (result *PackageRefList) {
|
||||
var overriddenArch, overridenName []byte
|
||||
@@ -328,7 +328,7 @@ func (l *PackageRefList) Merge(r *PackageRefList, overrideMatching, ignoreConfli
|
||||
|
||||
if overrideMatching {
|
||||
if bytes.Equal(archL, overriddenArch) && bytes.Equal(nameL, overridenName) {
|
||||
// this package has already been overriden on the right
|
||||
// this package has already been overridden on the right
|
||||
il++
|
||||
continue
|
||||
}
|
||||
|
||||
+7
-6
@@ -2,6 +2,7 @@ package deb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/smira/aptly/database"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
@@ -156,12 +157,12 @@ func (s *PackageRefListSuite) TestSubstract(c *C) {
|
||||
l4 := &PackageRefList{Refs: [][]byte{r4, r5}}
|
||||
l5 := &PackageRefList{Refs: [][]byte{r1, r2, r3}}
|
||||
|
||||
c.Check(l1.Substract(empty), DeepEquals, l1)
|
||||
c.Check(l1.Substract(l2), DeepEquals, l3)
|
||||
c.Check(l1.Substract(l3), DeepEquals, l2)
|
||||
c.Check(l1.Substract(l4), DeepEquals, l5)
|
||||
c.Check(empty.Substract(l1), DeepEquals, empty)
|
||||
c.Check(l2.Substract(l3), DeepEquals, l2)
|
||||
c.Check(l1.Subtract(empty), DeepEquals, l1)
|
||||
c.Check(l1.Subtract(l2), DeepEquals, l3)
|
||||
c.Check(l1.Subtract(l3), DeepEquals, l2)
|
||||
c.Check(l1.Subtract(l4), DeepEquals, l5)
|
||||
c.Check(empty.Subtract(l1), DeepEquals, empty)
|
||||
c.Check(l2.Subtract(l3), DeepEquals, l2)
|
||||
}
|
||||
|
||||
func (s *PackageRefListSuite) TestDiff(c *C) {
|
||||
|
||||
+7
-6
@@ -3,12 +3,6 @@ package deb
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/database"
|
||||
"github.com/smira/aptly/http"
|
||||
"github.com/smira/aptly/utils"
|
||||
"github.com/smira/go-uuid/uuid"
|
||||
"github.com/ugorji/go/codec"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -20,6 +14,13 @@ import (
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/database"
|
||||
"github.com/smira/aptly/http"
|
||||
"github.com/smira/aptly/utils"
|
||||
"github.com/smira/go-uuid/uuid"
|
||||
"github.com/ugorji/go/codec"
|
||||
)
|
||||
|
||||
// RemoteRepo statuses
|
||||
|
||||
+2
-1
@@ -3,9 +3,10 @@ package deb
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/DisposaBoy/JsonConfigReader"
|
||||
"github.com/smira/aptly/utils"
|
||||
"os"
|
||||
)
|
||||
|
||||
// UploadersRule is single rule of format: what packages can group or key upload
|
||||
|
||||
Reference in New Issue
Block a user