asteris-llc/converge

View on GitHub
resource/user/user_test.go

Summary

Maintainability
F
1 wk
Test Coverage

File user_test.go has 1224 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Copyright © 2016 Asteris, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Severity: Major
Found in resource/user/user_test.go - About 2 days to fix

    Function TestDiffAdd has 302 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestDiffAdd(t *testing.T) {
        t.Parallel()
    
        zone := time.FixedZone(time.Now().In(time.Local).Zone())
        expiryString := "1996-12-12"
    Severity: Major
    Found in resource/user/user_test.go - About 1 day to fix

      Function TestDiffMod has 290 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestDiffMod(t *testing.T) {
          t.Parallel()
      
          t.Run("set all options", func(t *testing.T) {
              u := user.NewUser(new(user.System))
      Severity: Major
      Found in resource/user/user_test.go - About 1 day to fix

        Function TestApply has 246 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestApply(t *testing.T) {
            t.Parallel()
        
            t.Run("state=present", func(t *testing.T) {
                t.Run("add tests", func(t *testing.T) {
        Severity: Major
        Found in resource/user/user_test.go - About 1 day to fix

          Function TestCheck has 116 lines of code (exceeds 50 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: Major
          Found in resource/user/user_test.go - About 3 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 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

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

                      t.Run("with gid", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = fakeUsername
                          u.GID = existingGID
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 3 other locations - About 4 hrs to fix
              resource/user/user_test.go on lines 620..640
              resource/user/user_test.go on lines 658..678
              resource/user/user_test.go on lines 696..716

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

              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("group exists-provide groupname", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = existingGroupName
                          u.GroupName = existingGroupName
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 3 other locations - About 4 hrs to fix
              resource/user/user_test.go on lines 658..678
              resource/user/user_test.go on lines 696..716
              resource/user/user_test.go on lines 732..752

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

              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("with groupname", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = fakeUsername
                          u.GroupName = existingGroupName
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 3 other locations - About 4 hrs to fix
              resource/user/user_test.go on lines 620..640
              resource/user/user_test.go on lines 658..678
              resource/user/user_test.go on lines 732..752

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

              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("uid not found", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = fakeUsername
                          u.UID = fakeUID
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 3 other locations - About 4 hrs to fix
              resource/user/user_test.go on lines 620..640
              resource/user/user_test.go on lines 696..716
              resource/user/user_test.go on lines 732..752

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

              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("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 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

              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

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

                          t.Run("cannot modify user", func(t *testing.T) {
                              u.Username = currUsername
                              u.GroupName = fakeGroupName
                              status, err := u.Check(context.Background(), fakerenderer.New())
              
              
              Severity: Major
              Found in resource/user/user_test.go and 1 other location - About 1 hr to fix
              resource/user/user_test.go on lines 158..170

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

              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("cannot add user", func(t *testing.T) {
                              u.Username = fakeUsername
                              u.GroupName = fakeGroupName
                              status, err := u.Check(context.Background(), fakerenderer.New())
              
              
              Severity: Major
              Found in resource/user/user_test.go and 1 other location - About 1 hr to fix
              resource/user/user_test.go on lines 188..200

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

              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("error-gid not found", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = currUsername
                          u.GID = fakeGID
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 2 other locations - About 1 hr to fix
              resource/user/user_test.go on lines 1135..1147
              resource/user/user_test.go on lines 1209..1221

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

              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("error-uid found", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = currUsername
                          u.UID = existingUID
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 2 other locations - About 1 hr to fix
              resource/user/user_test.go on lines 1209..1221
              resource/user/user_test.go on lines 1243..1255

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

              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("error-groupname not found", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = currUsername
                          u.GroupName = fakeGroupName
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 2 other locations - About 1 hr to fix
              resource/user/user_test.go on lines 1135..1147
              resource/user/user_test.go on lines 1243..1255

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

              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("error-groupname not found", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = fakeUsername
                          u.GroupName = fakeGroupName
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 2 other locations - About 1 hr to fix
              resource/user/user_test.go on lines 680..692
              resource/user/user_test.go on lines 754..766

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

              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("error-gid not found", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = fakeUsername
                          u.GID = fakeGID
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 2 other locations - About 1 hr to fix
              resource/user/user_test.go on lines 680..692
              resource/user/user_test.go on lines 718..730

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

              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("error-uid found", func(t *testing.T) {
                          u := user.NewUser(new(user.System))
                          u.Username = fakeUsername
                          u.UID = currUID
                          status := resource.NewStatus()
              Severity: Major
              Found in resource/user/user_test.go and 2 other locations - About 1 hr to fix
              resource/user/user_test.go on lines 718..730
              resource/user/user_test.go on lines 754..766

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

              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 setUid() (string, error) {
                  for i := 0; i <= maxUID; i++ {
                      uid := strconv.Itoa(i)
                      user, err := os.LookupId(uid)
                      if err == nil && user.Username != currUsername {
              Severity: Minor
              Found in resource/user/user_test.go and 1 other location - About 40 mins to fix
              resource/group/group_test.go on lines 986..995

              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

              func setFakeUid should be setFakeUID
              Open

              func setFakeUid() (string, error) {
              Severity: Minor
              Found in resource/user/user_test.go by golint

              func setUid should be setUID
              Open

              func setUid() (string, error) {
              Severity: Minor
              Found in resource/user/user_test.go by golint

              There are no issues that match your filters.

              Category
              Status