cloudfoundry/stratos

View on GitHub
src/jetstream/plugins/backup/backup_restore.go

Summary

Maintainability
A
0 mins
Test Coverage

Method cnsiTokenBackup.createBackup has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring.
Wontfix

func (ctb *cnsiTokenBackup) createBackup(data *BackupRequest) (*BackupContent, error) {
    log.Debug("createBackup")
    allEndpoints, err := ctb.p.ListEndpoints()
    if err != nil {
        return nil, interfaces.NewHTTPShadowError(http.StatusBadGateway, "Failed to fetch endpoints", "Failed to fetch endpoints: %+v", err)
Severity: Minor
Found in src/jetstream/plugins/backup/backup_restore.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 cnsiTokenBackup.restoreBackup has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring.
Wontfix

func (ctb *cnsiTokenBackup) restoreBackup(backup *RestoreRequest) error {
    log.Debug("restoreBackup")

    data := &BackupContent{}
    if err := json.Unmarshal([]byte(backup.Data), data); err != nil {
Severity: Minor
Found in src/jetstream/plugins/backup/backup_restore.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 cnsiTokenBackup.createBackup has 53 lines of code (exceeds 50 allowed). Consider refactoring.
Wontfix

func (ctb *cnsiTokenBackup) createBackup(data *BackupRequest) (*BackupContent, error) {
    log.Debug("createBackup")
    allEndpoints, err := ctb.p.ListEndpoints()
    if err != nil {
        return nil, interfaces.NewHTTPShadowError(http.StatusBadGateway, "Failed to fetch endpoints", "Failed to fetch endpoints: %+v", err)
Severity: Minor
Found in src/jetstream/plugins/backup/backup_restore.go - About 1 hr to fix

    Method cnsiTokenBackup.restoreBackup has 9 return statements (exceeds 4 allowed).
    Wontfix

    func (ctb *cnsiTokenBackup) restoreBackup(backup *RestoreRequest) error {
        log.Debug("restoreBackup")
    
        data := &BackupContent{}
        if err := json.Unmarshal([]byte(backup.Data), data); err != nil {
    Severity: Major
    Found in src/jetstream/plugins/backup/backup_restore.go - About 55 mins to fix

      Method cnsiTokenBackup.BackupEndpoints has 6 return statements (exceeds 4 allowed).
      Wontfix

      func (ctb *cnsiTokenBackup) BackupEndpoints(c echo.Context) error {
          log.Debug("BackupEndpoints")
      
          // Create the backup request struct from the body
          body, err := ioutil.ReadAll(c.Request().Body)
      Severity: Major
      Found in src/jetstream/plugins/backup/backup_restore.go - About 40 mins to fix

        Method cnsiTokenBackup.createBackup has 5 return statements (exceeds 4 allowed).
        Wontfix

        func (ctb *cnsiTokenBackup) createBackup(data *BackupRequest) (*BackupContent, error) {
            log.Debug("createBackup")
            allEndpoints, err := ctb.p.ListEndpoints()
            if err != nil {
                return nil, interfaces.NewHTTPShadowError(http.StatusBadGateway, "Failed to fetch endpoints", "Failed to fetch endpoints: %+v", err)
        Severity: Major
        Found in src/jetstream/plugins/backup/backup_restore.go - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status