Bug 1280898 - Set up eslint for calendar files - enable no-lonely-if rule. r=MakeMyDay
authoreslint <eslint@bugzilla.kewis.ch>
Fri, 08 Jul 2016 14:05:54 +0200
changeset 25994 ff506e40c3a28846acd5313c8c93fe45bf30db8f
parent 25993 3d474ac6379c7c7278e3d41fb40437d95b9f7470
child 25995 2f2abb3fd4c9a47993c5861ed22d6d9f924c5480
push id1771
push userclokep@gmail.com
push dateMon, 14 Nov 2016 17:47:53 +0000
treeherdercomm-beta@399ae9d71595 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMakeMyDay
bugs1280898
Bug 1280898 - Set up eslint for calendar files - enable no-lonely-if rule. r=MakeMyDay MozReview-Commit-ID: 5CSRa1woomx
calendar/.eslintrc
calendar/base/content/agenda-listbox.xml
calendar/base/content/calendar-month-view.xml
calendar/base/content/calendar-multiday-view.xml
calendar/base/content/calendar-unifinder.js
calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
calendar/base/content/dialogs/calendar-event-dialog-recurrence.js
calendar/base/content/today-pane.js
calendar/base/content/widgets/calendar-list-tree.xml
calendar/base/content/widgets/calendar-widgets.xml
calendar/base/content/widgets/minimonth.xml
calendar/base/modules/calRecurrenceUtils.jsm
calendar/base/src/calCachedCalendar.js
calendar/base/src/calCalendarManager.js
calendar/base/src/calEvent.js
calendar/base/src/calTimezoneService.js
calendar/base/src/calUtils.js
calendar/import-export/calOutlookCSVImportExport.js
calendar/lightning/content/lightning-item-iframe.js
calendar/providers/caldav/calDavCalendar.js
calendar/providers/memory/calMemoryCalendar.js
calendar/providers/storage/calStorageUpgrade.jsm
calendar/resources/content/datetimepickers/datetimepickers.xml
calendar/test/unit/test_alarm.js
--- a/calendar/.eslintrc
+++ b/calendar/.eslintrc
@@ -358,18 +358,20 @@
 
     // Restricts the use of parentheses to only where they are necessary
     // Disabled for now since this also removes parens around assignments, e.g. let foo = bar == baz
     // "no-extra-parens": [2, "all", { "conditionalAssign": false, "returnAssign": false, "nestedBinaryExpressions": false }],
 
     // Double quotes should be used.
     "quotes": [2, "double", { "avoidEscape": true }],
 
+    // Disallow if as the only statement in an else block.
+    "no-lonely-if": 2,
+
     // Will enable these rules later
     "block-spacing": 0,
-    "no-lonely-if": 0,
     "computed-property-spacing": 0,
 
     // The following rules will not be enabled currently, but are kept here for
     // easier updates in the future.
     "no-else-return": 0,
   }
 }
--- a/calendar/base/content/agenda-listbox.xml
+++ b/calendar/base/content/agenda-listbox.xml
@@ -65,22 +65,20 @@
                 this.kCheckbox.label = this.getAttribute("title");
                 if (this.id == "nextweek-header") {
                     if (duration > 7) {
                         this.kCheckbox.label += " (" + unitPluralForm(duration / 7, "weeks") + ")";
                     } else {
                         this.kCheckbox.label += " (" + unitPluralForm(duration, "days") + ")";
                     }
                 }
+            } else if (synthetic.duration == 1) {
+                this.kCheckbox.label = getDateFormatter().formatDate(synthetic.start);
             } else {
-                if (synthetic.duration == 1) {
-                    this.kCheckbox.label = getDateFormatter().formatDate(synthetic.start);
-                } else {
-                    this.kCheckbox.label = getDateFormatter().formatInterval(synthetic.start, synthetic.end);
-                }
+                this.kCheckbox.label = getDateFormatter().formatInterval(synthetic.start, synthetic.end);
             }
         ]]></body>
       </method>
       <method name="getCheckbox">
         <body><![CDATA[
             return this.kCheckbox;
         ]]></body>
       </method>
