Skip to content

Commit

Permalink
refactor: use optional chaining (#17510)
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed Aug 30, 2022
1 parent 781b8fb commit 1ca1a21
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/config/migrations/custom/schedule-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ScheduleMigration extends AbstractMigration {
schedules[i].replace(regEx(/( \d?\d)((a|p)m)/g), '$1:00$2') // TODO #12071
).schedules[0];
// Only migrate if the after time is greater than before, e.g. "after 10pm and before 5am"
if (!parsedSchedule || !parsedSchedule.t_a || !parsedSchedule.t_b) {
if (!parsedSchedule?.t_a || !parsedSchedule.t_b) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/galaxy-collection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class GalaxyCollectionDatasource extends Datasource {
this.handleGenericErrors(err);
}

if (!baseUrlResponse || !baseUrlResponse.body) {
if (!baseUrlResponse?.body) {
logger.warn(
{ dependency: packageName },
`Received invalid data from ${baseUrl}`
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/helm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class HelmDatasource extends Datasource {
res = await this.http.get('index.yaml', {
baseUrl: ensureTrailingSlash(helmRepository),
});
if (!res || !res.body) {
if (!res?.body) {
logger.warn(
{ helmRepository },
`Received invalid response from helm repository`
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/versioning/maven/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ function parseRange(rangeStr: string): Range[] | null {
if (interval.leftType) {
return null;
} // something like '[1,2],[3'
if (!ranges || !ranges.length) {
if (!ranges?.length) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ export default async function executePostUpgradeCommands(

const updateUpgradeCommands: BranchUpgradeConfig[] = config.upgrades.filter(
({ postUpgradeTasks }) =>
!postUpgradeTasks ||
!postUpgradeTasks.executionMode ||
!postUpgradeTasks?.executionMode ||
postUpgradeTasks.executionMode === 'update'
);

Expand Down

0 comments on commit 1ca1a21

Please sign in to comment.