Closed Bug 1393219 Opened 7 years ago Closed 7 years ago

Code clean-up: Style nits, typos and trailing spaces

Categories

(Thunderbird :: General, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 57.0

People

(Reporter: jorgk-bmo, Assigned: jorgk-bmo)

Details

Attachments

(7 files, 2 obsolete files)

To facilitate continuous integration, I will collect some patches here that can be landed if no other patch is available to trigger a build.
Assignee: nobody → jorgk
Status: NEW → ASSIGNED
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/b97b47c64376
Style nit: Use IsEmpty() instead of Length()==0. r=me
Attachment #8900458 - Attachment description: 1393219-isempty.patch - style nit → 1393219-isempty.patch - style nit [Landed: comment #3]
I found this browsing code the other day in the context of bug 1242030 comment #216. It's part of creating a stream of patches for triggering builds after M-C merges.
Attachment #8905422 - Flags: review?(acelists)
Attachment #8905432 - Attachment description: 1393219-whitespace-mimedrft.cpp → 1393219-whitespace-mimedrft.patch
Attachment #8905432 - Attachment filename: 1393219-whitespace-mimedrft.cpp → 1393219-whitespace-mimedrft.patch
Attachment #8905432 - Attachment is patch: true
More.
Attachment #8905432 - Attachment is obsolete: true
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/b6e47292fdff
Typo fix. rs=typo-only
https://hg.mozilla.org/comm-central/rev/5a8396d48e9e
Fix white-space issues in mimedrft.cpp. rs=white-space-only
Attachment #8900465 - Attachment description: 1393219-test-typo.patch → 1393219-test-typo.patch [Landed: comment #7]
Comment on attachment 8905438 [details] [diff] [review]
1393219-whitespace-mimedrft.cpp (v2) [Landed: comment #7]

The patch doesn't reflect 100% what was landed since I found some more.
Attachment #8905438 - Attachment description: 1393219-whitespace-mimedrft.cpp (v2). → 1393219-whitespace-mimedrft.cpp (v2) [Landed: comment #7]
Comment on attachment 8905422 [details] [diff] [review]
1393219-unused-uri.patch [Landed: comment #14]

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

Unused variable? Nice
Attachment #8905422 - Flags: review?(acelists) → review+
Comment on attachment 8905438 [details] [diff] [review]
1393219-whitespace-mimedrft.cpp (v2) [Landed: comment #7]

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

Removing ugly spaces? Good :)

::: mailnews/mime/src/mimedrft.cpp
@@ +1915,4 @@
>  
>    if (!contLoc && !newAttachment->m_realName.IsEmpty())
>      workURLSpec = ToNewCString(newAttachment->m_realName);
> +  if ((contLoc) && (!workURLSpec))

These probably do not need so many backets.
Attachment #8905438 - Flags: review+
Comment on attachment 8906016 [details] [diff] [review]
1393219-mimedrft-parenthesis.patch [Landed: comment #14]

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

Thanks :)
Attachment #8906016 - Flags: review?(acelists) → review+
Remove define for CaseInsensitiveCompare and its use. Why?
It's confusing like hell since this is also a comparison function in M-C:
https://dxr.mozilla.org/mozilla-central/search?q=CaseInsensitiveCompare&redirect=false

Also, there are other comparison functions which look the same:
nsCaseInsensitiveStringComparator()
Attachment #8906135 - Flags: review?(acelists)
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/128de925dde2
remove superfluous parenthesis in mimedrft.cpp. r=aceman
https://hg.mozilla.org/comm-central/rev/4fc52379f051
Clean-up: Remove unused variable. r=aceman
Attachment #8905422 - Attachment description: 1393219-unused-uri.patch → 1393219-unused-uri.patch [Landed: comment #14]
Attachment #8906016 - Attachment description: 1393219-mimedrft-parenthesis.patch → 1393219-mimedrft-parenthesis.patch [Landed: comment #14]
When I wrote this, I didn't know that FindChar() could take an offset. The reviewer didn't notice it either. I've tested this to avoid an "off-by-one" error.

Only occurrence in C-C:
https://dxr.mozilla.org/comm-central/search?q=regexp%3Asubstring.*find&redirect=false
Attachment #8906153 - Flags: review?(acelists)
Comment on attachment 8906153 [details] [diff] [review]
1393219-findchar.patch [Landed: Comment #27]

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

If this fixes an error (changes behaviour), then it does not look like belonging into this bug.
No error, no behaviour change, just removing clumsiness.
Comment on attachment 8906153 [details] [diff] [review]
1393219-findchar.patch [Landed: Comment #27]

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

Thanks, I misread your comment, thinking you fix an off-by-one error, but you just tried to avoid introducing one.
Attachment #8906153 - Flags: review?(acelists) → review+
Comment on attachment 8906135 [details] [diff] [review]
1393219-CaseInsensitiveCompare.patch

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

I'm not particularly happy about this change. The variable could be useful as it explains what the 'true' value means to the casual reader. Maybe just renaming it would solve the problem you are after (clash with name of another function) ? Similarly you could use more of the kNotFound constant instead of -1 in the patch.
Attachment #8906135 - Flags: review?(acelists) → feedback?(mkmelin+mozilla)
Attachment #8900465 - Flags: review+
Attachment #8900458 - Flags: review+
OK, how about instead of s/CaseInsensitiveCompare/true/ make "/* ignoreCase = */ true like I had here:
https://hg.mozilla.org/comm-central/rev/def874d2d27c8fa1734f885059d29362b3990032#l1.12
which was inspired by this:
https://hg.mozilla.org/mozilla-central/rev/a1bcb487ffec#l2.13
How about this one then? Sometimes we explain arguments at the call site, but having a define for that purpose seems misguided.
Attachment #8906135 - Attachment is obsolete: true
Attachment #8906135 - Flags: feedback?(mkmelin+mozilla)
Attachment #8906266 - Flags: review?(acelists)
Comment on attachment 8906266 [details] [diff] [review]
1393219-CaseInsensitiveCompare.patch (v2) [Landed: Comment #26]

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

That could work, I've seen this elsewhere. But why was renaming not good?
Also please, use the kNotFound where possible.
(In reply to :aceman from comment #19)
>  Similarly you could use more of the kNotFound constant
> instead of -1 in the patch.

Personally I think we should do more of the opposite, and use -1 more. If you use a KNotFound you have to "know" that that constant exists, and that it's defined in the current file/context. That not found is -1 is common knowledge, and anybody even unfamiliar with the code (but familiar with c++ and other programming languages) would understand it and be able to use that instantly.
Let's not get caught up in a discussion about kNotFound vs. -1 vs. >= 0.

The point is, CaseInsensitiveCompare is really bad, it confused me yesterday, see:
https://hg.mozilla.org/comm-central/rev/9e30863be03af555dc65fadac63c02138707fb8e#l3.12
https://hg.mozilla.org/comm-central/rev/def874d2d27c8fa1734f885059d29362b3990032#l1.12
since I thought it was a comparison function like nsCaseInsensitiveStringComparator().
So under bustage-fix pressure I did it the M-C way, only to realise that indeed we have a #define for this from the quirky old days that no one understands any more:

- * The internal API expects nsCaseInsensitiveC?StringComparator() and true.
- * Redefine CaseInsensitiveCompare so that Find works.
- */
-#define CaseInsensitiveCompare true
-/**

What??
Attachment #8906266 - Flags: review?(mkmelin+mozilla)
Comment on attachment 8906266 [details] [diff] [review]
1393219-CaseInsensitiveCompare.patch (v2) [Landed: Comment #26]

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

LGTM, r=mkmelin

::: mailnews/base/search/src/nsMsgBodyHandler.cpp
@@ +364,5 @@
>      // MIME type. message/rfc822 is best treated as a multipart with no proper
>      // boundary; since we only use boundaries for retriggering the headers,
>      // the lack of one can safely be ignored.
> +    else if (lowerCaseLine.Find("multipart/", /* ignoreCase = */ true) != -1 ||
> +        lowerCaseLine.Find("message/", /* ignoreCase = */ true) != -1)

nit: align these two lowerCaseLines while you're toughing this
Attachment #8906266 - Flags: review?(mkmelin+mozilla) → review+
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/27e6d777270f
remove define for CaseInsensitiveCompare. r=mkmelin
Attachment #8906266 - Attachment description: 1393219-CaseInsensitiveCompare.patch (v2) → 1393219-CaseInsensitiveCompare.patch (v2) [Landed: Comment #26]
Attachment #8906266 - Flags: review?(acelists)
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/2ee641160857
Use FindChar() with offset instead of extracting Substring. r=aceman
Attachment #8906153 - Attachment description: 1393219-findchar.patch → 1393219-findchar.patch [Landed: Comment #27]
I'm done here. More "Code clean-up: Style nits, typos and trailing spaces" in a new bug.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Keywords: leave-open
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 57.0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: