asteris-llc/converge

View on GitHub

Showing 615 of 615 total issues

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

        t.Run("timer", func(t *testing.T) {
            typeName := "timer"
            typeProps := map[string]interface{}{}
            m := &DbusMock{}
            m.On("ListUnits").Return([]dbus.UnitStatus{dbus.UnitStatus{Name: ("name." + typeName)}}, nil)
Severity: Major
Found in resource/systemd/unit/systemd_linux_test.go and 10 other locations - About 5 hrs to fix
resource/systemd/unit/systemd_linux_test.go on lines 177..199
resource/systemd/unit/systemd_linux_test.go on lines 200..222
resource/systemd/unit/systemd_linux_test.go on lines 223..245
resource/systemd/unit/systemd_linux_test.go on lines 246..268
resource/systemd/unit/systemd_linux_test.go on lines 269..291
resource/systemd/unit/systemd_linux_test.go on lines 292..314
resource/systemd/unit/systemd_linux_test.go on lines 315..337
resource/systemd/unit/systemd_linux_test.go on lines 361..383
resource/systemd/unit/systemd_linux_test.go on lines 384..406
resource/systemd/unit/systemd_linux_test.go on lines 407..429

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

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

        t.Run("socket", func(t *testing.T) {
            typeName := "socket"
            typeProps := map[string]interface{}{}
            m := &DbusMock{}
            m.On("ListUnits").Return([]dbus.UnitStatus{dbus.UnitStatus{Name: ("name." + typeName)}}, nil)
Severity: Major
Found in resource/systemd/unit/systemd_linux_test.go and 10 other locations - About 5 hrs to fix
resource/systemd/unit/systemd_linux_test.go on lines 200..222
resource/systemd/unit/systemd_linux_test.go on lines 223..245
resource/systemd/unit/systemd_linux_test.go on lines 246..268
resource/systemd/unit/systemd_linux_test.go on lines 269..291
resource/systemd/unit/systemd_linux_test.go on lines 292..314
resource/systemd/unit/systemd_linux_test.go on lines 315..337
resource/systemd/unit/systemd_linux_test.go on lines 338..360
resource/systemd/unit/systemd_linux_test.go on lines 361..383
resource/systemd/unit/systemd_linux_test.go on lines 384..406
resource/systemd/unit/systemd_linux_test.go on lines 407..429

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

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

        t.Run("swap", func(t *testing.T) {
            typeName := "swap"
            typeProps := map[string]interface{}{}
            m := &DbusMock{}
            m.On("ListUnits").Return([]dbus.UnitStatus{dbus.UnitStatus{Name: ("name." + typeName)}}, nil)
Severity: Major
Found in resource/systemd/unit/systemd_linux_test.go and 10 other locations - About 5 hrs to fix
resource/systemd/unit/systemd_linux_test.go on lines 177..199
resource/systemd/unit/systemd_linux_test.go on lines 200..222
resource/systemd/unit/systemd_linux_test.go on lines 223..245
resource/systemd/unit/systemd_linux_test.go on lines 246..268
resource/systemd/unit/systemd_linux_test.go on lines 292..314
resource/systemd/unit/systemd_linux_test.go on lines 315..337
resource/systemd/unit/systemd_linux_test.go on lines 338..360
resource/systemd/unit/systemd_linux_test.go on lines 361..383
resource/systemd/unit/systemd_linux_test.go on lines 384..406
resource/systemd/unit/systemd_linux_test.go on lines 407..429

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

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 TestParseSwitchConditionalWithDefault(t *testing.T) {
    var sampleDefault = `
switch "named-switch" {
    default {
        task.query "foo" {
Severity: Major
Found in parse/preprocessor/switch/switch_test.go and 1 other location - About 4 hrs to fix
parse/preprocessor/switch/switch_test.go on lines 175..204

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

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 TestParseSwitchConditionalWithCase(t *testing.T) {
    var sampleCase = `
switch "named-switch" {
    case "eq 1 0" "a" {
        task.query "foo" {
Severity: Major
Found in parse/preprocessor/switch/switch_test.go and 1 other location - About 4 hrs to fix
parse/preprocessor/switch/switch_test.go on lines 208..238

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

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

func peerBranchSampleGraph(t *testing.T) *graph.Graph {
    g := graph.New()

    g.Add(node.New(graph.ID("root"), struct{}{}))
    g.Add(node.New(graph.ID("root", "switch1"), struct{}{}))
Severity: Major
Found in graph/node/conditional/conditional_test.go - About 4 hrs to fix

    File container_test.go has 617 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 resource/docker/container/container_test.go - About 4 hrs to fix

      Function ExportedFields has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
      Open

      func ExportedFields(input interface{}) (exported []*ExportedField, err error) {
          nonEmbeddedFields := make(map[string]struct{})
          embeddedFields := make(map[string][]*ExportedField)
          if nil == input {
              return exported, ErrNilStruct
      Severity: Minor
      Found in resource/field_extractor.go - About 4 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 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

      Method Group.Apply has 138 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (g *Group) Apply(context.Context) (resource.TaskStatus, error) {
          var (
              groupByGid *user.Group
              gidErr     error
              newNameErr error
      Severity: Major
      Found in resource/group/group.go - About 4 hrs to fix

        Method Group.Check has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
        Open

        func (g *Group) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
            var (
                groupByGid     *user.Group
                gidErr         error
                groupByNewName *user.Group
        Severity: Minor
        Found in resource/group/group.go - About 4 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

        Method Group.Check has 130 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (g *Group) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
            var (
                groupByGid     *user.Group
                gidErr         error
                groupByNewName *user.Group
        Severity: Major
        Found in resource/group/group.go - About 4 hrs to fix

          Graph has 33 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type Graph struct {
              inner  *dag.AcyclicGraph
              values cmap.ConcurrentMap
          
              innerLock *sync.RWMutex
          Severity: Minor
          Found in graph/graph.go - About 4 hrs to fix

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

                t.Run("when-user-change-and-group-unspecified", func(t *testing.T) {
                    t.Parallel()
            
                    o := (&owner.Owner{
                        Destination: "foo",
            Severity: Major
            Found in resource/file/owner/owner_test.go and 3 other locations - About 4 hrs to fix
            resource/file/owner/owner_test.go on lines 152..176
            resource/file/owner/owner_test.go on lines 204..228
            resource/file/owner/owner_test.go on lines 230..254

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

            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-user-change-and-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 3 other locations - About 4 hrs to fix
            resource/file/owner/owner_test.go on lines 178..202
            resource/file/owner/owner_test.go on lines 204..228
            resource/file/owner/owner_test.go on lines 230..254

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

            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-group-change-and-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 3 other locations - About 4 hrs to fix
            resource/file/owner/owner_test.go on lines 152..176
            resource/file/owner/owner_test.go on lines 178..202
            resource/file/owner/owner_test.go on lines 230..254

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

            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-group-change-and-user-unspecified", func(t *testing.T) {
                    t.Parallel()
            
                    o := (&owner.Owner{
                        Destination: "foo",
            Severity: Major
            Found in resource/file/owner/owner_test.go and 3 other locations - About 4 hrs to fix
            resource/file/owner/owner_test.go on lines 152..176
            resource/file/owner/owner_test.go on lines 178..202
            resource/file/owner/owner_test.go on lines 204..228

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

            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