asteris-llc/converge

View on GitHub

Showing 615 of 615 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func TestDownEdges(t *testing.T) {
    // DownEdges should return string IDs for the downward edges of a given node
    t.Parallel()

    g := graph.New()
Severity: Major
Found in graph/graph_test.go and 1 other location - About 1 hr to fix
graph/graph_test.go on lines 123..134

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 154.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            t.Run("missing issued at", func(t *testing.T) {
                badTok := jwt.NewWithClaims(
                    jwt.GetSigningMethod(rpc.JWTAlg),
                    jwt.StandardClaims{
                        ExpiresAt: time.Now().Unix(),
Severity: Major
Found in rpc/jwt_test.go and 1 other location - About 1 hr to fix
rpc/jwt_test.go on lines 97..111

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 154.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    t.Run("state defaults to present", func(t *testing.T) {
        p := &volume.Preparer{Name: "test-volume"}
        task, err := p.Prepare(context.Background(), fakerenderer.New())
        require.NoError(t, err)
        require.IsType(t, (*volume.Volume)(nil), task)
Severity: Major
Found in resource/docker/volume/preparer_test.go and 2 other locations - About 1 hr to fix
resource/docker/network/preparer_test.go on lines 39..46
resource/docker/network/preparer_test.go on lines 48..55

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 150.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

            t.Run("sha512", func(t *testing.T) {
                hashType = string(HashSHA512)
                p.HashType = &hashType
                hash = hex.EncodeToString(sha512.New().Sum(nil))
                p.Hash = &hash
Severity: Major
Found in resource/unarchive/preparer_test.go and 2 other locations - About 1 hr to fix
resource/unarchive/preparer_test.go on lines 103..114
resource/unarchive/preparer_test.go on lines 116..127

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 150.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function dependencyWalk has 14 return statements (exceeds 4 allowed).
Open

func dependencyWalk(rctx context.Context, g *Graph, cb WalkFunc) error {
    // the basic idea of this implementation is that we want to defer schedule
    // children of any given node until after that node's non-child dependencies
    // are satisfied. We're going to have a couple major components of this.
    // First, a scheduler/latch to make sure we don't schedule work more than
Severity: Major
Found in graph/graph.go - About 1 hr to fix

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        t.Run("state defaults to present", func(t *testing.T) {
            p := &network.Preparer{Name: "test-network"}
            task, err := p.Prepare(context.Background(), fakerenderer.New())
            require.NoError(t, err)
            require.IsType(t, (*network.Network)(nil), task)
    Severity: Major
    Found in resource/docker/network/preparer_test.go and 2 other locations - About 1 hr to fix
    resource/docker/network/preparer_test.go on lines 48..55
    resource/docker/volume/preparer_test.go on lines 39..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 150.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

                t.Run("sha1", func(t *testing.T) {
                    hashType = string(HashSHA1)
                    p.HashType = &hashType
                    hash = hex.EncodeToString(sha1.New().Sum(nil))
                    p.Hash = &hash
    Severity: Major
    Found in resource/unarchive/preparer_test.go and 2 other locations - About 1 hr to fix
    resource/unarchive/preparer_test.go on lines 116..127
    resource/unarchive/preparer_test.go on lines 129..140

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 150.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        t.Run("driver defaults to bridge", func(t *testing.T) {
            p := &network.Preparer{Name: "test-network"}
            task, err := p.Prepare(context.Background(), fakerenderer.New())
            require.NoError(t, err)
            require.IsType(t, (*network.Network)(nil), task)
    Severity: Major
    Found in resource/docker/network/preparer_test.go and 2 other locations - About 1 hr to fix
    resource/docker/network/preparer_test.go on lines 39..46
    resource/docker/volume/preparer_test.go on lines 39..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 150.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

                t.Run("sha256", func(t *testing.T) {
                    hashType = string(HashSHA256)
                    p.HashType = &hashType
                    hash = hex.EncodeToString(sha256.New().Sum(nil))
                    p.Hash = &hash
    Severity: Major
    Found in resource/unarchive/preparer_test.go and 2 other locations - About 1 hr to fix
    resource/unarchive/preparer_test.go on lines 103..114
    resource/unarchive/preparer_test.go on lines 129..140

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 150.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        t.Run("normal absolute values", func(t *testing.T) {
            size, err := lowlevel.ParseSize("100G")
            assert.NoError(t, err)
            assert.Equal(t, int64(100), size.Size)
            assert.Equal(t, false, size.Relative)
    Severity: Major
    Found in resource/lvm/lowlevel/size_test.go and 1 other location - About 1 hr to fix
    resource/lvm/lowlevel/size_test.go on lines 41..50

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 150.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        t.Run("normal relative values", func(t *testing.T) {
            size, err := lowlevel.ParseSize("100%FREE")
            assert.NoError(t, err)
            assert.Equal(t, int64(100), size.Size)
            assert.Equal(t, true, size.Relative)
    Severity: Major
    Found in resource/lvm/lowlevel/size_test.go and 1 other location - About 1 hr to fix
    resource/lvm/lowlevel/size_test.go on lines 30..39

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 150.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function TestLoadSwitch has 58 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestLoadSwitch(t *testing.T) {
        var sampleStatement = `
    switch "named-switch" {
        case "eq 1 0" "a" {
            task.query "foo" {
    Severity: Minor
    Found in parse/preprocessor/switch/switch_test.go - About 1 hr to fix

      Method Group.Check has 13 return statements (exceeds 4 allowed).
      Open

      func (g *Group) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
          var (
              groupByGid     *user.Group
              gidErr         error
              groupByNewName *user.Group
      Severity: Major
      Found in resource/group/group.go - About 1 hr to fix

        Function TestDependencyResolverResolvesGroupDependencies has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
        Open

        func TestDependencyResolverResolvesGroupDependencies(t *testing.T) {
            t.Parallel()
            defer logging.HideLogs(t)()
        
            t.Run("intra-module", func(t *testing.T) {
        Severity: Minor
        Found in load/dependencyresolver_test.go - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method Server.Listen has 56 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (s *Server) Listen(ctx context.Context, addr *url.URL) error {
            logger := logging.GetLogger(ctx).WithField("addr", addr)
        
            // set up a context within the waitgroup
            wg, ctx := errgroup.WithContext(ctx)
        Severity: Minor
        Found in rpc/server.go - About 1 hr to fix

          Function TestPreparer has 56 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func TestPreparer(t *testing.T) {
              users := []*user.User{fakeUser("1", "1", "user-1")}
              groups := []*user.Group{fakeGroup("1", "group-1")}
              t.Run("implements-resource", func(t *testing.T) {
                  assert.Implements(t, (*resource.Resource)(nil), new(owner.Preparer))
          Severity: Minor
          Found in resource/file/owner/preparer_test.go - About 1 hr to fix

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

                t.Run("when-state-absent", func(t *testing.T) {
                    p := &apt.Preparer{Name: "test1", State: "absent"}
                    task, err := p.Prepare(context.Background(), fakerenderer.New())
                    require.NoError(t, err)
                    asAPT, ok := task.(*pkg.Package)
            Severity: Major
            Found in resource/package/apt/preparer_test.go and 3 other locations - About 1 hr to fix
            resource/package/apt/preparer_test.go on lines 40..47
            resource/package/rpm/preparer_test.go on lines 40..47
            resource/package/rpm/preparer_test.go on lines 48..55

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 143.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

                t.Run("when-state-present", func(t *testing.T) {
                    p := &rpm.Preparer{Name: "test1", State: "present"}
                    task, err := p.Prepare(context.Background(), fakerenderer.New())
                    require.NoError(t, err)
                    asRPM, ok := task.(*pkg.Package)
            Severity: Major
            Found in resource/package/rpm/preparer_test.go and 3 other locations - About 1 hr to fix
            resource/package/apt/preparer_test.go on lines 40..47
            resource/package/apt/preparer_test.go on lines 49..56
            resource/package/rpm/preparer_test.go on lines 48..55

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 143.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

                t.Run("when-state-present", func(t *testing.T) {
                    p := &apt.Preparer{Name: "test1", State: "present"}
                    task, err := p.Prepare(context.Background(), fakerenderer.New())
                    require.NoError(t, err)
                    asAPT, ok := task.(*pkg.Package)
            Severity: Major
            Found in resource/package/apt/preparer_test.go and 3 other locations - About 1 hr to fix
            resource/package/apt/preparer_test.go on lines 49..56
            resource/package/rpm/preparer_test.go on lines 40..47
            resource/package/rpm/preparer_test.go on lines 48..55

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 143.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

                t.Run("when-state-absent", func(t *testing.T) {
                    p := &rpm.Preparer{Name: "test1", State: "absent"}
                    task, err := p.Prepare(context.Background(), fakerenderer.New())
                    require.NoError(t, err)
                    asRPM, ok := task.(*pkg.Package)
            Severity: Major
            Found in resource/package/rpm/preparer_test.go and 3 other locations - About 1 hr to fix
            resource/package/apt/preparer_test.go on lines 40..47
            resource/package/apt/preparer_test.go on lines 49..56
            resource/package/rpm/preparer_test.go on lines 40..47

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 143.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language