Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sydneyli committed Jan 23, 2019
1 parent bc4ce47 commit fbd079c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
33 changes: 17 additions & 16 deletions checker/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func SetStatus(oldStatus CheckStatus, newStatus CheckStatus) CheckStatus {
return oldStatus
}

// Result the result of a singular check. It's agnostic to the nature
// Result is the result of a singular check. It's agnostic to the nature
// of the check performed, and simply stores a reference to the check's name,
// a summary of what the check should do, as well as any error, failure, or
// warning messages associated.
Expand All @@ -33,6 +33,7 @@ type Result struct {
Checks map[string]Result `json:"checks,omitempty"`
}

// NewResult constructs a base result object and returns its pointer.
func NewResult(name string) *Result {
return &Result{
Name: name,
Expand All @@ -45,34 +46,34 @@ func NewResult(name string) *Result {
// Error adds an error message to this check result.
// The Error status will override any other existing status for this check.
// Typically, when a check encounters an error, it stops executing.
func (c *Result) Error(format string, a ...interface{}) Result {
c.Status = SetStatus(c.Status, Error)
c.Messages = append(c.Messages, fmt.Sprintf("Error: "+format, a...))
return *c
func (r *Result) Error(format string, a ...interface{}) Result {
r.Status = SetStatus(r.Status, Error)
r.Messages = append(r.Messages, fmt.Sprintf("Error: "+format, a...))
return *r
}

// Failure adds a failure message to this check result.
// The Failure status will override any Status other than Error.
// Whenever Failure is called, the entire check is failed.
func (c *Result) Failure(format string, a ...interface{}) Result {
c.Status = SetStatus(c.Status, Failure)
c.Messages = append(c.Messages, fmt.Sprintf("Failure: "+format, a...))
return *c
func (r *Result) Failure(format string, a ...interface{}) Result {
r.Status = SetStatus(r.Status, Failure)
r.Messages = append(r.Messages, fmt.Sprintf("Failure: "+format, a...))
return *r
}

// Warning adds a warning message to this check result.
// The Warning status only supercedes the Success status.
func (c *Result) Warning(format string, a ...interface{}) Result {
c.Status = SetStatus(c.Status, Warning)
c.Messages = append(c.Messages, fmt.Sprintf("Warning: "+format, a...))
return *c
func (r *Result) Warning(format string, a ...interface{}) Result {
r.Status = SetStatus(r.Status, Warning)
r.Messages = append(r.Messages, fmt.Sprintf("Warning: "+format, a...))
return *r
}

// Success simply sets the status of Result to a Success.
// Status is set if no other status has been declared on this check.
func (c *Result) Success() Result {
c.Status = SetStatus(c.Status, Success)
return *c
func (r *Result) Success() Result {
r.Status = SetStatus(r.Status, Success)
return *r
}

// Returns result of specified check.
Expand Down
1 change: 1 addition & 0 deletions models/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/EFForg/starttls-backend/checker"
)

// Current version of the scanning API.
const ScanVersion = 1

// Scan stores the result of a scan of a domain
Expand Down

0 comments on commit fbd079c

Please sign in to comment.