@@ -224,37 +222,36 @@
             let longFormat = aPeriod.multiday || aPeriod.duration > 1;
 
             let duration = "";
             let iconType = "";
             if (startDate.compare(endDate) == 0) {
                 // event that starts and ends in the same day, midnight included
                 duration = longFormat ? dateFormatter.formatDateTime(start)
                                       : dateFormatter.formatTime(start);
+            } else if (startDate.compare(periodStartDate) >= 0 &&
+                       startDate.compare(periodEndDate) <= 0) {
+                // event spanning multiple days, start date within period
+                iconType = "start";
+                duration = longFormat ? dateFormatter.formatDateTime(start)
+                                      : dateFormatter.formatTime(start);
+            } else if (endDate.compare(periodStartDate) >= 0 &&
+                       endDate.compare(periodEndDate) <= 0) {
+                // event spanning multiple days, end date within period
+                iconType = "end";
+                if (endAtMidnight) {
+                    duration = dateFormatter.formatDate(endDate) + " ";
+                    duration = longFormat ? duration + calGetString("dateFormat", "midnight")
+                                          : calGetString("dateFormat", "midnight");
+                } else {
+                    duration = longFormat ? dateFormatter.formatDateTime(end)
+                                          : dateFormatter.formatTime(end);
+                }
             } else {
-                // event spanning multiple days
-                if (startDate.compare(periodStartDate) >= 0 &&
-                     startDate.compare(periodEndDate) <= 0) {
-                    iconType = "start";
-                    duration = longFormat ? dateFormatter.formatDateTime(start)
-                                          : dateFormatter.formatTime(start);
-                } else if (endDate.compare(periodStartDate) >= 0 &&
-                           endDate.compare(periodEndDate) <= 0) {
-                    iconType = "end";
-                    if (endAtMidnight) {
-                        duration = dateFormatter.formatDate(endDate) + " ";
-                        duration = longFormat ? duration + calGetString("dateFormat", "midnight")
-                                              : calGetString("dateFormat", "midnight");
-                    } else {
-                        duration = longFormat ? dateFormatter.formatDateTime(end)
-                                              : dateFormatter.formatTime(end);
-                    }
-                } else {
-                    iconType = "continue";
-                }
+                iconType = "continue";
             }
             let multiDayImage = document.getAnonymousElementByAttribute(this, "anonid", "agenda-multiDayEvent-image");
             multiDayImage.setAttribute("type", iconType);
             let durationbox = document.getAnonymousElementByAttribute(this, "anonid", "agenda-event-start");
             durationbox.textContent = duration;
 
             // show items with time only (today & tomorrow) as one line.
             if (longFormat) {
--- a/calendar/base/content/calendar-month-view.xml
+++ b/calendar/base/content/calendar-month-view.xml
@@ -95,22 +95,20 @@
               if (startTime.compare(parentDate) == -1) {
                 if (comp == 1) {
                   label.value = "↔";
                 } else if (comp == 0) {
                   label.value = "↤";
                 } else {
                   label.value = "⇥ " + df.formatTime(endTime);
                 }
+              } else if (comp == 1) {
+                label.value = "⇤ " + df.formatTime(startTime);
               } else {
-                if (comp == 1) {
-                  label.value = "⇤ " + df.formatTime(startTime);
-                } else {
-                  label.value = df.formatTime(startTime);
-                }
+                label.value = df.formatTime(startTime);
               }
               label.setAttribute("time", "true");
             }
           }
 
           this.setEditableLabel();
           this.setCSSClasses();
           return val;
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -1634,24 +1634,20 @@
           window.removeEventListener("keypress", col.onEventSweepKeypress, false);
 
           document.calendarEventColumnDragging = null;
 
           // if the user didn't sweep out at least a few pixels, ignore
           // unless we're in a different column
           if (dragState.origColumn == col) {
               let ignore = false;
-              if (col.getAttribute("orient") == "vertical") {
-                  if (Math.abs(event.screenY - dragState.origLoc) < 3) {
-                      ignore = true;
-                  }
-              } else {
-                  if (Math.abs(event.screenX - dragState.origLoc) < 3) {
-                      ignore = true;
-                  }
+              let orient = col.getAttribute("orient");
+              let position = orient == "vertical" ? event.screenY : event.screenX;
+              if (Math.abs(position - dragState.origLoc) < 3) {
+                  ignore = true;
               }
 
               if (ignore) {
                   col.mDragState = null;
                   return;
               }
           }
 
--- a/calendar/base/content/calendar-unifinder.js
+++ b/calendar/base/content/calendar-unifinder.js
@@ -797,22 +797,20 @@ var unifinderTreeView = {
         this.tree = tree;
     },
 
     toggleOpenState: function uTV_toggleOpenState(aRow) {},
 
     cycleHeader: function uTV_cycleHeader(col) {
         if (!this.selectedColumn) {
             this.sortDirection = "ascending";
+        } else if (!this.sortDirection || this.sortDirection == "descending") {
+            this.sortDirection = "ascending";
         } else {
-            if (!this.sortDirection || this.sortDirection == "descending") {
-                this.sortDirection = "ascending";
-            } else {
-                this.sortDirection = "descending";
-            }
+            this.sortDirection = "descending";
         }
         this.selectedColumn = col.element;
         this.sortItems();
     },
 
     isEditable: function uTV_isEditable(aRow, aCol) {
         return false;
     },
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
@@ -893,20 +893,18 @@
               // do we need to scroll in order to see the selected row?
               let listbox =
                   document.getAnonymousElementByAttribute(
                       self, "anonid", "listbox");
               let firstVisibleRow = listbox.getIndexOfFirstVisibleRow();
               let numOfVisibleRows = listbox.getNumberOfVisibleRows();
               if (aRow <= firstVisibleRow) {
                   listbox.scrollToIndex(aRow - 1);
-              } else {
-                  if (aRow - 1 >= (firstVisibleRow + numOfVisibleRows)) {
-                      listbox.scrollToIndex(aRow - numOfVisibleRows);
-                  }
+              } else if (aRow - 1 >= (firstVisibleRow + numOfVisibleRows)) {
+                  listbox.scrollToIndex(aRow - numOfVisibleRows);
               }
               let input =
                   document.getAnonymousElementByAttribute(
                       node, "anonid", "input");
               input.focus();
           };
           setTimeout(set_focus, 0);
         ]]></body>
