cloudfoundry-incubator/stratos

View on GitHub
src/jetstream/repository/tokens/pgsql_tokens.go

Summary

Maintainability
F
3 days
Test Coverage

Method PgsqlTokenRepository.findCNSIToken has a Cognitive Complexity of 25 (exceeds 8 allowed). Consider refactoring.
Open

func (p *PgsqlTokenRepository) findCNSIToken(cnsiGUID string, userGUID string, encryptionKey []byte, includeDisconnected bool) (interfaces.TokenRecord, error) {
    log.Debug("findCNSIToken")
    if cnsiGUID == "" {
        msg := "Unable to find CNSI Token without a valid CNSI GUID."
        log.Debug(msg)
Severity: Minor
Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 3 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 PgsqlTokenRepository.FindAllCNSITokenBackup has a Cognitive Complexity of 22 (exceeds 8 allowed). Consider refactoring.
Open

func (p *PgsqlTokenRepository) FindAllCNSITokenBackup(cnsiGUID string, encryptionKey []byte) ([]interfaces.BackupTokenRecord, error) {
    log.Debug("FindAllCNSITokenBackup")
    if cnsiGUID == "" {
        msg := "Unable to find CNSI Token without a valid CNSI GUID."
        log.Debug(msg)
Severity: Minor
Found in src/jetstream/repository/tokens/pgsql_tokens.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 pgsql_tokens.go has 521 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package tokens

import (
    "database/sql"
    "errors"
Severity: Minor
Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 2 hrs to fix

    Method PgsqlTokenRepository.SaveCNSIToken has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
    Open

    func (p *PgsqlTokenRepository) SaveCNSIToken(cnsiGUID string, userGUID string, tr interfaces.TokenRecord, encryptionKey []byte) error {
        log.Debug("SaveCNSIToken")
        if cnsiGUID == "" {
            msg := "Unable to save CNSI Token without a valid CNSI GUID."
            log.Debug(msg)
    Severity: Minor
    Found in src/jetstream/repository/tokens/pgsql_tokens.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

    Method PgsqlTokenRepository.findCNSIToken has 84 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (p *PgsqlTokenRepository) findCNSIToken(cnsiGUID string, userGUID string, encryptionKey []byte, includeDisconnected bool) (interfaces.TokenRecord, error) {
        log.Debug("findCNSIToken")
        if cnsiGUID == "" {
            msg := "Unable to find CNSI Token without a valid CNSI GUID."
            log.Debug(msg)
    Severity: Major
    Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 2 hrs to fix

      Method PgsqlTokenRepository.SaveCNSIToken has 78 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (p *PgsqlTokenRepository) SaveCNSIToken(cnsiGUID string, userGUID string, tr interfaces.TokenRecord, encryptionKey []byte) error {
          log.Debug("SaveCNSIToken")
          if cnsiGUID == "" {
              msg := "Unable to save CNSI Token without a valid CNSI GUID."
              log.Debug(msg)
      Severity: Major
      Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 2 hrs to fix

        Method PgsqlTokenRepository.FindAllCNSITokenBackup has 75 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (p *PgsqlTokenRepository) FindAllCNSITokenBackup(cnsiGUID string, encryptionKey []byte) ([]interfaces.BackupTokenRecord, error) {
            log.Debug("FindAllCNSITokenBackup")
            if cnsiGUID == "" {
                msg := "Unable to find CNSI Token without a valid CNSI GUID."
                log.Debug(msg)
        Severity: Minor
        Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 2 hrs to fix

          Method PgsqlTokenRepository.UpdateTokenAuth has 59 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (p *PgsqlTokenRepository) UpdateTokenAuth(userGUID string, tr interfaces.TokenRecord, encryptionKey []byte) error {
              log.Debug("UpdateTokenAuth")
          
              if userGUID == "" {
                  msg := "Unable to save Token without a valid User GUID."
          Severity: Minor
          Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 1 hr to fix

            Method PgsqlTokenRepository.UpdateTokenAuth has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring.
            Open

            func (p *PgsqlTokenRepository) UpdateTokenAuth(userGUID string, tr interfaces.TokenRecord, encryptionKey []byte) error {
                log.Debug("UpdateTokenAuth")
            
                if userGUID == "" {
                    msg := "Unable to save Token without a valid User GUID."
            Severity: Minor
            Found in src/jetstream/repository/tokens/pgsql_tokens.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

            Method PgsqlTokenRepository.SaveAuthToken has 51 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (p *PgsqlTokenRepository) SaveAuthToken(userGUID string, tr interfaces.TokenRecord, encryptionKey []byte) error {
                log.Debug("SaveAuthToken")
                if userGUID == "" {
                    msg := "Unable to save Auth Token without a valid User GUID."
                    log.Debug(msg)
            Severity: Minor
            Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 1 hr to fix

              Method PgsqlTokenRepository.SaveCNSIToken has 10 return statements (exceeds 4 allowed).
              Open

              func (p *PgsqlTokenRepository) SaveCNSIToken(cnsiGUID string, userGUID string, tr interfaces.TokenRecord, encryptionKey []byte) error {
                  log.Debug("SaveCNSIToken")
                  if cnsiGUID == "" {
                      msg := "Unable to save CNSI Token without a valid CNSI GUID."
                      log.Debug(msg)
              Severity: Major
              Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 1 hr to fix

                Method PgsqlTokenRepository.UpdateTokenAuth has 10 return statements (exceeds 4 allowed).
                Open

                func (p *PgsqlTokenRepository) UpdateTokenAuth(userGUID string, tr interfaces.TokenRecord, encryptionKey []byte) error {
                    log.Debug("UpdateTokenAuth")
                
                    if userGUID == "" {
                        msg := "Unable to save Token without a valid User GUID."
                Severity: Major
                Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 1 hr to fix

                  Method PgsqlTokenRepository.SaveAuthToken has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
                  Open

                  func (p *PgsqlTokenRepository) SaveAuthToken(userGUID string, tr interfaces.TokenRecord, encryptionKey []byte) error {
                      log.Debug("SaveAuthToken")
                      if userGUID == "" {
                          msg := "Unable to save Auth Token without a valid User GUID."
                          log.Debug(msg)
                  Severity: Minor
                  Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 55 mins 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 PgsqlTokenRepository.findCNSIToken has 7 return statements (exceeds 4 allowed).
                  Open

                  func (p *PgsqlTokenRepository) findCNSIToken(cnsiGUID string, userGUID string, encryptionKey []byte, includeDisconnected bool) (interfaces.TokenRecord, error) {
                      log.Debug("findCNSIToken")
                      if cnsiGUID == "" {
                          msg := "Unable to find CNSI Token without a valid CNSI GUID."
                          log.Debug(msg)
                  Severity: Major
                  Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 45 mins to fix

                    Method PgsqlTokenRepository.SaveAuthToken has 7 return statements (exceeds 4 allowed).
                    Open

                    func (p *PgsqlTokenRepository) SaveAuthToken(userGUID string, tr interfaces.TokenRecord, encryptionKey []byte) error {
                        log.Debug("SaveAuthToken")
                        if userGUID == "" {
                            msg := "Unable to save Auth Token without a valid User GUID."
                            log.Debug(msg)
                    Severity: Major
                    Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 45 mins to fix

                      Method PgsqlTokenRepository.FindAllCNSITokenBackup has 6 return statements (exceeds 4 allowed).
                      Open

                      func (p *PgsqlTokenRepository) FindAllCNSITokenBackup(cnsiGUID string, encryptionKey []byte) ([]interfaces.BackupTokenRecord, error) {
                          log.Debug("FindAllCNSITokenBackup")
                          if cnsiGUID == "" {
                              msg := "Unable to find CNSI Token without a valid CNSI GUID."
                              log.Debug(msg)
                      Severity: Major
                      Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 40 mins to fix

                        Method PgsqlTokenRepository.FindAuthToken has 5 return statements (exceeds 4 allowed).
                        Open

                        func (p *PgsqlTokenRepository) FindAuthToken(userGUID string, encryptionKey []byte) (interfaces.TokenRecord, error) {
                            log.Debug("FindAuthToken")
                            if userGUID == "" {
                                msg := "Unable to find UAA Token without a valid User GUID."
                                log.Debug(msg)
                        Severity: Major
                        Found in src/jetstream/repository/tokens/pgsql_tokens.go - About 35 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status