@@ -180,7 +180,7 @@ type Feature struct {
180
180
}
181
181
182
182
// Compare compares two features and returns an integer representing
183
- // if the first feature (a ) is greater than, equal to, or less than the second
183
+ // if the first feature (f ) is greater than, equal to, or less than the second
184
184
// feature (b). "Greater than" means the first feature has more functionality
185
185
// than the second feature. It is assumed the features are for the same FeatureName.
186
186
//
@@ -190,59 +190,59 @@ type Feature struct {
190
190
// 3. The limit is greater
191
191
// 4. Enabled is greater than disabled
192
192
// 5. The actual is greater
193
- func (a Feature ) Compare (b Feature ) int {
194
- if ! a .Capable () || ! b .Capable () {
193
+ func (f Feature ) Compare (b Feature ) int {
194
+ if ! f .Capable () || ! b .Capable () {
195
195
// If either is incapable, then it is possible a grace period
196
196
// feature can be "greater" than an entitled.
197
197
// If either is "NotEntitled" then we can defer to a strict entitlement
198
198
// check.
199
- if a .Entitlement .Weight () >= 0 && b .Entitlement .Weight () >= 0 {
200
- if a .Capable () && ! b .Capable () {
199
+ if f .Entitlement .Weight () >= 0 && b .Entitlement .Weight () >= 0 {
200
+ if f .Capable () && ! b .Capable () {
201
201
return 1
202
202
}
203
- if b .Capable () && ! a .Capable () {
203
+ if b .Capable () && ! f .Capable () {
204
204
return - 1
205
205
}
206
206
}
207
207
}
208
208
209
209
// Strict entitlement check. Higher is better
210
- entitlementDifference := a .Entitlement .Weight () - b .Entitlement .Weight ()
210
+ entitlementDifference := f .Entitlement .Weight () - b .Entitlement .Weight ()
211
211
if entitlementDifference != 0 {
212
212
return entitlementDifference
213
213
}
214
214
215
215
// If the entitlement is the same, then we can compare the limits.
216
- if a .Limit == nil && b .Limit != nil {
216
+ if f .Limit == nil && b .Limit != nil {
217
217
return - 1
218
218
}
219
- if a .Limit != nil && b .Limit == nil {
219
+ if f .Limit != nil && b .Limit == nil {
220
220
return 1
221
221
}
222
- if a .Limit != nil && b .Limit != nil {
223
- difference := * a .Limit - * b .Limit
222
+ if f .Limit != nil && b .Limit != nil {
223
+ difference := * f .Limit - * b .Limit
224
224
if difference != 0 {
225
225
return int (difference )
226
226
}
227
227
}
228
228
229
229
// Enabled is better than disabled.
230
- if a .Enabled && ! b .Enabled {
230
+ if f .Enabled && ! b .Enabled {
231
231
return 1
232
232
}
233
- if ! a .Enabled && b .Enabled {
233
+ if ! f .Enabled && b .Enabled {
234
234
return - 1
235
235
}
236
236
237
237
// Higher actual is better
238
- if a .Actual == nil && b .Actual != nil {
238
+ if f .Actual == nil && b .Actual != nil {
239
239
return - 1
240
240
}
241
- if a .Actual != nil && b .Actual == nil {
241
+ if f .Actual != nil && b .Actual == nil {
242
242
return 1
243
243
}
244
- if a .Actual != nil && b .Actual != nil {
245
- difference := * a .Actual - * b .Actual
244
+ if f .Actual != nil && b .Actual != nil {
245
+ difference := * f .Actual - * b .Actual
246
246
if difference != 0 {
247
247
return int (difference )
248
248
}
0 commit comments