--- a/calendar/base/content/dialogs/calendar-event-dialog-recurrence.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-recurrence.js
@@ -156,37 +156,35 @@ function initializeControls(rule) {
     let ruleComponentsEmpty = (byDayRuleComponent.length == 0 &&
                                byMonthDayRuleComponent.length == 0);
     if (ruleComponentsEmpty || rule.type != "MONTHLY") {
         document.getElementById("monthly-group").selectedIndex = 1;
         document.getElementById("monthly-days").days = [startDate.day];
         let day = Math.floor((startDate.day - 1) / 7) + 1;
         setElementValue("monthly-ordinal", day);
         setElementValue("monthly-weekday", startDate.weekday + 1);
-    } else {
-        if (everyWeekDay(byDayRuleComponent)) {
-            // Every day of the month.
-            document.getElementById("monthly-group").selectedIndex = 0;
-            setElementValue("monthly-ordinal", 0);
-            setElementValue("monthly-weekday", -1);
-        } else if (byDayRuleComponent.length > 0) {
-            // One of the first five days or weekdays of the month.
-            document.getElementById("monthly-group").selectedIndex = 0;
-            let ruleInfo = getOrdinalAndWeekdayOfRule(byDayRuleComponent[0]);
-            setElementValue("monthly-ordinal", ruleInfo.ordinal);
-            setElementValue("monthly-weekday", ruleInfo.weekday);
-        } else if (byMonthDayRuleComponent.length == 1 && byMonthDayRuleComponent[0] == -1) {
-            // The last day of the month.
-            document.getElementById("monthly-group").selectedIndex = 0;
-            setElementValue("monthly-ordinal", byMonthDayRuleComponent[0]);
-            setElementValue("monthly-weekday", byMonthDayRuleComponent[0]);
-        } else if (byMonthDayRuleComponent.length > 0) {
-            document.getElementById("monthly-group").selectedIndex = 1;
-            document.getElementById("monthly-days").days = byMonthDayRuleComponent;
-        }
+    } else if (everyWeekDay(byDayRuleComponent)) {
+        // Every day of the month.
+        document.getElementById("monthly-group").selectedIndex = 0;
+        setElementValue("monthly-ordinal", 0);
+        setElementValue("monthly-weekday", -1);
+    } else if (byDayRuleComponent.length > 0) {
+        // One of the first five days or weekdays of the month.
+        document.getElementById("monthly-group").selectedIndex = 0;
+        let ruleInfo = getOrdinalAndWeekdayOfRule(byDayRuleComponent[0]);
+        setElementValue("monthly-ordinal", ruleInfo.ordinal);
+        setElementValue("monthly-weekday", ruleInfo.weekday);
+    } else if (byMonthDayRuleComponent.length == 1 && byMonthDayRuleComponent[0] == -1) {
+        // The last day of the month.
+        document.getElementById("monthly-group").selectedIndex = 0;
+        setElementValue("monthly-ordinal", byMonthDayRuleComponent[0]);
+        setElementValue("monthly-weekday", byMonthDayRuleComponent[0]);
+    } else if (byMonthDayRuleComponent.length > 0) {
+        document.getElementById("monthly-group").selectedIndex = 1;
+        document.getElementById("monthly-days").days = byMonthDayRuleComponent;
     }
 
     // "YEARLY" ruletype
     if (byMonthRuleComponent.length == 0 || rule.type != "YEARLY") {
         setElementValue("yearly-month-rule", startDate.month + 1);
         setElementValue("yearly-month-ordinal", startDate.month + 1);
         if (byMonthDayRuleComponent.length > 0) {
             setControlsForByMonthDay_YearlyRule(startDate, byMonthDayRuleComponent[0]);
--- a/calendar/base/content/today-pane.js
+++ b/calendar/base/content/today-pane.js
@@ -175,31 +175,29 @@ var TodayPane = {
         if (TodayPane.minidayDrag.session) {
             if (x * x + y * y >= MIN_DRAG_DISTANCE_SQ) {
                 let distance = Math.floor(Math.sqrt(x * x + y * y) - Math.sqrt(MIN_DRAG_DISTANCE_SQ));
                 // Dragging on the left/right side, the day date decrease/increase
                 TodayPane.minidayDrag.distance = (x > 0) ? distance : -distance;
             } else {
                 TodayPane.minidayDrag.distance = 0;
             }
-        } else {
+        } else if (x * x + y * y > 9) {
             // move the mouse a bit before starting the drag session
-            if (x * x + y * y > 9) {
-                window.addEventListener("mouseout", TodayPane.stopSwitching, false);
-                TodayPane.minidayDrag.session = true;
-                let dragCenterImage = document.getElementById("dragCenter-image");
-                dragCenterImage.removeAttribute("hidden");
-                // Move the starting point in the center so we have a fixed
-                // point where stopping the day switching while still dragging
-                let centerObj = dragCenterImage.boxObject;
-                TodayPane.minidayDrag.startX = Math.floor(centerObj.x + centerObj.width / 2);
-                TodayPane.minidayDrag.startY = Math.floor(centerObj.y + centerObj.height / 2);
+            window.addEventListener("mouseout", TodayPane.stopSwitching, false);
+            TodayPane.minidayDrag.session = true;
+            let dragCenterImage = document.getElementById("dragCenter-image");
+            dragCenterImage.removeAttribute("hidden");
+            // Move the starting point in the center so we have a fixed
+            // point where stopping the day switching while still dragging
+            let centerObj = dragCenterImage.boxObject;
+            TodayPane.minidayDrag.startX = Math.floor(centerObj.x + centerObj.width / 2);
+            TodayPane.minidayDrag.startY = Math.floor(centerObj.y + centerObj.height / 2);
 
-                TodayPane.updateAdvanceTimer();
-            }
+            TodayPane.updateAdvanceTimer();
         }
     },
 
     /**
      * Figure out the days switching speed according to the position (when
      * dragging) or time elapsed (when pressing buttons).
      */
     updateAdvanceTimer: function md_updateAdvanceTimer(aEvent, aDir) {
--- a/calendar/base/content/widgets/calendar-list-tree.xml
+++ b/calendar/base/content/widgets/calendar-list-tree.xml
@@ -599,21 +599,19 @@
               // If we have a client point, get the row directly from the client
               // point.
               aRow = aRow || {};
               this.treebox.getCellAt(event.clientX,
                                      event.clientY,
                                      aRow,
                                      aCol || {},
                                      {});
-          } else {
+          } else if (document.popupNode && document.popupNode.contextCalendar) {
               // Otherwise, we can try to get the context calendar from the popupNode.
-              if (document.popupNode && document.popupNode.contextCalendar) {
-                  return document.popupNode.contextCalendar;
-              }
+              return document.popupNode.contextCalendar;
           }
           return aRow && aRow.value > -1 && this.mCalendarList[aRow.value];
         ]]></body>
       </method>
 
       <method name="getCalendar">
         <!--
           - Get the calendar from a certain index.
--- a/calendar/base/content/widgets/calendar-widgets.xml
+++ b/calendar/base/content/widgets/calendar-widgets.xml
@@ -402,22 +402,20 @@
             if (pushModeCollapsedAttribute) {
                 if (!display) {
                     if (modeIndex == -1) {
                         collapsedModes.push(this.currentMode);
                         if (this.getAttribute("collapsedinmodes") == ",") {
                             collapsedModes.splice(0, 2);
                         }
                     }
-                } else {
-                    if (modeIndex > -1) {
-                        collapsedModes.splice(modeIndex, 1);
-                        if (collapsedModes.join(",") == "") {
-                            collapsedModes[0] = ",";
-                        }
+                } else if (modeIndex > -1) {
+                    collapsedModes.splice(modeIndex, 1);
+                    if (collapsedModes.join(",") == "") {
+                        collapsedModes[0] = ",";
                     }
                 }
                 this.setAttribute("collapsedinmodes", collapsedModes.join(","));
                 let id = this.getAttribute("id");
                 if (id) {
                     document.persist(id, "collapsedinmodes");
                 }
             }
--- a/calendar/base/content/widgets/minimonth.xml
+++ b/calendar/base/content/widgets/minimonth.xml
@@ -968,21 +968,19 @@
         <parameter name="aFreeBusy"/>
         <body><![CDATA[
             if (aFreeBusy == true) {
                 if (this.mObservesComposite == false) {
                     getCompositeCalendar().addObserver(this);
                     this.mObservesComposite = true;
                     this.getItems();
                  }
-            } else {
-                if (this.mObservesComposite == true) {
-                    getCompositeCalendar().removeObserver(this);
-                    this.mObservesComposite = false;
-                 }
+            } else if (this.mObservesComposite == true) {
+                getCompositeCalendar().removeObserver(this);
+                this.mObservesComposite = false;
             }
         ]]></body>
       </method>
       <method name="removeAttribute">
         <parameter name="aAttr"/>
         <body><![CDATA[
           if (aAttr == "freebusy") {
               this._setFreeBusy(false);
--- a/calendar/base/modules/calRecurrenceUtils.jsm
+++ b/calendar/base/modules/calRecurrenceUtils.jsm
@@ -183,50 +183,48 @@ function recurrenceRule2String(recurrenc
                     // First, find out if the 'BYMONTHDAY' component contains
                     // any elements with a negative value lesser than -1 ("the
                     // last day"). If so we currently don't support any rule
                     if (component.some(function(element, index, array) {
                                            return element < -1;
                                        })) {
                         // we don't support any other combination for now...
                         return getRString("ruleTooComplex");
+                    } else if (component.length == 1 && component[0] == -1) {
+                        // i.e. one day, the last day of the month
+                        let monthlyString = getRString("monthlyLastDayOfNth");
+                        ruleString = PluralForm.get(rule.interval, monthlyString)
+                                               .replace("#1", rule.interval);
                     } else {
-                        if (component.length == 1 && component[0] == -1) {
-                            // i.e. one day, the last day of the month
-                            let monthlyString = getRString("monthlyLastDayOfNth");
-                            ruleString = PluralForm.get(rule.interval, monthlyString)
-                                                   .replace("#1", rule.interval);
-                        } else {
-                            // i.e. one or more monthdays every N months.
+                        // i.e. one or more monthdays every N months.
 
-                            // Build a string with a list of days separated with commas.
-                            let day_string = "";
-                            let lastDay = false;
-                            for (let i = 0; i < component.length; i++) {
-                                if (component[i] == -1) {
-                                    lastDay = true;
-                                    continue;
-                                }
-                                day_string += dateFormatter.formatDayWithOrdinal(component[i]) + ", ";
-                            }
-                            if (lastDay) {
-                                day_string += getRString("monthlyLastDay") + ", ";
+                        // Build a string with a list of days separated with commas.
+                        let day_string = "";
+                        let lastDay = false;
+                        for (let i = 0; i < component.length; i++) {
+                            if (component[i] == -1) {
+                                lastDay = true;
+                                continue;
                             }
-                            day_string = day_string.slice(0, -2)
-                                                   .replace(/,(?= [^,]*$)/,
-                                                            " " + getRString("repeatDetailsAnd"));
+                            day_string += dateFormatter.formatDayWithOrdinal(component[i]) + ", ";
+                        }
+                        if (lastDay) {
+                            day_string += getRString("monthlyLastDay") + ", ";
+                        }
+                        day_string = day_string.slice(0, -2)
+                                               .replace(/,(?= [^,]*$)/,
+                                                        " " + getRString("repeatDetailsAnd"));
 
-                            // Add the word "day" in plural form to the list of days then
-                            // compose the final string with the interval of months
-                            let monthlyDayString = getRString("monthlyDaysOfNth_day", [day_string]);
-                            monthlyDayString = PluralForm.get(component.length, monthlyDayString);
-                            let monthlyString = getRString("monthlyDaysOfNth", [monthlyDayString]);
-                            ruleString = PluralForm.get(rule.interval, monthlyString)
-                                                   .replace("#2", rule.interval);
-                        }
+                        // Add the word "day" in plural form to the list of days then
+                        // compose the final string with the interval of months
+                        let monthlyDayString = getRString("monthlyDaysOfNth_day", [day_string]);
+                        monthlyDayString = PluralForm.get(component.length, monthlyDayString);
+                        let monthlyString = getRString("monthlyDaysOfNth", [monthlyDayString]);
+                        ruleString = PluralForm.get(rule.interval, monthlyString)
+                                               .replace("#2", rule.interval);
                     }
                 } else {
                     let monthlyString = getRString("monthlyDaysOfNth", [startDate.day]);
                     ruleString = PluralForm.get(rule.interval, monthlyString)
                                            .replace("#2", rule.interval);
                 }
             } else if (rule.type == "YEARLY") {
                 let bymonthday = null;
@@ -330,42 +328,40 @@ function recurrenceRule2String(recurrenc
                              dateFormatter.formatDateShort(startDate),
                              dateFormatter.formatDateShort(untilDate)]);
                     }
                 } else {
                     detailsString = getRString("repeatDetailsInfiniteAllDay",
                                                [ruleString,
                                                 dateFormatter.formatDateShort(startDate)]);
                 }
-            } else {
-                if (rule.isFinite) {
-                    if (rule.isByCount) {
-                        let countString = getRString("repeatCount",
-                            [ruleString,
-                             dateFormatter.formatDateShort(startDate),
-                             dateFormatter.formatTime(startDate),
-                             dateFormatter.formatTime(endDate)]);
-                        detailsString = PluralForm.get(rule.count, countString)
-                                                  .replace("#5", rule.count);
-                    } else {
-                        let untilDate = rule.untilDate.getInTimezone(kDefaultTimezone);
-                        detailsString = getRString("repeatDetailsUntil",
-                            [ruleString,
-                             dateFormatter.formatDateShort(startDate),
-                             dateFormatter.formatDateShort(untilDate),
-                             dateFormatter.formatTime(startDate),
-                             dateFormatter.formatTime(endDate)]);
-                    }
-                } else {
-                    detailsString = getRString("repeatDetailsInfinite",
+            } else if (rule.isFinite) {
+                if (rule.isByCount) {
+                    let countString = getRString("repeatCount",
                         [ruleString,
                          dateFormatter.formatDateShort(startDate),
                          dateFormatter.formatTime(startDate),
                          dateFormatter.formatTime(endDate)]);
+                    detailsString = PluralForm.get(rule.count, countString)
+                                              .replace("#5", rule.count);
+                } else {
+                    let untilDate = rule.untilDate.getInTimezone(kDefaultTimezone);
+                    detailsString = getRString("repeatDetailsUntil",
+                        [ruleString,
+                         dateFormatter.formatDateShort(startDate),
+                         dateFormatter.formatDateShort(untilDate),
+                         dateFormatter.formatTime(startDate),
+                         dateFormatter.formatTime(endDate)]);
                 }
+            } else {
+                detailsString = getRString("repeatDetailsInfinite",
+                    [ruleString,
+                     dateFormatter.formatDateShort(startDate),
+                     dateFormatter.formatTime(startDate),
+                     dateFormatter.formatTime(endDate)]);
             }
             return detailsString;
         }
     }
     return null;
 }
 
 /**
--- a/calendar/base/src/calCachedCalendar.js
+++ b/calendar/base/src/calCachedCalendar.js
@@ -617,23 +617,21 @@ calCachedCalendar.prototype = {
                 break;
         }
 
         return this.mUncachedCalendar.getProperty(aName);
     },
     refresh: function() {
         if (this.offline) {
             this.downstreamRefresh();
-        } else {
+        } else if (this.supportsChangeLog) {
             /* we first ensure that any remaining offline items are reconciled with the calendar server */
-            if (this.supportsChangeLog) {
-                this.playbackOfflineItems(this.downstreamRefresh.bind(this));
-            } else {
-                this.downstreamRefresh();
-            }
+            this.playbackOfflineItems(this.downstreamRefresh.bind(this));
+        } else {
+            this.downstreamRefresh();
         }
     },
     downstreamRefresh: function() {
         if (this.mUncachedCalendar.canRefresh && !this.offline) {
             return this.mUncachedCalendar.refresh(); // will trigger synchronize once the calendar is loaded
         } else {
             let this_ = this;
             return this.synchronize(
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -886,22 +886,20 @@ calMgrCalendarObserver.prototype = {
                                  aCalendar.getProperty(prop));
             }
 
             if (initialSortOrderPos != null) {
                 newCal.setProperty("initialSortOrderPos",
                                    initialSortOrderPos);
             }
             this.calMgr.registerCalendar(newCal);
-        } else {
-            if (aCalendar.wrappedJSObject instanceof calCachedCalendar) {
-                // any attempt to switch this flag will reset the cached calendar;
-                // could be useful for users in case the cache may be corrupted.
-                aCalendar.wrappedJSObject.setupCachedCalendar();
-            }
+        } else if (aCalendar.wrappedJSObject instanceof calCachedCalendar) {
+            // any attempt to switch this flag will reset the cached calendar;
+            // could be useful for users in case the cache may be corrupted.
+            aCalendar.wrappedJSObject.setupCachedCalendar();
         }
     },
 
     onPropertyDeleting: function(aCalendar, aName) {
         this.onPropertyChanged(aCalendar, aName, false, true);
     },
 
     // Error announcer specific functions
