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("comment", func(t *testing.T) {
        u := user.NewUser(new(user.System))
        u.Username = currUsername
        u.Name = "test"
        status := resource.NewStatus()
Severity: Major
Found in resource/user/user_test.go and 1 other location - About 3 hrs to fix
resource/user/user_test.go on lines 1299..1317

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

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("directory", func(t *testing.T) {
        u := user.NewUser(new(user.System))
        u.Username = currUsername
        u.HomeDir = "/tmp/test"
        status := resource.NewStatus()
Severity: Major
Found in resource/user/user_test.go and 1 other location - About 3 hrs to fix
resource/user/user_test.go on lines 1279..1297

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

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

func Test_DrawNode_WhenVertexIDReturnsError_ReturnsError(t *testing.T) {
    err := errors.New("test error")
    provider := new(MockPrintProvider)
    provider.On("VertexGetID", mock.Anything).Return(pp.VisibleString(""), err)
    provider.On("VertexGetLabel", mock.Anything).Return(pp.VisibleString(""), nil)
Severity: Major
Found in prettyprinters/graphviz/graphviz_test.go and 1 other location - About 3 hrs to fix
prettyprinters/graphviz/graphviz_test.go on lines 97..109

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

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

func Test_DrawNode_WhenVertexLabelReturnsError_ReturnsError(t *testing.T) {
    err := errors.New("test error")
    provider := new(MockPrintProvider)
    provider.On("VertexGetID", mock.Anything).Return(pp.VisibleString(""), nil)
    provider.On("VertexGetLabel", mock.Anything).Return(pp.VisibleString(""), err)
Severity: Major
Found in prettyprinters/graphviz/graphviz_test.go and 1 other location - About 3 hrs to fix
prettyprinters/graphviz/graphviz_test.go on lines 68..80

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

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("uid not found", func(t *testing.T) {
            u := user.NewUser(new(user.System))
            u.Username = currUsername
            u.UID = fakeUID
            status := resource.NewStatus()
Severity: Major
Found in resource/user/user_test.go and 2 other locations - About 2 hrs to fix
resource/user/user_test.go on lines 1189..1207
resource/user/user_test.go on lines 1223..1241

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

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("with groupname", func(t *testing.T) {
            u := user.NewUser(new(user.System))
            u.Username = currUsername
            u.GroupName = existingGroupName
            status := resource.NewStatus()
Severity: Major
Found in resource/user/user_test.go and 2 other locations - About 2 hrs to fix
resource/user/user_test.go on lines 1115..1133
resource/user/user_test.go on lines 1223..1241

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

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("with gid", func(t *testing.T) {
            u := user.NewUser(new(user.System))
            u.Username = currUsername
            u.GID = existingGID
            status := resource.NewStatus()
Severity: Major
Found in resource/user/user_test.go and 2 other locations - About 2 hrs to fix
resource/user/user_test.go on lines 1115..1133
resource/user/user_test.go on lines 1189..1207

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

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

func TestGetFailedReason(t *testing.T) {
    t.Parallel()

    t.Run("returns-error-when-no-properties", func(t *testing.T) {
        t.Parallel()
Severity: Major
Found in resource/systemd/unit/resource_test.go - About 2 hrs to fix

    Function TestCheck has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
    Open

    func TestCheck(t *testing.T) {
        t.Parallel()
    
        t.Run("state=present", func(t *testing.T) {
            u := user.NewUser(new(user.System))
    Severity: Minor
    Found in resource/user/user_test.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

    Function TestShouldEvaluate has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
    Open

    func TestShouldEvaluate(t *testing.T) {
        t.Run("when-many-branches", func(t *testing.T) {
            g := peerBranchSampleGraph(t)
            resources := []string{"resource1", "resource2", "resource3"}
            t.Run("when-true-true-true", func(t *testing.T) {
    Severity: Minor
    Found in graph/node/conditional/conditional_test.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

    File conditional_test.go has 537 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package conditional_test
    
    import (
        "errors"
        "fmt"
    Severity: Minor
    Found in graph/node/conditional/conditional_test.go - About 2 hrs to fix

      Function TestJWTAuth has 94 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestJWTAuth(t *testing.T) {
          t.Parallel()
      
          secret := "secret"
          token := rpc.NewJWTAuth(secret)
      Severity: Major
      Found in rpc/jwt_test.go - About 2 hrs to fix

        Method User.Apply has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
        Open

        func (u *User) Apply(context.Context) (resource.TaskStatus, error) {
            // lookup the user by name
            // ErrUnsupported is returned if the system is not supported
            // Lookup returns user.UnknownUserError if the user is not found
            userByName, nameErr := u.system.Lookup(u.Username)
        Severity: Minor
        Found in resource/user/user.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

        Method resourceVG.Check has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
        Open

        func (r *resourceVG) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
            status := &resource.Status{}
        
            if err := r.lvm.Check(); err != nil {
                return nil, errors.Wrap(err, "lvm.volumegroup")
        Severity: Minor
        Found in resource/lvm/vg/vg.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

        Function TestNodeValidateName has 93 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestNodeValidateName(t *testing.T) {
            t.Parallel()
            t.Run("when valid", func(t *testing.T) {
                t.Parallel()
                t.Run("alpha", func(t *testing.T) {
        Severity: Major
        Found in parse/node_test.go - About 2 hrs to fix

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

                      t.Run("hashtype", func(t *testing.T) {
                          prep := fetch.Preparer{
                              Destination: "/tmp/converge.tar.gz",
                              Source:      "https://github.com/asteris-llc/converge/releases/download/0.2.0/converge_0.2.0_darwin_amd64.tar.gz",
                              Hash:        &hash,
          Severity: Major
          Found in resource/file/fetch/preparer_test.go and 1 other location - About 2 hrs to fix
          resource/file/fetch/preparer_test.go on lines 211..231

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

          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("hash", func(t *testing.T) {
                          prep := fetch.Preparer{
                              Destination: "/tmp/converge.tar.gz",
                              Source:      "https://github.com/asteris-llc/converge/releases/download/0.2.0/converge_0.2.0_darwin_amd64.tar.gz",
                              HashType:    &hashType,
          Severity: Major
          Found in resource/file/fetch/preparer_test.go and 1 other location - About 2 hrs to fix
          resource/file/fetch/preparer_test.go on lines 189..209

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

          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-only-uid", func(t *testing.T) {
                      t.Run("when-matches", func(t *testing.T) {
                          o := &owner.Ownership{UID: intRef(1)}
                          d, err := owner.NewOwnershipDiff(m, "foo", o)
                          require.NoError(t, err)
          Severity: Major
          Found in resource/file/owner/ownership_test.go and 1 other location - About 2 hrs to fix
          resource/file/owner/ownership_test.go on lines 159..172

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

          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-only-gid", func(t *testing.T) {
                      t.Run("when-matches", func(t *testing.T) {
                          o := &owner.Ownership{GID: intRef(1)}
                          d, err := owner.NewOwnershipDiff(m, "foo", o)
                          require.NoError(t, err)
          Severity: Major
          Found in resource/file/owner/ownership_test.go and 1 other location - About 2 hrs to fix
          resource/file/owner/ownership_test.go on lines 145..158

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

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

          func TestExportedFields(t *testing.T) {
              t.Parallel()
              t.Run("exported-fields", func(t *testing.T) {
                  t.Parallel()
                  t.Run("when-value", func(t *testing.T) {
          Severity: Major
          Found in resource/field_extractor_test.go - About 2 hrs to fix
            Severity
            Category
            Status
            Source
            Language