asteris-llc/converge

View on GitHub

Showing 615 of 615 total issues

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

            t.Run("hashtype", func(t *testing.T) {
                p := &Preparer{
                    Source:      "/tmp/test.zip",
                    Destination: "/tmp/test",
                    Hash:        &hash,
Severity: Major
Found in resource/unarchive/preparer_test.go and 1 other location - About 2 hrs to fix
resource/unarchive/preparer_test.go on lines 239..259

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

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

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

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

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

Refactorings

Further Reading

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

            t.Run("hash", func(t *testing.T) {
                p := &Preparer{
                    Source:      "/tmp/test.zip",
                    Destination: "/tmp/test",
                    HashType:    &hashType,
Severity: Major
Found in resource/unarchive/preparer_test.go and 1 other location - About 2 hrs to fix
resource/unarchive/preparer_test.go on lines 217..237

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

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-resolvable", func(t *testing.T) {
        gr, err := hclutils.LoadAndParseFromString("TestRenderConditionals", src)
        require.NoError(t, err)
        err = graphutils.AddMetadata(gr, "root/task.query.a", "conditional-predicate-raw", "eq `a` `{{param `a`}}`")
        err = graphutils.AddMetadata(gr, "root/task.query.a", conditional.MetaBranchName, "branch1")
Severity: Major
Found in render/render_test.go and 1 other location - About 2 hrs to fix
render/render_test.go on lines 206..220

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

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 TypeExtractor.Visit has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
Open

func (te *TypeExtractor) Visit(node ast.Node) (w ast.Visitor) {
    if node == nil {
        return nil
    }

Severity: Minor
Found in docs/extract.go - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

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

    t.Run("when-valid-predicate", func(t *testing.T) {
        gr, err := hclutils.LoadAndParseFromString("TestRenderConditionals", src)
        require.NoError(t, err)
        err = graphutils.AddMetadata(gr, "root/task.query.a", "conditional-predicate-raw", "true")
        err = graphutils.AddMetadata(gr, "root/task.query.a", conditional.MetaBranchName, "branch1")
Severity: Major
Found in render/render_test.go and 1 other location - About 2 hrs to fix
render/render_test.go on lines 165..179

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

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

func newScopeTypePropertiesFromMap(m map[string]interface{}) *ScopeTypeProperties {
    s := &ScopeTypeProperties{}

    if val, ok := m["BlockIOAccounting"]; ok {
        s.BlockIOAccounting = val.(bool)
Severity: Major
Found in resource/systemd/unit/systemd_properties.go - About 2 hrs to fix

    Function TestStartUnit has 87 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestStartUnit(t *testing.T) {
        t.Parallel()
        t.Run("call-start-unit", func(t *testing.T) {
            t.Parallel()
            u := randomUnit(UnitTypeService)
    Severity: Major
    Found in resource/systemd/unit/systemd_linux_test.go - About 2 hrs to fix

      Function TestStopUnit has 87 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func TestStopUnit(t *testing.T) {
          t.Parallel()
          t.Run("call-stop-unit", func(t *testing.T) {
              t.Parallel()
              u := randomUnit(UnitTypeService)
      Severity: Major
      Found in resource/systemd/unit/systemd_linux_test.go - About 2 hrs to fix

        Function TestReloadUnit has 87 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestReloadUnit(t *testing.T) {
            t.Parallel()
            t.Run("call-reload-unit", func(t *testing.T) {
                t.Parallel()
                u := randomUnit(UnitTypeService)
        Severity: Major
        Found in resource/systemd/unit/systemd_linux_test.go - About 2 hrs to fix

          Function TestRestartUnit has 87 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func TestRestartUnit(t *testing.T) {
              t.Parallel()
              t.Run("call-restart-unit", func(t *testing.T) {
                  t.Parallel()
                  u := randomUnit(UnitTypeService)
          Severity: Major
          Found in resource/systemd/unit/systemd_linux_test.go - About 2 hrs to fix

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

                case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
                    raw, err := strconv.ParseUint(num, base, typ.Bits())
            
                    if err != nil {
                        return reflect.Zero(typ), errors.Wrapf(err, "could not convert %s to %s", num, typ.Kind())
            Severity: Major
            Found in resource/preparer.go and 1 other location - About 2 hrs to fix
            resource/preparer.go on lines 505..527

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

            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

                case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
                    raw, err := strconv.ParseInt(num, base, typ.Bits())
            
                    if err != nil {
                        return reflect.Zero(typ), errors.Wrapf(err, "could not convert %s to %s", num, typ.Kind())
            Severity: Major
            Found in resource/preparer.go and 1 other location - About 2 hrs to fix
            resource/preparer.go on lines 529..551

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

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

            func TestDirectoryCheck(t *testing.T) {
                tmpDir, err := ioutil.TempDir("", "converge-directory-check")
                require.NoError(t, err)
                defer os.RemoveAll(tmpDir)
            
            
            Severity: Major
            Found in resource/file/directory/directory_test.go - About 2 hrs to fix

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

                      t.Run("when-uid", func(t *testing.T) {
                          u := new(int)
                          *u = 1
                          p := (&owner.Preparer{UID: u}).SetOSProxy(m)
                          oRes, err := p.Prepare(context.Background(), fakerenderer.New())
              Severity: Major
              Found in resource/file/owner/preparer_test.go and 1 other location - About 2 hrs to fix
              resource/file/owner/preparer_test.go on lines 73..85

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

              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-gid", func(t *testing.T) {
                          g := new(int)
                          *g = 1
                          p := (&owner.Preparer{GID: g}).SetOSProxy(m)
                          oRes, err := p.Prepare(context.Background(), fakerenderer.New())
              Severity: Major
              Found in resource/file/owner/preparer_test.go and 1 other location - About 2 hrs to fix
              resource/file/owner/preparer_test.go on lines 49..61

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 211.

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

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

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

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

              Refactorings

              Further Reading

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

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

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

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

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

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

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

              Refactorings

              Further Reading

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

                      t.Run("volume exists", func(t *testing.T) {
                          vol := &volume.Volume{Name: "test-volume", State: "absent"}
                          c := &mockClient{}
                          vol.SetClient(c)
                          c.On("FindVolume", "test-volume").Return(&dc.Volume{Name: "test-volume"}, nil)
              Severity: Major
              Found in resource/docker/volume/volume_test.go and 1 other location - About 2 hrs to fix
              resource/docker/volume/volume_test.go on lines 94..108

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

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

              func TestApply(t *testing.T) {
                  t.Parallel()
                  t.Run("single-diff", func(t *testing.T) {
                      users := []*user.User{fakeUser("1", "1", "user-1"), fakeUser("2", "2", "user-2")}
                      groups := []*user.Group{fakeGroup("1", "group-1"), fakeGroup("2", "group-2")}
              Severity: Major
              Found in resource/file/owner/owner_test.go - About 2 hrs to fix

                File graph_test.go has 511 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: Minor
                Found in graph/graph_test.go - About 2 hrs to fix

                  Preparer has 21 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  type Preparer struct {
                      Source      map[string]interface{}
                      Destination Resource
                  }
                  Severity: Minor
                  Found in resource/preparer.go - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language