refactor: change if in else to else if (#21353)

This commit is contained in:
Noritaka Kobayashi
2025-06-13 15:11:33 +09:00
committed by GitHub
parent 88e3a3cbe2
commit 0d59bf81cf
4 changed files with 35 additions and 44 deletions

View File

@@ -84,20 +84,18 @@ export class DriverConfig extends ExtensionConfig {
err: 'Missing or incorrect supported platformNames list.',
val: platformNames,
});
} else if (_.isEmpty(platformNames)) {
problems.push({
err: 'Empty platformNames list.',
val: platformNames,
});
} else {
if (_.isEmpty(platformNames)) {
problems.push({
err: 'Empty platformNames list.',
val: platformNames,
});
} else {
for (const pName of platformNames) {
if (!_.isString(pName)) {
problems.push({
err: 'Incorrectly formatted platformName.',
val: pName,
});
}
for (const pName of platformNames) {
if (!_.isString(pName)) {
problems.push({
err: 'Incorrectly formatted platformName.',
val: pName,
});
}
}
}

View File

@@ -240,20 +240,17 @@ export class ExtensionConfig {
for (const summary of errorSummaries) {
log.error(summary);
}
} else {
} else if (!_.isEmpty(warningSummaries)) {
// only display warnings if there are no errors!
if (!_.isEmpty(warningSummaries)) {
log.warn(
`Appium encountered ${util.pluralize(
'warning',
warningMap.size,
true
)} while validating ${this.extensionType}s found in manifest ${this.manifestPath}`
);
for (const summary of warningSummaries) {
log.warn(summary);
}
log.warn(
`Appium encountered ${util.pluralize(
'warning',
warningMap.size,
true
)} while validating ${this.extensionType}s found in manifest ${this.manifestPath}`
);
for (const summary of warningSummaries) {
log.warn(summary);
}
}
return exts;

View File

@@ -390,19 +390,17 @@ export class Manifest {
if (err.code === 'ENOENT') {
data = _.cloneDeep(INITIAL_MANIFEST_DATA);
shouldWrite = true;
} else if (this.#manifestPath) {
throw new Error(
`Appium had trouble loading the extension installation ` +
`cache file (${this.#manifestPath}). It may be invalid YAML. Specific error: ${
err.message
}`
);
} else {
if (this.#manifestPath) {
throw new Error(
`Appium had trouble loading the extension installation ` +
`cache file (${this.#manifestPath}). It may be invalid YAML. Specific error: ${
err.message
}`
);
} else {
throw new Error(
`Appium encountered an unknown problem. Specific error: ${err.message}`
);
}
throw new Error(
`Appium encountered an unknown problem. Specific error: ${err.message}`
);
}
}

View File

@@ -296,12 +296,10 @@ async function getImagesMatches(img1Data, img2Data, options = {}) {
matches = matches.filter((match) =>
goodMatchesFactor(match.distance, minDistance, maxDistance)
);
} else {
if (matches.length > goodMatchesFactor) {
matches = matches
.sort((match1, match2) => match1.distance - match2.distance)
.slice(0, goodMatchesFactor);
}
} else if (matches.length > goodMatchesFactor) {
matches = matches
.sort((match1, match2) => match1.distance - match2.distance)
.slice(0, goodMatchesFactor);
}
}