--- a/calendar/base/src/calEvent.js
+++ b/calendar/base/src/calEvent.js
@@ -183,23 +183,21 @@ calEvent.prototype = {
         if (endDate === undefined) {
             endDate = this.getProperty("DTEND");
             if (!endDate && this.startDate) {
                 endDate = this.startDate.clone();
                 let dur = this.getProperty("DURATION");
                 if (dur) {
                     // If there is a duration set on the event, calculate the right end time.
                     endDate.addDuration(cal.createDuration(dur));
-                } else {
+                } else if (endDate.isDate) {
                     // If the start time is a date-time the event ends on the same calendar
                     // date and time of day. If the start time is a date the events
                     // non-inclusive end is the end of the calendar date.
-                    if (endDate.isDate) {
-                        endDate.day += 1;
-                    }
+                    endDate.day += 1;
                 }
             }
             this.mEndDate = endDate;
         }
         return endDate;
     },
 
     set endDate(value) {
--- a/calendar/base/src/calTimezoneService.js
+++ b/calendar/base/src/calTimezoneService.js
@@ -198,30 +198,28 @@ calTimezoneService.prototype = {
         if (!tz) {
             cal.ERROR("Couldn't find " + tzid);
             return null;
         }
         if (!tz.zone) {
             if (tz.aliasTo) {
                 // This zone is an alias.
                 tz.zone = this.getTimezone(tz.aliasTo);
+            } else if (Preferences.get("calendar.icaljs", false)) {
+                let parsedComp = ICAL.parse("BEGIN:VCALENDAR\r\n" + tz.ics + "\r\nEND:VCALENDAR");
+                let icalComp = new ICAL.Component(parsedComp);
+                let tzComp = icalComp.getFirstSubcomponent("vtimezone");
+                tz.zone = new calICALJSTimezone(ICAL.Timezone.fromData({
+                    tzid: tzid,
+                    component: tzComp,
+                    latitude: tz.latitude,
+                    longitude: tz.longitude
+                }));
             } else {
-                if (Preferences.get("calendar.icaljs", false)) {
-                    let parsedComp = ICAL.parse("BEGIN:VCALENDAR\r\n" + tz.ics + "\r\nEND:VCALENDAR");
-                    let icalComp = new ICAL.Component(parsedComp);
-                    let tzComp = icalComp.getFirstSubcomponent("vtimezone");
-                    tz.zone = new calICALJSTimezone(ICAL.Timezone.fromData({
-                        tzid: tzid,
-                        component: tzComp,
-                        latitude: tz.latitude,
-                        longitude: tz.longitude
-                    }));
-                } else {
-                    tz.zone = new calLibicalTimezone(tzid, tz.ics, tz.latitude, tz.longitude);
-                }
+                tz.zone = new calLibicalTimezone(tzid, tz.ics, tz.latitude, tz.longitude);
             }
         }
         return tz.zone;
     },
 
     get timezoneIds() {
         let zones = [];
         for (let [k, v] of this.mZones.entries()) {
@@ -483,31 +481,29 @@ function guessSystemTimezone() {
                         continue; // period ends too early
                     }
                 } // else forever rule
             } // else no daylight rule
 
             // found period that covers today.
             if (!isForNextTransitionDate) {
                 return period;
-            } else {
-                if (todayUTC.nativeTime < periodStartCalDate.nativeTime) {
-                    // already know periodStartCalDate < oneYr from now,
-                    // and transitions are at most once per year, so it is next.
-                    return cal.dateTimeToJsDate(periodStartCalDate);
-                } else if (rrule) {
-                    // find next occurrence after today
-                    periodCalRule.icalProperty = rrule;
-                    let nextTransitionDate =
-                        periodCalRule.getNextOccurrence(periodStartCalDate,
-                                                        todayUTC);
-                    // make sure rule doesn't end before next transition date.
-                    if (nextTransitionDate) {
-                        return cal.dateTimeToJsDate(nextTransitionDate);
-                    }
+            } else if (todayUTC.nativeTime < periodStartCalDate.nativeTime) {
+                // already know periodStartCalDate < oneYr from now,
+                // and transitions are at most once per year, so it is next.
+                return cal.dateTimeToJsDate(periodStartCalDate);
+            } else if (rrule) {
+                // find next occurrence after today
+                periodCalRule.icalProperty = rrule;
+                let nextTransitionDate =
+                    periodCalRule.getNextOccurrence(periodStartCalDate,
+                                                    todayUTC);
+                // make sure rule doesn't end before next transition date.
+                if (nextTransitionDate) {
+                    return cal.dateTimeToJsDate(nextTransitionDate);
                 }
             }
         }
         // no such period found
         return null;
     }
 
     function environmentVariableValue(varName) {
--- a/calendar/base/src/calUtils.js
+++ b/calendar/base/src/calUtils.js
@@ -1129,21 +1129,19 @@ function checkIfInRange(item, rangeStart
     let end = ensureDateTime(endDate);
     let queryEnd = ensureDateTime(rangeEnd);
 
     if (start.compare(end) == 0) {
         if ((!queryStart || start.compare(queryStart) >= 0) &&
             (!queryEnd || start.compare(queryEnd) < 0)) {
             return startDate;
         }
-    } else {
-        if ((!queryEnd || start.compare(queryEnd) < 0) &&
-            (!queryStart || end.compare(queryStart) > 0)) {
-            return startDate;
-        }
+    } else if ((!queryEnd || start.compare(queryEnd) < 0) &&
+               (!queryStart || end.compare(queryStart) > 0)) {
+        return startDate;
     }
     return null;
 }
 
 /**
  * This function return the progress state of a task:
  * completed, overdue, duetoday, inprogress, future
  *
--- a/calendar/import-export/calOutlookCSVImportExport.js
+++ b/calendar/import-export/calOutlookCSVImportExport.js
@@ -268,40 +268,37 @@ calOutlookCSVImporter.prototype = {
                     // timed events last the default length.
                     eDate = sDate.clone();
                     if (sDate.isDate) {
                         // end date is exclusive, so set to next day after start.
                         eDate.day += 1;
                     } else {
                         eDate.minute += Preferences.get("calendar.event.defaultlength", 60);
                     }
+                } else if (sDate.isDate) {
+                    // A time part for the startDate is missing or was
+                    // not recognized. We have to throw away the endDates
+                    // time part too for obtaining a valid event.
+                    eDate.isDate = true;
+                    // Correct the eDate if duration is less than one day.
+                    if (eDate.subtractDate(sDate).days < 1) {
+                        eDate = sDate.clone();
+                        eDate.day += 1;
+                    }
                 } else {
-                    // An endDate was found.
-                    if (sDate.isDate) {
-                        // A time part for the startDate is missing or was
-                        // not recognized. We have to throw away the endDates
-                        // time part too for obtaining a valid event.
-                        eDate.isDate = true;
-                        // Correct the eDate if duration is less than one day.
-                        if (eDate.subtractDate(sDate).days < 1) {
-                            eDate = sDate.clone();
-                            eDate.day += 1;
-                        }
-                    } else {
-                        // We now have a timed startDate and an endDate. If the
-                        // end time is invalid set it to 23:59:00
-                        if (eDate.isDate) {
-                            eDate.isDate = false;
-                            eDate.hour = 23;
-                            eDate.minute = 59;
-                        }
-                        // Correct the duration to 0 seconds if it is negative.
-                        if (eDate.subtractDate(sDate).isNegative) {
-                            eDate = sDate.clone();
-                        }
+                    // We now have a timed startDate and an endDate. If the
+                    // end time is invalid set it to 23:59:00
+                    if (eDate.isDate) {
+                        eDate.isDate = false;
+                        eDate.hour = 23;
+                        eDate.minute = 59;
+                    }
+                    // Correct the duration to 0 seconds if it is negative.
+                    if (eDate.subtractDate(sDate).isNegative) {
+                        eDate = sDate.clone();
                     }
                 }
                 event.startDate = sDate;
                 event.endDate = eDate;
 
                 // Exists an alarm true/false column?
                 if ("alarmIndex" in args) {
                     // Is an alarm wanted for this event?
@@ -391,21 +388,19 @@ calOutlookCSVImporter.prototype = {
         }
 
         if (rt && aLocale.timeAmPmIndex &&
             rt[aLocale.timeAmPmIndex] != aLocale.timePmString) {
             // AM
             if (dt.hour == 12) {
                 dt.hour = 0;
             }
-        } else {
-            // PM
-            if (dt.hour < 12) {
-               dt.hour += 12;
-            }
+        } else if (dt.hour < 12) {
+           // PM
+           dt.hour += 12;
         }
         return dt;
     },
 
     parseTextField: function parseTextField(aTextField) {
         return aTextField ? aTextField.replace(/""/g, "\"") : "";
     }
 };
--- a/calendar/lightning/content/lightning-item-iframe.js
+++ b/calendar/lightning/content/lightning-item-iframe.js
@@ -1267,21 +1267,19 @@ function getRepeatTypeAndUntilDate(aItem
                                                 break;
                                             }
                                         }
                                         if (!found && (!rule.isFinite || !rule.isByCount)) {
                                             repeatType = "every.weekday";
                                             updateUntilDate(rule);
                                         }
                                     }
-                                } else {
-                                    if (!rule.isFinite || !rule.isByCount) {
-                                        repeatType = "daily";
-                                        updateUntilDate(rule);
-                                    }
+                                } else if (!rule.isFinite || !rule.isByCount) {
+                                    repeatType = "daily";
+                                    updateUntilDate(rule);
                                 }
                             }
                         }
                         break;
                     case "WEEKLY":
                         if (!checkRecurrenceRule(rule, ["BYSECOND",
                                                         "BYMINUTE",
                                                         "BYDAY",
@@ -2181,34 +2179,32 @@ function addAttachment(attachment, cloud
                 uploadCloudAttachment(attachment, cloudProvider, listItem);
             } else {
                 let leafName = attachment.getParameter("FILENAME");
                 listItem.setAttribute("image", cloudProvider.iconClass);
                 if (leafName) {
                     listItem.setAttribute("label", leafName);
                 }
             }
+        } else if (attachment.uri.schemeIs("file")) {
+            listItem.setAttribute("image", "moz-icon://" + attachment.uri);
         } else {
-            if (attachment.uri.schemeIs("file")) {
-                listItem.setAttribute("image", "moz-icon://" + attachment.uri);
+            let leafName = attachment.getParameter("FILENAME");
+            let providerType = attachment.getParameter("PROVIDER");
+            let cloudFileEnabled = Preferences.get("mail.cloud_files.enabled", false);
+
+            if (leafName) {
+                // TODO security issues?
+                listItem.setAttribute("label", leafName);
+            }
+            if (providerType && cloudFileEnabled) {
+                let provider = cloudFileAccounts.getProviderForType(providerType);
+                listItem.setAttribute("image", provider.iconClass);
             } else {
-                let leafName = attachment.getParameter("FILENAME");
-                let providerType = attachment.getParameter("PROVIDER");
-                let cloudFileEnabled = Preferences.get("mail.cloud_files.enabled", false);
-
-                if (leafName) {
-                    // TODO security issues?
-                    listItem.setAttribute("label", leafName);
-                }
-                if (providerType && cloudFileEnabled) {
-                    let provider = cloudFileAccounts.getProviderForType(providerType);
-                    listItem.setAttribute("image", provider.iconClass);
-                } else {
-                    listItem.setAttribute("image", "moz-icon://dummy.html");
-                }
+                listItem.setAttribute("image", "moz-icon://dummy.html");
             }
         }
 
         // Now that everything is set up, add it to the attachment box.
         documentLink.appendChild(listItem);
 
         // full attachment object is stored here
         listItem.attachment = attachment;
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -1293,22 +1293,20 @@ calDavCalendar.prototype = {
                 this.mOfflineStorage.getItems.apply(this.mOfflineStorage, arguments);
             } else {
                 this.notifyOperationComplete(aListener,
                                              Components.results.NS_OK,
                                              cIOL.GET,
                                              null,
                                              null);
             }
+        } else if (!this.checkedServerInfo) {
+            this.mQueuedQueries.push(Array.from(arguments));
         } else {
-            if (!this.checkedServerInfo) {
-                this.mQueuedQueries.push(Array.from(arguments));
-            } else {
-                this.mOfflineStorage.getItems.apply(this.mOfflineStorage, arguments);
-            }
+            this.mOfflineStorage.getItems.apply(this.mOfflineStorage, arguments);
         }
     },
 
     fillACLProperties: function caldav_fillACLProperties() {
         let orgId = this.calendarUserAddress;
         if (orgId) {
             this.mACLProperties["organizerId"] = orgId;
         }
--- a/calendar/providers/memory/calMemoryCalendar.js
+++ b/calendar/providers/memory/calMemoryCalendar.js
@@ -405,24 +405,22 @@ calMemoryCalendar.prototype = {
 
         // return occurrences?
         let itemReturnOccurrences = ((aItemFilter & calICalendar.ITEM_FILTER_CLASS_OCCURRENCES) != 0);
 
         // figure out the return interface type
         let typeIID = null;
         if (itemReturnOccurrences) {
             typeIID = Components.interfaces.calIItemBase;
-        } else {
-            if (wantEvents && wantTodos) {
-                typeIID = Components.interfaces.calIItemBase;
-            } else if (wantEvents) {
-                typeIID = Components.interfaces.calIEvent;
-            } else if (wantTodos) {
-                typeIID = Components.interfaces.calITodo;
-            }
+        } else if (wantEvents && wantTodos) {
+            typeIID = Components.interfaces.calIItemBase;
+        } else if (wantEvents) {
+            typeIID = Components.interfaces.calIEvent;
+        } else if (wantTodos) {
+            typeIID = Components.interfaces.calITodo;
         }
 
         aRangeStart = cal.ensureDateTime(aRangeStart);
         aRangeEnd = cal.ensureDateTime(aRangeEnd);
 
 
         let offline_filter = aItemFilter &
             (calICalendar.ITEM_FILTER_OFFLINE_DELETED |
--- a/calendar/providers/storage/calStorageUpgrade.jsm
+++ b/calendar/providers/storage/calStorageUpgrade.jsm
@@ -1545,28 +1545,27 @@ upgrade.v22 = function upgrade_v22(db, v
                         ritem.type = aType;
                         ritem.isNegative = !!aIsNegative;
                         if (aCount) {
                             try {
                                 ritem.count = aCount;
                             } catch (exc) {
                                 // Don't fail if setting an invalid count
                             }
+                        } else if (aEndDate) {
+                            let allday = (aTmpFlags & CAL_ITEM_FLAG.EVENT_ALLDAY) != 0;
+                            let untilDate = newDateTime(aEndDate, allday ? "" : "UTC");
+                            if (allday) {
+                                untilDate.isDate = true;
+                            }
+                            ritem.untilDate = untilDate;
                         } else {
-                            if (aEndDate) {
-                                let allday = ((aTmpFlags & CAL_ITEM_FLAG.EVENT_ALLDAY) != 0);
-                                let untilDate = newDateTime(aEndDate, allday ? "" : "UTC");
-                                if (allday) {
-                                    untilDate.isDate = true;
-                                }
-                                ritem.untilDate = untilDate;
-                            } else {
-                                ritem.untilDate = null;
-                            }
+                            ritem.untilDate = null;
                         }
+
                         try {
                             ritem.interval = aInterval;
                         } catch (exc) {
                             // Don't fail if setting an invalid interval
                         }
 
                         let rtypes = {
                             SECOND: aSecond,
--- a/calendar/resources/content/datetimepickers/datetimepickers.xml
+++ b/calendar/resources/content/datetimepickers/datetimepickers.xml
@@ -318,22 +318,20 @@
                                 (this.mValue.getFullYear() != aValue.getFullYear());
                 }
                 this.mValue = aValue;
                 this.kTextBox.value = formattedValue;
                 if (aRefresh && dateChanged) {
                   this.fireEvent("change");
                 }
               }
-            } else {
+            } else if (this.mValue) {
               // invalid date, revert to previous date
               // set textBox.value property, not attribute
-              if (this.mValue) {
-                this.kTextBox.value = this.formatDate(this.mValue);
-              }
+              this.kTextBox.value = this.formatDate(this.mValue);
             }
           ]]>
         </body>
       </method>
 
       <method name="onPopup">
         <body>
           <![CDATA[
--- a/calendar/test/unit/test_alarm.js
+++ b/calendar/test/unit/test_alarm.js
@@ -446,23 +446,21 @@ function test_clone() {
     ok(newAlarm.isMutable);
 
     // Check if item is still the same
     // TODO This is not quite optimal, maybe someone can find a better way to do
     // the comparisons.
     for (let prop in propMap) {
         if (prop == "item") {
             equal(alarm.item.icalString, newAlarm.item.icalString);
-        } else {
-            if ((alarm[prop] instanceof Ci.nsISupports &&
-                 alarm[prop].icalString != newAlarm[prop].icalString) ||
-                !(alarm[prop] instanceof Ci.nsISupports) &&
-                  alarm[prop] != newAlarm[prop]) {
-                do_throw(prop + " differs, " + alarm[prop] + " == " + newAlarm[prop]);
-            }
+        } else if ((alarm[prop] instanceof Ci.nsISupports &&
+                    alarm[prop].icalString != newAlarm[prop].icalString) ||
+                   !(alarm[prop] instanceof Ci.nsISupports) &&
+                     alarm[prop] != newAlarm[prop]) {
+            do_throw(prop + " differs, " + alarm[prop] + " == " + newAlarm[prop]);
         }
     }
 
     // Check if changes on the cloned object do not affect the original object.
     for (let prop in clonePropMap) {
         newAlarm[prop] = clonePropMap[prop];
         dump("Checking " + prop + "...");
         notEqual(alarm[prop], newAlarm[prop]);