kubenetworks/kubevpn

View on GitHub
pkg/ssh/gssapi_ccache.go

Summary

Maintainability
D
2 days
Test Coverage

Method CCache.writeCredential has 109 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *CCache) writeCredential(cred *Credential, endian *binary.ByteOrder) ([]byte, error) {
    var byteString bytes.Buffer
    var err error

    b := &byteString
Severity: Major
Found in pkg/ssh/gssapi_ccache.go - About 3 hrs to fix

    Method CCache.writeCredential has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *CCache) writeCredential(cred *Credential, endian *binary.ByteOrder) ([]byte, error) {
        var byteString bytes.Buffer
        var err error
    
        b := &byteString
    Severity: Minor
    Found in pkg/ssh/gssapi_ccache.go - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    File gssapi_ccache.go has 508 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package ssh
    
    import (
        "bytes"
        "encoding/binary"
    Severity: Minor
    Found in pkg/ssh/gssapi_ccache.go - About 2 hrs to fix

      Method CCache.writeCredential has 24 return statements (exceeds 4 allowed).
      Open

      func (c *CCache) writeCredential(cred *Credential, endian *binary.ByteOrder) ([]byte, error) {
          var byteString bytes.Buffer
          var err error
      
          b := &byteString
      Severity: Major
      Found in pkg/ssh/gssapi_ccache.go - About 2 hrs to fix

        Method CCache.Marshal has 8 return statements (exceeds 4 allowed).
        Open

        func (c *CCache) Marshal() ([]byte, error) {
            var b bytes.Buffer
            var err error
            endian := c.getEndian()
        
        
        Severity: Major
        Found in pkg/ssh/gssapi_ccache.go - About 50 mins to fix

          Method CCache.writePrincipal has 7 return statements (exceeds 4 allowed).
          Open

          func (c *CCache) writePrincipal(p principal, endian *binary.ByteOrder) ([]byte, error) {
              var byteString bytes.Buffer
              var err error
          
              b := &byteString
          Severity: Major
          Found in pkg/ssh/gssapi_ccache.go - About 45 mins to fix

            Method CCache.Unmarshal has 5 return statements (exceeds 4 allowed).
            Open

            func (c *CCache) Unmarshal(b []byte) error {
                p := 0
                //The first byte of the file always has the value 5
                if int8(b[p]) != 5 {
                    return errors.New("Invalid credential cache data. First byte does not equal 5")
            Severity: Major
            Found in pkg/ssh/gssapi_ccache.go - About 35 mins to fix

              Method CCache.writeV4Header has 5 return statements (exceeds 4 allowed).
              Open

              func (c *CCache) writeV4Header() ([]byte, error) {
                  var byteString bytes.Buffer
                  var err error
              
                  b := &byteString
              Severity: Major
              Found in pkg/ssh/gssapi_ccache.go - About 35 mins to fix

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

                    for _, address := range cred.Addresses {
                        // Type
                        err = binary.Write(b, *endian, uint16(address.AddrType))
                        if err != nil {
                            return []byte{}, err
                Severity: Major
                Found in pkg/ssh/gssapi_ccache.go and 1 other location - About 1 hr to fix
                pkg/ssh/gssapi_ccache.go on lines 393..409

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

                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

                    for _, authData := range cred.AuthData {
                        // Type
                        err = binary.Write(b, *endian, uint16(authData.ADType))
                        if err != nil {
                            return []byte{}, err
                Severity: Major
                Found in pkg/ssh/gssapi_ccache.go and 1 other location - About 1 hr to fix
                pkg/ssh/gssapi_ccache.go on lines 367..383

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

                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 readInt32(b []byte, p *int, e *binary.ByteOrder) (i int32) {
                    buf := bytes.NewBuffer(b[*p : *p+4])
                    binary.Read(buf, *e, &i)
                    *p += 4
                    return
                Severity: Minor
                Found in pkg/ssh/gssapi_ccache.go and 1 other location - About 30 mins to fix
                pkg/ssh/gssapi_ccache.go on lines 630..635

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

                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 readInt16(b []byte, p *int, e *binary.ByteOrder) (i int16) {
                    buf := bytes.NewBuffer(b[*p : *p+2])
                    binary.Read(buf, *e, &i)
                    *p += 2
                    return
                Severity: Minor
                Found in pkg/ssh/gssapi_ccache.go and 1 other location - About 30 mins to fix
                pkg/ssh/gssapi_ccache.go on lines 638..643

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

                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

                There are no issues that match your filters.

                Category
                Status