Closed Bug 1512837 Opened 5 years ago Closed 5 years ago

cleanup logic in mailnews/base/content/dateFormat.js

Categories

(MailNews Core :: Filters, defect)

defect
Not set
trivial

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 67.0

People

(Reporter: aceman, Assigned: aceman)

References

Details

Attachments

(1 file, 1 obsolete file)

Improve the logic flow in mailnews/base/content/dateFormat.js, e.g. do not set the same default values at 2 places.
Attached patch 1512837.patch (obsolete) — Splinter Review

The calls to getComplexValue(pref_name, Ci.nsIPrefLocalizedString) were missing the .data (see the third case) but they still could be converted silently to the correct value, at least in a dump().
I add them for safety as the .data is always used in other places.

Attachment #9041003 - Flags: review?(jorgk)
Comment on attachment 9041003 [details] [diff] [review]
1512837.patch

Review of attachment 9041003 [details] [diff] [review]:
-----------------------------------------------------------------

You never cease to surprise. How did we get to this bug? I this covered by tests? Strange that `.data` was missing and it still did something useful.

::: mailnews/base/content/dateFormat.js
@@ +42,5 @@
>      // check the format option
>      if (arrayOfStrings.length != 3)  // no successful split
>      {
> +      Cu.reportError("initLocaleShortDateFormat: could not analyze the date format, defaulting to mm/dd/yyyy");
> +      return;

This early return isn't needed.

@@ +65,5 @@
>        {
>          // 12.1999.01 or 1999.12.01
>          gSearchDateFormat = arrayOfStrings[0] == "12" ? 4 : 1;
>        }
> +      return;

And this one either.

@@ +84,5 @@
>    // get a search date format option and a separator
>    try {
>      gSearchDateFormat =
>        Services.prefs.getComplexValue("mailnews.search_date_format",
> +                                     Ci.nsIPrefLocalizedString).data;

I wonder how that worked without the .data.
Attachment #9041003 - Flags: review?(jorgk) → review+

(In reply to Jorg K (GMT+1) from comment #2)

This early return isn't needed.

The returns aren't needed in current state of the function, but it looked cleaner to me to exit early when done.

gSearchDateFormat =
Services.prefs.getComplexValue("mailnews.search_date_format",

  •                                 Ci.nsIPrefLocalizedString).data;
    

I wonder how that worked without the .data.

I tested it with dump() and it displayed the correct string value even though gSearchDateFormat was of Object type. Probably some automatic conversion.

I'd remove the returns.

Ok, thanks

Attachment #9041003 - Attachment is obsolete: true
Attachment #9041006 - Flags: review+

(In reply to Jorg K (GMT+1) from comment #2)

You never cease to surprise. How did we get to this bug? I this covered by
tests?

Noticed in bug 1512808.

Keywords: checkin-needed

Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/6ba67360bdd4
clean up logic in mailnews/base/content/dateFormat.js. r=jorgk

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 67.0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: