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-valid", func(t *testing.T) {
            t.Parallel()
            p := &Preparer{
                SignalNumber: 9,
                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 38..49
resource/systemd/unit/preparer_test.go on lines 50..61
resource/systemd/unit/preparer_test.go on lines 62..73

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

        t.Run("when-lowercase", 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 38..49
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

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

        t.Run("when-sig-prefix", func(t *testing.T) {
            t.Parallel()
            p := &Preparer{
                SignalName: "sigkill",
                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 38..49
resource/systemd/unit/preparer_test.go on lines 50..61
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

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 175.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 174.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 174.

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

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

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

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

Refactorings

Further Reading

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

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

Duplicated Code

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

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

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

Tuning

This issue has a mass of 174.

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

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

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

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

Refactorings

Further Reading

Function newSliceTypePropertiesFromMap has 68 lines of code (exceeds 50 allowed). Consider refactoring.
Open

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

    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

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

    // Copyright © 2016 Asteris, LLC
    //
    // Licensed under the Apache License, Version 2.0 (the "License");
    // you may not use this file except in compliance with the License.
    // You may obtain a copy of the License at
    Severity: Major
    Found in resource/file/directory/preparer.go and 1 other location - About 1 hr to fix
    resource/file/content/preparer.go on lines 1..44

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

    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

    // Copyright © 2016 Asteris, LLC
    //
    // Licensed under the Apache License, Version 2.0 (the "License");
    // you may not use this file except in compliance with the License.
    // You may obtain a copy of the License at
    Severity: Major
    Found in resource/file/content/preparer.go and 1 other location - About 1 hr to fix
    resource/file/directory/preparer.go on lines 1..44

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

    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 ExportedFields has 67 lines of code (exceeds 50 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 1 hr to fix

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

      type fakeAPIClient struct {
          FindImageFunc       func(repoTag string) (*dc.Image, error)
          PullImageFunc       func(name, tag string) error
          FindContainerFunc   func(name string) (*dc.Container, error)
          CreateContainerFunc func(opts dc.CreateContainerOptions) (*dc.Container, error)
      Severity: Major
      Found in resource/docker/container/container_test.go and 1 other location - About 1 hr to fix
      resource/docker/image/image_test.go on lines 143..150

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

      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

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

      type fakeAPIClient struct {
          FindImageFunc       func(repoTag string) (*dc.Image, error)
          PullImageFunc       func(name, tag string) error
          FindContainerFunc   func(name string) (*dc.Container, error)
          CreateContainerFunc func(opts dc.CreateContainerOptions) (*dc.Container, error)
      Severity: Major
      Found in resource/docker/image/image_test.go and 1 other location - About 1 hr to fix
      resource/docker/container/container_test.go on lines 704..711

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

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

      func (p *Preparer) convertNumber(typ reflect.Type, r Renderer, name string, val interface{}, base int) (reflect.Value, error) {
          if val == nil {
              return reflect.Zero(typ), nil
          }
      
      
      Severity: Minor
      Found in resource/preparer.go - About 1 hr to fix

        Method User.DiffAdd has 65 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (u *User) DiffAdd(status *resource.Status) (*AddUserOptions, error) {
            options := new(AddUserOptions)
        
            // if a group exists with the same name as the user being added, a groupname
            // must also be indicated so the user may be added to that group
        Severity: Minor
        Found in resource/user/user.go - About 1 hr to fix

          Function TestRenderConditionals has 65 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func TestRenderConditionals(t *testing.T) {
              defer logging.HideLogs(t)()
          
              src := `
          param "a" {
          Severity: Minor
          Found in render/render_test.go - About 1 hr to fix

            Method Signal.String has 65 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (s Signal) String() string {
                switch s {
                case SIGHUP:
                    return "SIGHUP"
                case SIGINT:
            Severity: Minor
            Found in resource/systemd/unit/signals.go - About 1 hr to fix

              Method TypeExtractor.Visit has 65 lines of code (exceeds 50 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 1 hr to fix

                Function TestVGCheck has 65 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func TestVGCheck(t *testing.T) {
                    t.Run("check prerequisites failure", func(t *testing.T) {
                        lvm, m := testhelpers.MakeFakeLvm()
                        m.On("Check").Return(fmt.Errorf("failed"))
                        _ = simpleCheckFailure(t, lvm, "vg0", []string{"/dev/sda1"}, false, false)
                Severity: Minor
                Found in resource/lvm/vg/vg_test.go - About 1 hr to fix

                  Method Group.Apply has 16 return statements (exceeds 4 allowed).
                  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 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language