asteris-llc/converge

View on GitHub

Showing 572 of 572 total issues

Function newMountTypePropertiesFromMap has 389 lines of code (exceeds 50 allowed). Consider refactoring.
Open

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

    if val, ok := m["AmbientCapabilities"]; ok {
        s.AmbientCapabilities = val.(uint64)
Severity: Major
Found in resource/systemd/unit/systemd_properties.go - About 1 day to fix

    Function TestListUnits has 383 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestListUnits(t *testing.T) {
        t.Parallel()
    
        t.Run("when-dbus-errors", func(t *testing.T) {
            t.Run("list-units-returns-error", func(t *testing.T) {
    Severity: Major
    Found in resource/systemd/unit/systemd_linux_test.go - About 1 day to fix

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

      func TestCheck(t *testing.T) {
          t.Parallel()
      
          users := []*user.User{
              fakeUser("1", "1", "user-1"),
      Severity: Major
      Found in resource/file/owner/owner_test.go - About 1 day to fix

        Function newSwapTypePropertiesFromMap has 377 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func newSwapTypePropertiesFromMap(m map[string]interface{}) *SwapTypeProperties {
            s := &SwapTypeProperties{}
        
            if val, ok := m["AmbientCapabilities"]; ok {
                s.AmbientCapabilities = val.(uint64)
        Severity: Major
        Found in resource/systemd/unit/systemd_properties.go - About 1 day to fix

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

          func TestCheck(t *testing.T) {
              t.Parallel()
          
              t.Run("state=present", func(t *testing.T) {
                  g := group.NewGroup(new(group.System))
          Severity: Major
          Found in resource/group/group_test.go - About 1 day to fix

            Function TestPreparerPrepare has 306 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func TestPreparerPrepare(t *testing.T) {
                defer logging.HideLogs(t)()
            
                // newWithField is a little utility. We have this pattern over and over
                // where we need to set a target field and then check that we render without
            Severity: Major
            Found in resource/preparer_test.go - About 1 day to fix

              Function TestDiffAdd has 302 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func TestDiffAdd(t *testing.T) {
                  t.Parallel()
              
                  zone := time.FixedZone(time.Now().In(time.Local).Zone())
                  expiryString := "1996-12-12"
              Severity: Major
              Found in resource/user/user_test.go - About 1 day to fix

                File group_test.go has 874 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: Major
                Found in resource/group/group_test.go - About 1 day to fix

                  Function TestNetworkCheck has 295 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func TestNetworkCheck(t *testing.T) {
                      t.Parallel()
                      defer logging.HideLogs(t)()
                  
                      nwName := "test-network"
                  Severity: Major
                  Found in resource/docker/network/network_test.go - About 1 day to fix

                    Function TestDiffMod has 290 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func TestDiffMod(t *testing.T) {
                        t.Parallel()
                    
                        t.Run("set all options", func(t *testing.T) {
                            u := user.NewUser(new(user.System))
                    Severity: Major
                    Found in resource/user/user_test.go - About 1 day to fix

                      Function TestApply has 283 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func TestApply(t *testing.T) {
                          t.Parallel()
                      
                          t.Run("hash error", func(t *testing.T) {
                              task := fetch.Fetch{
                      Severity: Major
                      Found in resource/file/fetch/fetch_test.go - About 1 day to fix

                        Function TestApply has 277 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func TestApply(t *testing.T) {
                            t.Parallel()
                            t.Run("query-unit-returns-error", func(t *testing.T) {
                                t.Parallel()
                                expected := errors.New("error1")
                        Severity: Major
                        Found in resource/systemd/unit/resource_test.go - About 1 day to fix

                          File systemd_linux_test.go has 834 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: Major
                          Found in resource/systemd/unit/systemd_linux_test.go - About 1 day to fix

                            Function newPropertiesFromMap has a Cognitive Complexity of 74 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func newPropertiesFromMap(m map[string]interface{}) *Properties {
                                s := &Properties{}
                            
                                if val, ok := m["ActiveEnterTimestamp"]; ok {
                                    s.ActiveEnterTimestamp = val.(uint64)
                            Severity: Minor
                            Found in resource/systemd/unit/systemd_properties.go - About 1 day 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.Apply has a Cognitive Complexity of 74 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func (g *Group) Apply(context.Context) (resource.TaskStatus, error) {
                                var (
                                    groupByGid *user.Group
                                    gidErr     error
                                    newNameErr error
                            Severity: Minor
                            Found in resource/group/group.go - About 1 day 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 TestEvaluateDuplicates has 248 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func TestEvaluateDuplicates(t *testing.T) {
                                t.Parallel()
                            
                                t.Run("no duplicates", func(t *testing.T) {
                                    destDir, err := ioutil.TempDir("", "destDir_unarchive")
                            Severity: Major
                            Found in resource/unarchive/unarchive_test.go - About 1 day to fix

                              Function TestApply has 247 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func TestApply(t *testing.T) {
                                  t.Parallel()
                              
                                  srcDir, err := ioutil.TempDir("", "unarchive_srcDir")
                                  require.NoError(t, err)
                              Severity: Major
                              Found in resource/unarchive/unarchive_test.go - About 1 day to fix

                                Function TestApply has 246 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func TestApply(t *testing.T) {
                                    t.Parallel()
                                
                                    t.Run("state=present", func(t *testing.T) {
                                        t.Run("add tests", func(t *testing.T) {
                                Severity: Major
                                Found in resource/user/user_test.go - About 1 day to fix

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

                                      t.Run("Original", func(t *testing.T) {
                                          t.Run("uid", func(t *testing.T) {
                                              o := (&owner.OwnershipDiff{UIDs: &[2]int{1, 2}}).SetProxy(m)
                                              assert.Equal(t, "user: user-1 (1)", o.Original())
                                          })
                                  Severity: Major
                                  Found in resource/file/owner/ownership_test.go and 1 other location - About 1 day to fix
                                  resource/file/owner/ownership_test.go on lines 64..87

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

                                  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("Current", func(t *testing.T) {
                                          t.Run("uid", func(t *testing.T) {
                                              o := (&owner.OwnershipDiff{UIDs: &[2]int{1, 2}}).SetProxy(m)
                                              assert.Equal(t, "user: user-2 (2)", o.Current())
                                          })
                                  Severity: Major
                                  Found in resource/file/owner/ownership_test.go and 1 other location - About 1 day to fix
                                  resource/file/owner/ownership_test.go on lines 40..63

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

                                  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