Skip to content

Commit 6951ef4

Browse files
Psychpsyoalimpfard
authored andcommitted
Meta: Validate proper formatting for FIXMEs and AD-HOCs
1 parent 100f379 commit 6951ef4

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Libraries/LibWeb/HTML/HTMLMediaElement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,8 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
12591259
if (enable == TriState::True)
12601260
audio_track->set_enabled(true);
12611261

1262-
// AD-HOC(ish): According to https://dev.w3.org/html5/html-sourcing-inband-tracks/, kind should be set according to format, and the following criteria within
1263-
// the specified formats.
1262+
// NB: According to https://dev.w3.org/html5/html-sourcing-inband-tracks/, kind should be set according to format, and the following criteria within
1263+
// the specified formats.
12641264
// WebM:
12651265
// - "main": the FlagDefault element is set on the track
12661266
// - "translation": not first audio (video) track
@@ -1318,7 +1318,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
13181318
if (enable == TriState::True)
13191319
video_track->set_selected(true);
13201320

1321-
// AD-HOC(ish): See the comment regarding AudioTrack.kind above with regard to https://dev.w3.org/html5/html-sourcing-inband-tracks/.
1321+
// NB: See the comment regarding AudioTrack.kind above with regard to https://dev.w3.org/html5/html-sourcing-inband-tracks/.
13221322
video_track->set_kind(enable == TriState::True ? "main"_utf16 : "translation"_utf16);
13231323

13241324
// 7. Fire an event named addtrack at this VideoTrackList object, using TrackEvent, with the track attribute initialized to the new VideoTrack object.

Meta/check-style.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
# We check for and disallow any comments linking to the single-page HTML spec because it takes a long time to load.
5858
SINGLE_PAGE_HTML_SPEC_LINK = re.compile("//.*https://html\\.spec\\.whatwg\\.org/#")
5959

60+
# We similarily check and disallow AD-HOCs and FIXMEs that aren't followed by a colon.
61+
INVALID_AD_HOC_OR_FIXME = re.compile(r'^(?:[\s\d./\-(*]+(?:AD-HOC|FIXME)[^:]|.*"FIXME[^:"]).*$', re.MULTILINE)
62+
6063

6164
def should_check_file(filename):
6265
if not filename.endswith(".cpp") and not filename.endswith(".h"):
@@ -97,6 +100,7 @@ def run():
97100
errors_include_missing_local = []
98101
errors_include_bad_complex = []
99102
errors_single_page_html_spec = []
103+
errors_invalid_ad_hoc_or_fixme = {}
100104

101105
for filename in find_files_here_or_argv():
102106
with open(filename, mode="r", encoding="utf-8") as f:
@@ -146,6 +150,9 @@ def run():
146150
errors_include_missing_local.append(filename)
147151
if SINGLE_PAGE_HTML_SPEC_LINK.search(file_content):
148152
errors_single_page_html_spec.append(filename)
153+
invalid_ad_hocs_or_fixmes = INVALID_AD_HOC_OR_FIXME.findall(file_content)
154+
if invalid_ad_hocs_or_fixmes:
155+
errors_invalid_ad_hoc_or_fixme[filename] = invalid_ad_hocs_or_fixmes
149156

150157
have_errors = False
151158
if errors_license:
@@ -184,6 +191,10 @@ def run():
184191
if errors_single_page_html_spec:
185192
print("Files with links to the single-page HTML spec:", " ".join(errors_single_page_html_spec))
186193
have_errors = True
194+
if errors_invalid_ad_hoc_or_fixme:
195+
for file in errors_invalid_ad_hoc_or_fixme:
196+
print(f"{file} contains invalid AD-HOC or FIXME usages:", "".join(errors_invalid_ad_hoc_or_fixme[file]))
197+
have_errors = True
187198

188199
if have_errors:
189200
sys.exit(1)

0 commit comments

Comments
 (0)