Skip to content

Commit 52eca96

Browse files
committed
refactor(featuredetection): remove temp in favour of early returns
Signed-off-by: Babak K. Shandiz <babakks@github.com>
1 parent ce01621 commit 52eca96

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

internal/featuredetection/feature_detection.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -425,28 +425,30 @@ func (d *detector) ActionsFeatures() (ActionsFeatures, error) {
425425
// going to be ignored/removed. So, once we are migrating to the new API version we should double check the status
426426
// of the API.
427427

428-
var dispatchRunDetailsSupported bool
429-
430428
if !ghauth.IsEnterprise(d.host) {
431-
dispatchRunDetailsSupported = true
432-
} else {
433-
minSupportedVersion, err := version.NewVersion(enterpriseWorkflowDispatchRunDetailsSupport)
434-
if err != nil {
435-
return ActionsFeatures{}, err
436-
}
429+
return ActionsFeatures{
430+
DispatchRunDetails: true,
431+
}, nil
432+
}
437433

438-
hostVersion, err := resolveEnterpriseVersion(d.httpClient, d.host)
439-
if err != nil {
440-
return ActionsFeatures{}, err
441-
}
434+
minSupportedVersion, err := version.NewVersion(enterpriseWorkflowDispatchRunDetailsSupport)
435+
if err != nil {
436+
return ActionsFeatures{}, err
437+
}
442438

443-
if hostVersion.GreaterThanOrEqual(minSupportedVersion) {
444-
dispatchRunDetailsSupported = true
445-
}
439+
hostVersion, err := resolveEnterpriseVersion(d.httpClient, d.host)
440+
if err != nil {
441+
return ActionsFeatures{}, err
442+
}
443+
444+
if hostVersion.GreaterThanOrEqual(minSupportedVersion) {
445+
return ActionsFeatures{
446+
DispatchRunDetails: true,
447+
}, nil
446448
}
447449

448450
return ActionsFeatures{
449-
DispatchRunDetails: dispatchRunDetailsSupported,
451+
DispatchRunDetails: false,
450452
}, nil
451453
}
452454

0 commit comments

Comments
 (0)