Skip to content

Commit c45d089

Browse files
committed
refactor: - Follow SonarLint recommendation to use optional chaining
1 parent 44c6d29 commit c45d089

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Urgency.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class Urgency {
1111
public static calculate(task: Task): number {
1212
let urgency = 0.0;
1313

14-
if (task.dueDate !== null && task.dueDate.isValid()) {
14+
if (task.dueDate?.isValid()) {
1515
// Map a range of 21 days to the value 0.2 - 1.0
1616
const startOfToday = window.moment().startOf('day');
1717
const daysOverdue = Math.round(startOfToday.diff(task.dueDate) / Urgency.milliSecondsPerDay);
@@ -29,13 +29,13 @@ export class Urgency {
2929
urgency += dueMultiplier * Urgency.dueCoefficient;
3030
}
3131

32-
if (task.scheduledDate !== null && task.scheduledDate.isValid()) {
32+
if (task.scheduledDate?.isValid()) {
3333
if (window.moment().isSameOrAfter(task.scheduledDate)) {
3434
urgency += 1 * Urgency.scheduledCoefficient;
3535
}
3636
}
3737

38-
if (task.startDate !== null && task.startDate.isValid()) {
38+
if (task.startDate?.isValid()) {
3939
if (window.moment().isBefore(task.startDate)) {
4040
urgency += 1 * Urgency.startedCoefficient;
4141
}

0 commit comments

Comments
 (0)