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("long form-second out of range", func(t *testing.T) {
                val := "2003-01-02T01:02:61"
                prep := &resource.Preparer{
                    Source:      map[string]interface{}{"time": val},
                    Destination: new(testPreparerTarget),
Severity: Major
Found in resource/preparer_test.go and 3 other locations - About 1 hr to fix
resource/preparer_test.go on lines 175..188
resource/preparer_test.go on lines 190..203
resource/preparer_test.go on lines 220..233

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

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("unknown", func(t *testing.T) {
                val := "3.2"
                prep := &resource.Preparer{
                    Source:      map[string]interface{}{"time": val},
                    Destination: new(testPreparerTarget),
Severity: Major
Found in resource/preparer_test.go and 3 other locations - About 1 hr to fix
resource/preparer_test.go on lines 190..203
resource/preparer_test.go on lines 205..218
resource/preparer_test.go on lines 220..233

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

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("short form", func(t *testing.T) {
                val := "2003-01-"
                prep := &resource.Preparer{
                    Source:      map[string]interface{}{"time": val},
                    Destination: new(testPreparerTarget),
Severity: Major
Found in resource/preparer_test.go and 3 other locations - About 1 hr to fix
resource/preparer_test.go on lines 175..188
resource/preparer_test.go on lines 205..218
resource/preparer_test.go on lines 220..233

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

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("zone provided-extra text", func(t *testing.T) {
                val := "2003-01-02T01:02:03-25:00:00"
                prep := &resource.Preparer{
                    Source:      map[string]interface{}{"time": val},
                    Destination: new(testPreparerTarget),
Severity: Major
Found in resource/preparer_test.go and 3 other locations - About 1 hr to fix
resource/preparer_test.go on lines 175..188
resource/preparer_test.go on lines 190..203
resource/preparer_test.go on lines 205..218

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

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 assertCorrectTypeProperties has 20 return statements (exceeds 4 allowed).
Open

func assertCorrectTypeProperties(t *testing.T, u *Unit) {
    checks := map[string]func() bool{
        "service":   func() bool { return u.ServiceProperties == nil },
        "socket":    func() bool { return u.SocketProperties == nil },
        "device":    func() bool { return u.DeviceProperties == nil },
Severity: Major
Found in resource/systemd/unit/utils_linux_test.go - About 1 hr to fix

    Function TestCheck has 70 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestCheck(t *testing.T) {
        t.Parallel()
    
        srcFile, err := ioutil.TempFile("", "unarchive_test.txt")
        require.NoError(t, err)
    Severity: Minor
    Found in resource/unarchive/unarchive_test.go - About 1 hr to fix

      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 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("when-group-no-change", func(t *testing.T) {
              t.Parallel()
      
              o := (&owner.Owner{
                  Destination: "foo",
      Severity: Major
      Found in resource/file/owner/owner_test.go and 1 other location - About 1 hr to fix
      resource/file/owner/owner_test.go on lines 92..106

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

      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) Check(ctx context.Context, r resource.Renderer) (resource.TaskStatus, error) {
          ch := make(chan response, 1)
      
          go func(ctx context.Context, r resource.Renderer) {
              status, err := f.checkWithContext(ctx, r)
      Severity: Major
      Found in resource/file/fetch/fetch.go and 1 other location - About 1 hr to fix
      resource/unarchive/unarchive.go on lines 108..122

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

      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-user-no-change", func(t *testing.T) {
              t.Parallel()
      
              o := (&owner.Owner{
                  Destination: "foo",
      Severity: Major
      Found in resource/file/owner/owner_test.go and 1 other location - About 1 hr to fix
      resource/file/owner/owner_test.go on lines 108..122

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

      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) Check(ctx context.Context, r resource.Renderer) (resource.TaskStatus, error) {
          ch := make(chan response, 1)
      
          go func(ctx context.Context, r resource.Renderer) {
              status, err := u.checkWithContext(ctx, r)
      Severity: Major
      Found in resource/unarchive/unarchive.go and 1 other location - About 1 hr to fix
      resource/file/fetch/fetch.go on lines 84..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 177.

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

      func TestNodeWithConditionals(t *testing.T) {
          t.Parallel()
          defer logging.HideLogs(t)()
          g, err := load.Nodes(context.Background(), "../samples/conditionalLanguages.hcl", false)
          require.NoError(t, err)
      Severity: Minor
      Found in load/nodes_test.go - About 1 hr to fix

        Function ParseSignalByName has 69 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func ParseSignalByName(s string) (Signal, error) {
            s = strings.ToUpper(s)
            if !strings.HasPrefix(s, "SIG") {
                s = "SIG" + s
            }
        Severity: Minor
        Found in resource/systemd/unit/signals.go - About 1 hr to fix

          Function newScopeTypePropertiesFromMap has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
          Open

          func newScopeTypePropertiesFromMap(m map[string]interface{}) *ScopeTypeProperties {
              s := &ScopeTypeProperties{}
          
              if val, ok := m["BlockIOAccounting"]; ok {
                  s.BlockIOAccounting = val.(bool)
          Severity: Minor
          Found in resource/systemd/unit/systemd_properties.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

          Function alignEdgesInGroup has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
          Open

          func alignEdgesInGroup(ctx context.Context, g *graph.Graph, id, group string) (*graph.Graph, error) {
              upEdges := withoutRoot(g.UpEdgesInGroup(id, group))
              for i, upEdge := range upEdges {
                  if i > 0 {
                      dest := highestGroupEdge(g, upEdges[i-1], group)
          Severity: Minor
          Found in load/dependencyresolver.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 4 locations. Consider refactoring.
          Open

                  t.Run("when-uppercase", func(t *testing.T) {
                      t.Parallel()
                      p := &Preparer{
                          SignalName: "KILL",
                          executor:   &ExecutorMock{},
          Severity: Major
          Found in resource/systemd/unit/preparer_test.go and 3 other locations - About 1 hr to fix
          resource/systemd/unit/preparer_test.go on lines 50..61
          resource/systemd/unit/preparer_test.go on lines 62..73
          resource/systemd/unit/preparer_test.go on lines 98..109

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 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

          Function Nodes has a Cognitive Complexity of 29 (exceeds 20 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

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

          Severity
          Category
          Status
          Source
          Language