asteris-llc/converge

View on GitHub

Showing 615 of 615 total issues

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

        t.Run("when-status-inactive", func(t *testing.T) {
            unit := &Unit{ActiveState: "inactive"}
            e := &ExecutorMock{}
            r.systemdExecutor = e
            e.On("QueryUnit", any, any).Return(unit, nil)
Severity: Major
Found in resource/systemd/unit/resource_test.go and 3 other locations - About 1 hr to fix
resource/systemd/unit/resource_test.go on lines 134..143
resource/systemd/unit/resource_test.go on lines 150..159
resource/systemd/unit/resource_test.go on lines 190..199

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

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-status-deactivating", func(t *testing.T) {
            unit := &Unit{ActiveState: "deactivating"}
            e := &ExecutorMock{}
            r.systemdExecutor = e
            e.On("QueryUnit", any, any).Return(unit, nil)
Severity: Major
Found in resource/systemd/unit/resource_test.go and 3 other locations - About 1 hr to fix
resource/systemd/unit/resource_test.go on lines 99..108
resource/systemd/unit/resource_test.go on lines 150..159
resource/systemd/unit/resource_test.go on lines 190..199

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

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-status-activating", func(t *testing.T) {
            unit := &Unit{ActiveState: "activating"}
            e := &ExecutorMock{}
            r.systemdExecutor = e
            e.On("QueryUnit", any, any).Return(unit, nil)
Severity: Major
Found in resource/systemd/unit/resource_test.go and 3 other locations - About 1 hr to fix
resource/systemd/unit/resource_test.go on lines 99..108
resource/systemd/unit/resource_test.go on lines 134..143
resource/systemd/unit/resource_test.go on lines 150..159

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

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-status-active", func(t *testing.T) {
            unit := &Unit{ActiveState: "active"}
            e := &ExecutorMock{}
            r.systemdExecutor = e
            e.On("QueryUnit", any, any).Return(unit, nil)
Severity: Major
Found in resource/systemd/unit/resource_test.go and 3 other locations - About 1 hr to fix
resource/systemd/unit/resource_test.go on lines 99..108
resource/systemd/unit/resource_test.go on lines 134..143
resource/systemd/unit/resource_test.go on lines 190..199

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

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 (u *Unarchive) Apply(ctx context.Context) (resource.TaskStatus, error) {
    ch := make(chan response, 1)

    go func(ctx context.Context) {
        status, err := u.applyWithContext(ctx)
Severity: Major
Found in resource/unarchive/unarchive.go and 1 other location - About 1 hr to fix
resource/file/fetch/fetch.go on lines 101..115

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

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 (f *Fetch) Apply(ctx context.Context) (resource.TaskStatus, error) {
    ch := make(chan response, 1)

    go func(ctx context.Context) {
        status, err := f.applyWithContext(ctx)
Severity: Major
Found in resource/file/fetch/fetch.go and 1 other location - About 1 hr to fix
resource/unarchive/unarchive.go on lines 125..139

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

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

func TestRetryUntil(t *testing.T) {
    t.Parallel()
    defer logging.HideLogs(t)()

    t.Run("sets retry count", func(t *testing.T) {
Severity: Minor
Found in resource/wait/retrier_test.go - About 1 hr to fix

    Method User.Apply has 61 lines of code (exceeds 50 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 1 hr to fix

      Function TestQueryUnit has 61 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestQueryUnit(t *testing.T) {
          t.Parallel()
          t.Run("when-verify", func(t *testing.T) {
              t.Parallel()
              t.Run("when-unit-exists", func(t *testing.T) {
      Severity: Minor
      Found in resource/systemd/unit/systemd_linux_test.go - About 1 hr to fix

        Function Nodes has 61 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func Nodes(ctx context.Context, root string, verify bool) (*graph.Graph, error) {
            logger := logging.GetLogger(ctx).WithField("function", "Nodes")
        
            toLoad := []*source{{"root", root, root}}
        
        
        Severity: Minor
        Found in load/nodes.go - About 1 hr to fix

          Function TestVGApply has 61 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func TestVGApply(t *testing.T) {
              t.Run("single device", func(t *testing.T) {
                  lvm, m := testhelpers.MakeFakeLvmEmpty()
                  m.On("CreateVolumeGroup", mock.Anything, mock.Anything).Return(nil)
          
          
          Severity: Minor
          Found in resource/lvm/vg/vg_test.go - About 1 hr to fix

            Method Printer.Show has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
            Open

            func (p Printer) Show(ctx context.Context, g *graph.Graph) (string, error) {
                outputBuffer := new(bytes.Buffer)
                write := func(s Renderable) { outputBuffer.WriteString(s.String()) }
            
                subgraphs := makeSubgraphMap()
            Severity: Minor
            Found in prettyprinters/prettyprinter.go - About 1 hr to fix

            Cognitive Complexity

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

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

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

            Further reading

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

            func Test_ExitCodes(t *testing.T) {
                expected := []uint32{0, 1, 2, 3}
                c := newResults("", 0, "")
                c = c.Append("", &shell.CommandResults{ExitStatus: 1})
                c = c.Append("", &shell.CommandResults{ExitStatus: 2})
            Severity: Major
            Found in resource/shell/command_results_test.go and 1 other location - About 1 hr to fix
            resource/shell/command_results_test.go on lines 90..98

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

            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_Reverse(t *testing.T) {
                expected := []uint32{0, 1, 2, 3}
                c := newResults("", 0, "")
                c = c.Append("", &shell.CommandResults{ExitStatus: 1})
                c = c.Append("", &shell.CommandResults{ExitStatus: 2})
            Severity: Major
            Found in resource/shell/command_results_test.go and 1 other location - About 1 hr to fix
            resource/shell/command_results_test.go on lines 80..88

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

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

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

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

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

            Refactorings

            Further Reading

            Method Renderer.lookup has 60 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (r *Renderer) lookup(name string) (string, error) {
                g := r.Graph()
                // fully-qualified graph name
                fqgn := graph.SiblingID(r.ID, name)
            
            
            Severity: Minor
            Found in render/renderer.go - About 1 hr to fix

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

                      t.Run("when-status-active", func(t *testing.T) {
                          unit := &Unit{ActiveState: "active"}
                          e := &ExecutorMock{}
                          r.systemdExecutor = e
                          e.On("QueryUnit", any, any).Return(unit, nil)
              Severity: Major
              Found in resource/systemd/unit/resource_test.go and 2 other locations - About 1 hr to fix
              resource/systemd/unit/resource_test.go on lines 90..98
              resource/systemd/unit/resource_test.go on lines 125..133

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 154.

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

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

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

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

              Refactorings

              Further Reading

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

                      t.Run("when-status-reloading", func(t *testing.T) {
                          unit := &Unit{ActiveState: "reloading"}
                          e := &ExecutorMock{}
                          r.systemdExecutor = e
                          e.On("QueryUnit", any, any).Return(unit, nil)
              Severity: Major
              Found in resource/systemd/unit/resource_test.go and 2 other locations - About 1 hr to fix
              resource/systemd/unit/resource_test.go on lines 81..89
              resource/systemd/unit/resource_test.go on lines 125..133

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 154.

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

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

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

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

              Refactorings

              Further Reading

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

                      t.Run("when-status-activating", func(t *testing.T) {
                          unit := &Unit{ActiveState: "activating"}
                          e := &ExecutorMock{}
                          r.systemdExecutor = e
                          e.On("QueryUnit", any, any).Return(unit, nil)
              Severity: Major
              Found in resource/systemd/unit/resource_test.go and 2 other locations - About 1 hr to fix
              resource/systemd/unit/resource_test.go on lines 81..89
              resource/systemd/unit/resource_test.go on lines 90..98

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 154.

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

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

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

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

              Refactorings

              Further Reading

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

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

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 154.

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

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

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

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

              Refactorings

              Further Reading

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

              func TestUpEdges(t *testing.T) {
                  // UpEdges should return string IDs for the upward edges of a given node
                  t.Parallel()
              
                  g := graph.New()
              Severity: Major
              Found in graph/graph_test.go and 1 other location - About 1 hr to fix
              graph/graph_test.go on lines 93..104

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 154.

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

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

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

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

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language