Bug 311387
| Summary: | stylechecker is trying to tackle lines contained in R"js( … )js"_s | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Karl Dubost <karlcow> |
| Component: | Tools / Tests | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=311383 | ||
Karl Dubost
In my case I was working on a script injection:
And the style checker sent:
Source/WebCore/page/Quirks.cpp:143: error: [whitespace/parens] More than one command on the same line in if
Source/WebCore/page/Quirks.cpp:146: error: [whitespace/braces] Place brace on its own line for function definitions.
Source/WebCore/page/Quirks.cpp:155: error: [whitespace/parens] More than one command on the same line in if
Source/WebCore/page/Quirks.cpp:160: error: [whitespace/newline] More than one command on the same line
For this code:
static constexpr auto ceacBeforeUnloadFixScript = R"js((function() {
if (window.__ceacBeforeUnloadFix) return;
window.__ceacBeforeUnloadFix = true;
var origAEL = window.addEventListener;
window.addEventListener = function(type, fn, opts) {
if (type === 'beforeunload') {
return origAEL.call(this, type, function(e) {
var ae = document.activeElement;
if (ae && ae.tagName === 'INPUT') {
var t = (ae.type || '').toLowerCase();
if (t === 'radio' || t === 'checkbox' || t === 'submit' || t === 'button')
return;
}
if (typeof fn === 'function') fn.call(this, e);
}, opts);
}
return origAEL.apply(this, arguments);
};
})();)js"_s;
The easy fix is to put everything as a one-liner but then we lose the readability of the code.
Maybe the style should avoid to parse lines inside a R"js( … )js"_s structure.
Related to https://github.com/WebKit/WebKit/pull/61948
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/174459210>