asteris-llc/converge

View on GitHub
resource/file/owner/ownership_test.go

Summary

Maintainability
F
4 days
Test Coverage

Function TestOwnershipDiff has 159 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestOwnershipDiff(t *testing.T) {
    users := []*user.User{
        fakeUser("1", "1", "user-1"),
        fakeUser("2", "2", "user-2"),
        fakeUser("3", "3", "user-3"),
Severity: Major
Found in resource/file/owner/ownership_test.go - About 5 hrs to fix

    Function TestApplyOwnershipDiff has 54 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestApplyOwnershipDiff(t *testing.T) {
        users := []*user.User{
            fakeUser("1", "1", "user-1"),
            fakeUser("2", "2", "user-2"),
        }
    Severity: Minor
    Found in resource/file/owner/ownership_test.go - About 1 hr to fix

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

          t.Run("Original", func(t *testing.T) {
              t.Run("uid", func(t *testing.T) {
                  o := (&owner.OwnershipDiff{UIDs: &[2]int{1, 2}}).SetProxy(m)
                  assert.Equal(t, "user: user-1 (1)", o.Original())
              })
      Severity: Major
      Found in resource/file/owner/ownership_test.go and 1 other location - About 1 day to fix
      resource/file/owner/ownership_test.go on lines 64..87

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

      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("Current", func(t *testing.T) {
              t.Run("uid", func(t *testing.T) {
                  o := (&owner.OwnershipDiff{UIDs: &[2]int{1, 2}}).SetProxy(m)
                  assert.Equal(t, "user: user-2 (2)", o.Current())
              })
      Severity: Major
      Found in resource/file/owner/ownership_test.go and 1 other location - About 1 day to fix
      resource/file/owner/ownership_test.go on lines 40..63

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

      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

      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 3 locations. Consider refactoring.
      Open

          t.Run("uid-changes", func(t *testing.T) {
              o := &owner.Ownership{UID: intRef(2), GID: intRef(1)}
              diff, err := owner.NewOwnershipDiff(m, "foo", o)
              require.NoError(t, err)
              err = diff.Apply()
      Severity: Major
      Found in resource/file/owner/ownership_test.go and 2 other locations - About 1 hr to fix
      resource/file/owner/ownership_test.go on lines 220..227
      resource/file/owner/ownership_test.go on lines 228..235

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

      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("gid-changes", func(t *testing.T) {
              o := &owner.Ownership{UID: intRef(1), GID: intRef(2)}
              diff, err := owner.NewOwnershipDiff(m, "foo", o)
              require.NoError(t, err)
              err = diff.Apply()
      Severity: Major
      Found in resource/file/owner/ownership_test.go and 2 other locations - About 1 hr to fix
      resource/file/owner/ownership_test.go on lines 212..219
      resource/file/owner/ownership_test.go on lines 228..235

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

      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-and-gid-changes", func(t *testing.T) {
              o := &owner.Ownership{UID: intRef(2), GID: intRef(2)}
              diff, err := owner.NewOwnershipDiff(m, "foo", o)
              require.NoError(t, err)
              err = diff.Apply()
      Severity: Major
      Found in resource/file/owner/ownership_test.go and 2 other locations - About 1 hr to fix
      resource/file/owner/ownership_test.go on lines 212..219
      resource/file/owner/ownership_test.go on lines 220..227

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

      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-uid-match", func(t *testing.T) {
                  o := &owner.Ownership{UID: intRef(1), GID: intRef(2)}
                  d, err := owner.NewOwnershipDiff(m, "foo", o)
                  require.NoError(t, err)
                  assert.True(t, d.Changes())
      Severity: Major
      Found in resource/file/owner/ownership_test.go and 3 other locations - About 40 mins to fix
      resource/file/owner/ownership_test.go on lines 121..126
      resource/file/owner/ownership_test.go on lines 127..132
      resource/file/owner/ownership_test.go on lines 139..144

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

      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-matching", func(t *testing.T) {
                  o := &owner.Ownership{UID: intRef(1), GID: intRef(1)}
                  d, err := owner.NewOwnershipDiff(m, "foo", o)
                  require.NoError(t, err)
                  assert.False(t, d.Changes())
      Severity: Major
      Found in resource/file/owner/ownership_test.go and 3 other locations - About 40 mins to fix
      resource/file/owner/ownership_test.go on lines 127..132
      resource/file/owner/ownership_test.go on lines 133..138
      resource/file/owner/ownership_test.go on lines 139..144

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

      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-mismatched", func(t *testing.T) {
                  o := &owner.Ownership{UID: intRef(2), GID: intRef(2)}
                  d, err := owner.NewOwnershipDiff(m, "foo", o)
                  require.NoError(t, err)
                  assert.True(t, d.Changes())
      Severity: Major
      Found in resource/file/owner/ownership_test.go and 3 other locations - About 40 mins to fix
      resource/file/owner/ownership_test.go on lines 121..126
      resource/file/owner/ownership_test.go on lines 133..138
      resource/file/owner/ownership_test.go on lines 139..144

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

      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-gid-match", func(t *testing.T) {
                  o := &owner.Ownership{UID: intRef(2), GID: intRef(1)}
                  d, err := owner.NewOwnershipDiff(m, "foo", o)
                  require.NoError(t, err)
                  assert.True(t, d.Changes())
      Severity: Major
      Found in resource/file/owner/ownership_test.go and 3 other locations - About 40 mins to fix
      resource/file/owner/ownership_test.go on lines 121..126
      resource/file/owner/ownership_test.go on lines 127..132
      resource/file/owner/ownership_test.go on lines 133..138

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

      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("mismatched-uid", func(t *testing.T) {
                      o := (&owner.OwnershipDiff{UIDs: &[2]int{1, 2}, GIDs: &[2]int{1, 1}}).SetProxy(m)
                      assert.True(t, o.Changes())
                  })
      Severity: Minor
      Found in resource/file/owner/ownership_test.go and 2 other locations - About 35 mins to fix
      resource/file/owner/ownership_test.go on lines 97..100
      resource/file/owner/ownership_test.go on lines 106..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 105.

      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("mismatched-gid", func(t *testing.T) {
                      o := (&owner.OwnershipDiff{UIDs: &[2]int{1, 1}, GIDs: &[2]int{1, 2}}).SetProxy(m)
                      assert.True(t, o.Changes())
                  })
      Severity: Minor
      Found in resource/file/owner/ownership_test.go and 2 other locations - About 35 mins to fix
      resource/file/owner/ownership_test.go on lines 97..100
      resource/file/owner/ownership_test.go on lines 102..105

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

      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("both", func(t *testing.T) {
                  o := (&owner.OwnershipDiff{UIDs: &[2]int{1, 2}, GIDs: &[2]int{1, 2}}).SetProxy(m)
                  assert.True(t, o.Changes())
              })
      Severity: Minor
      Found in resource/file/owner/ownership_test.go and 2 other locations - About 35 mins to fix
      resource/file/owner/ownership_test.go on lines 102..105
      resource/file/owner/ownership_test.go on lines 106..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 105.

      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

      There are no issues that match your filters.

      Category
      Status