asteris-llc/converge

View on GitHub

Showing 615 of 615 total issues

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

        t.Run("uid belongs to different user", func(t *testing.T) {
            u := user.NewUser(new(user.System))
            u.Username = currUsername
            u.UID = existingUID
            u.State = user.StateAbsent
Severity: Major
Found in resource/user/user_test.go and 1 other location - About 2 hrs to fix
resource/user/user_test.go on lines 984..998

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 200.

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("uid does not exist", func(t *testing.T) {
            u := user.NewUser(new(user.System))
            u.Username = currUsername
            u.UID = fakeUID
            u.State = user.StateAbsent
Severity: Major
Found in resource/user/user_test.go and 1 other location - About 2 hrs to fix
resource/user/user_test.go on lines 1000..1014

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 200.

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

Method User.DiffMod has 79 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (u *User) DiffMod(status *resource.Status, currUser *user.User) (*ModUserOptions, error) {
    options := new(ModUserOptions)

    // Check for differences between currUser and the desired modifications
    if u.NewUsername != "" {
Severity: Major
Found in resource/user/user.go - About 2 hrs to fix

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

            t.Run("volume does not exist", func(t *testing.T) {
                vol := &volume.Volume{
                    Name:  "test-volume",
                    State: "present",
                }
    Severity: Major
    Found in resource/docker/volume/volume_test.go and 1 other location - About 2 hrs to fix
    resource/docker/volume/volume_test.go on lines 50..61

    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 197.

    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("volume does not exist", func(t *testing.T) {
                vol := &volume.Volume{Name: "test-volume", State: "absent"}
                c := &mockClient{}
                vol.SetClient(c)
                c.On("FindVolume", "test-volume").Return(nil, nil)
    Severity: Major
    Found in resource/docker/volume/volume_test.go and 1 other location - About 2 hrs to fix
    resource/docker/volume/volume_test.go on lines 78..92

    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 197.

    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("no add-group gid already exists", func(t *testing.T) {
                        g.GID = currGid
                        g.Name = fakeName
                        status, err := g.Check(context.Background(), fakerenderer.New())
    
    
    Severity: Major
    Found in resource/group/group_test.go and 3 other locations - About 2 hrs to fix
    resource/group/group_test.go on lines 134..147
    resource/group/group_test.go on lines 373..386
    resource/group/group_test.go on lines 388..401

    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 196.

    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

                        if runtime.GOOS == "linux" {
                            assert.NoError(t, err)
                            assert.Equal(t, resource.StatusWillChange, status.StatusCode())
                            assert.Equal(t, "modify group name and gid", status.Messages()[0])
                            assert.Equal(t, fmt.Sprintf("group %s with gid %s", g.Name, currGid), status.Diffs()["group"].Original())
    Severity: Major
    Found in resource/group/group_test.go and 1 other location - About 2 hrs to fix
    resource/group/group_test.go on lines 224..233

    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 196.

    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("no delete-group name does not exist", func(t *testing.T) {
                    g.GID = currGid
                    g.Name = fakeName
                    status, err := g.Check(context.Background(), fakerenderer.New())
    
    
    Severity: Major
    Found in resource/group/group_test.go and 3 other locations - About 2 hrs to fix
    resource/group/group_test.go on lines 134..147
    resource/group/group_test.go on lines 204..217
    resource/group/group_test.go on lines 388..401

    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 196.

    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("no modify-group does not exist", func(t *testing.T) {
                        g.Name = fakeName
                        g.NewName = fakeName
                        status, err := g.Check(context.Background(), fakerenderer.New())
    
    
    Severity: Major
    Found in resource/group/group_test.go and 3 other locations - About 2 hrs to fix
    resource/group/group_test.go on lines 204..217
    resource/group/group_test.go on lines 373..386
    resource/group/group_test.go on lines 388..401

    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 196.

    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("no delete-group gid does not exist", func(t *testing.T) {
                    g.GID = fakeGid
                    g.Name = currName
                    status, err := g.Check(context.Background(), fakerenderer.New())
    
    
    Severity: Major
    Found in resource/group/group_test.go and 3 other locations - About 2 hrs to fix
    resource/group/group_test.go on lines 134..147
    resource/group/group_test.go on lines 204..217
    resource/group/group_test.go on lines 373..386

    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 196.

    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

                        if runtime.GOOS == "linux" {
                            assert.NoError(t, err)
                            assert.Equal(t, resource.StatusWillChange, status.StatusCode())
                            assert.Equal(t, "modify group gid", status.Messages()[0])
                            assert.Equal(t, fmt.Sprintf("group %s with gid %s", g.Name, currGid), status.Diffs()["group"].Original())
    Severity: Major
    Found in resource/group/group_test.go and 1 other location - About 2 hrs to fix
    resource/group/group_test.go on lines 275..284

    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 196.

    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

    Method Preparer.validateMutuallyExclusive has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
    Open

    func (p *Preparer) validateMutuallyExclusive(field reflect.StructField) error {
        if mutuallyexclusives, ok := field.Tag.Lookup("mutually_exclusive"); ok {
            name := p.getFieldName(field)
    
            exclusives := strings.Split(mutuallyexclusives, ",")
    Severity: Minor
    Found in resource/preparer.go - About 2 hrs 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

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

            t.Run("when-groupname", func(t *testing.T) {
                p := (&owner.Preparer{Groupname: "group-1"}).SetOSProxy(m)
                oRes, err := p.Prepare(context.Background(), fakerenderer.New())
                require.NoError(t, err)
                o, ok := oRes.(*owner.Owner)
    Severity: Major
    Found in resource/file/owner/preparer_test.go and 1 other location - About 2 hrs to fix
    resource/file/owner/preparer_test.go on lines 38..48

    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 195.

    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("when-username", func(t *testing.T) {
                p := (&owner.Preparer{Username: "user-1"}).SetOSProxy(m)
                oRes, err := p.Prepare(context.Background(), fakerenderer.New())
                require.NoError(t, err)
                o, ok := oRes.(*owner.Owner)
    Severity: Major
    Found in resource/file/owner/preparer_test.go and 1 other location - About 2 hrs to fix
    resource/file/owner/preparer_test.go on lines 62..72

    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 195.

    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 TestDiffDel has 76 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestDiffDel(t *testing.T) {
        t.Parallel()
    
        t.Run("user does not exist", func(t *testing.T) {
            u := user.NewUser(new(user.System))
    Severity: Major
    Found in resource/user/user_test.go - About 2 hrs to fix

      Method Container.diffContainer has 75 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c *Container) diffContainer(container *dc.Container, status *resource.Status) error {
          expectedStatus := strings.ToLower(c.CStatus)
          if expectedStatus == "" {
              expectedStatus = containerStatusRunning
          }
      Severity: Minor
      Found in resource/docker/container/container.go - About 2 hrs to fix

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

                        t.Run("no add-group already exists", func(t *testing.T) {
                            g.Name = currName
                            status, err := g.Check(context.Background(), fakerenderer.New())
        
                            if runtime.GOOS == "linux" {
        Severity: Major
        Found in resource/group/group_test.go and 1 other location - About 1 hr to fix
        resource/group/group_test.go on lines 327..339

        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 186.

        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("no delete-group does not exist", func(t *testing.T) {
                        g.Name = fakeName
                        status, err := g.Check(context.Background(), fakerenderer.New())
        
                        if runtime.GOOS == "linux" {
        Severity: Major
        Found in resource/group/group_test.go and 1 other location - About 1 hr to fix
        resource/group/group_test.go on lines 102..114

        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 186.

        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 TestNotifyTransform has 73 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestNotifyTransform(t *testing.T) {
            g := graph.New()
            g.Add(node.New("root", 1))
        
            doNothing := func(*node.Node, *graph.Graph) error { return nil }
        Severity: Minor
        Found in graph/notifier_test.go - About 1 hr to fix

          Method Unarchive.evaluateDuplicates has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
          Open

          func (u *Unarchive) evaluateDuplicates() error {
              // determine which directory has fewer items in order to minimize operations
              dirA := u.destDir.Name()
              dirB := u.fetchDir.Name()
              filesA := u.destContents
          Severity: Minor
          Found in resource/unarchive/unarchive.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

          Severity
          Category
          Status
          Source
          Language