Skip to content

Commit 86344e4

Browse files
committed
chore: reduce cyclomatic complexity of pool implementation
1 parent e031d9e commit 86344e4

File tree

1 file changed

+2
-5
lines changed
  • lambdas/functions/control-plane/src/pool

1 file changed

+2
-5
lines changed

lambdas/functions/control-plane/src/pool/pool.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ interface RunnerStatus {
2727
function canRunJob(workflowJobLabels: string[], runnerLabels: string[]): boolean {
2828
runnerLabels = runnerLabels.map((label) => label.toLowerCase());
2929
const matchLabels = workflowJobLabels.every((wl) => runnerLabels.includes(wl.toLowerCase()));
30-
const match = workflowJobLabels.length === 0 ? !matchLabels : matchLabels;
31-
return match;
30+
return workflowJobLabels.length !== 0 && matchLabels;
3231
}
3332

3433
export async function adjust(event: PoolEvent): Promise<void> {
@@ -52,9 +51,7 @@ export async function adjust(event: PoolEvent): Promise<void> {
5251
const runnerOwners = process.env.RUNNER_OWNERS.split(',');
5352
const amiIdSsmParameterName = process.env.AMI_ID_SSM_PARAMETER_NAME;
5453
const tracingEnabled = yn(process.env.POWERTOOLS_TRACE_ENABLED, { default: false });
55-
const onDemandFailoverOnError = process.env.ENABLE_ON_DEMAND_FAILOVER_FOR_ERRORS
56-
? (JSON.parse(process.env.ENABLE_ON_DEMAND_FAILOVER_FOR_ERRORS) as [string])
57-
: [];
54+
const onDemandFailoverOnError: string[] = JSON.parse(process.env.ENABLE_ON_DEMAND_FAILOVER_FOR_ERRORS ?? '[]');
5855

5956
const { ghesApiUrl, ghesBaseUrl } = getGitHubEnterpriseApiUrl();
6057

0 commit comments

Comments
 (0)