@@ -20,35 +20,35 @@ import (
2020// one suffices, but one fails, the whole check might be OK and only the subcheck
2121// Warning or Critical.
2222type Overall struct {
23- oks int
24- warnings int
25- criticals int
26- unknowns int
27- Summary string
28- stateSetExplicitely bool
29- Outputs []string // Deprecate this in a future version
30- PartialResults []PartialResult
23+ oks int
24+ warnings int
25+ criticals int
26+ unknowns int
27+ Summary string
28+ stateSetExplicitly bool
29+ Outputs []string // Deprecate this in a future version
30+ PartialResults []PartialResult
3131}
3232
3333// PartialResult represents a sub-result for an Overall struct
3434type PartialResult struct {
35- state int // Result state, either set explicitely or derived from partialResults
36- Output string
37- stateSetExplicitely bool // nolint: unused
38- defaultState int // Default result state, if no partial results are available and no state is set explicitely
39- defaultStateSet bool // nolint: unused
40- Perfdata perfdata. PerfdataList
41- PartialResults [] PartialResult
35+ Perfdata perfdata. PerfdataList
36+ PartialResults [] PartialResult
37+ Output string
38+ state int // Result state, either set explicitly or derived from partialResults
39+ defaultState int // Default result state, if no partial results are available and no state is set explicitly
40+ stateSetExplicitly bool // nolint: unused
41+ defaultStateSet bool // nolint: unused
4242}
4343
4444// String returns the status and output of the PartialResult
4545func (s * PartialResult ) String () string {
4646 return fmt .Sprintf ("[%s] %s" , check .StatusText (s .GetStatus ()), s .Output )
4747}
4848
49- // Add adds a return state explicitely
49+ // Add adds a return state explicitly
5050//
51- // Hint: This will set stateSetExplicitely to true
51+ // Hint: This will set stateSetExplicitly to true
5252func (o * Overall ) Add (state int , output string ) {
5353 switch state {
5454 case check .OK :
@@ -61,8 +61,8 @@ func (o *Overall) Add(state int, output string) {
6161 o .unknowns ++
6262 }
6363
64- // TODO: Might be a bit obscure that the Add method also sets stateSetExplicitely
65- o .stateSetExplicitely = true
64+ // TODO: Might be a bit obscure that the Add method also sets stateSetExplicitly
65+ o .stateSetExplicitly = true
6666
6767 o .Outputs = append (o .Outputs , fmt .Sprintf ("[%s] %s" , check .StatusText (state ), output ))
6868}
@@ -73,13 +73,14 @@ func (o *Overall) AddSubcheck(subcheck PartialResult) {
7373}
7474
7575// AddSubcheck adds a PartialResult to the PartialResult
76- func (o * PartialResult ) AddSubcheck (subcheck PartialResult ) {
77- o .PartialResults = append (o .PartialResults , subcheck )
76+ func (s * PartialResult ) AddSubcheck (subcheck PartialResult ) {
77+ s .PartialResults = append (s .PartialResults , subcheck )
7878}
7979
8080// GetStatus returns the current state (ok, warning, critical, unknown) of the Overall
8181func (o * Overall ) GetStatus () int {
82- if o .stateSetExplicitely {
82+ if o .stateSetExplicitly {
83+ // nolint: gocritic
8384 if o .criticals > 0 {
8485 return check .Critical
8586 } else if o .unknowns > 0 {
@@ -92,7 +93,7 @@ func (o *Overall) GetStatus() int {
9293 return check .Unknown
9394 }
9495 } else {
95- // state not set explicitely !
96+ // state not set explicitly !
9697 if len (o .PartialResults ) == 0 {
9798 return check .Unknown
9899 }
@@ -144,8 +145,8 @@ func (o *Overall) GetSummary() string {
144145 return o .Summary
145146 }
146147
147- // Was the state set explicitely ?
148- if o .stateSetExplicitely {
148+ // Was the state set explicitly ?
149+ if o .stateSetExplicitly {
149150 // Yes, so lets generate it from the sum of the overall states
150151 if o .criticals > 0 {
151152 o .Summary += fmt .Sprintf ("critical=%d " , o .criticals )
@@ -169,7 +170,7 @@ func (o *Overall) GetSummary() string {
169170 }
170171 }
171172
172- if ! o .stateSetExplicitely {
173+ if ! o .stateSetExplicitly {
173174 // No, so lets combine the partial ones
174175 if len (o .PartialResults ) == 0 {
175176 // Oh, we actually don't have those either
@@ -238,10 +239,10 @@ func (o *Overall) GetOutput() string {
238239 pdata .WriteString (" " + o .PartialResults [i ].getPerfdata ())
239240 }
240241
241- pdata_string := strings .Trim (pdata .String (), " " )
242+ pdataString := strings .Trim (pdata .String (), " " )
242243
243- if len (pdata_string ) > 0 {
244- output .WriteString ("|" + pdata_string + "\n " )
244+ if len (pdataString ) > 0 {
245+ output .WriteString ("|" + pdataString + "\n " )
245246 }
246247 }
247248
@@ -266,15 +267,15 @@ func (s *PartialResult) getPerfdata() string {
266267}
267268
268269// getOutput generates indented output for all subsequent PartialResults
269- func (s * PartialResult ) getOutput (indent_level int ) string {
270+ func (s * PartialResult ) getOutput (indentLevel int ) string {
270271 var output strings.Builder
271272
272- prefix := strings .Repeat (" " , indent_level )
273+ prefix := strings .Repeat (" " , indentLevel )
273274 output .WriteString (prefix + "\\ _ " + s .String () + "\n " )
274275
275276 if s .PartialResults != nil {
276277 for _ , ss := range s .PartialResults {
277- output .WriteString (ss .getOutput (indent_level + 2 ))
278+ output .WriteString (ss .getOutput (indentLevel + 2 ))
278279 }
279280 }
280281
@@ -300,15 +301,15 @@ func (s *PartialResult) SetState(state int) error {
300301 }
301302
302303 s .state = state
303- s .stateSetExplicitely = true
304+ s .stateSetExplicitly = true
304305
305306 return nil
306307}
307308
308309// GetStatus returns the current state (ok, warning, critical, unknown) of the PartialResult
309310// nolint: unused
310311func (s * PartialResult ) GetStatus () int {
311- if s .stateSetExplicitely {
312+ if s .stateSetExplicitly {
312313 return s .state
313314 }
314315
0 commit comments