Skip to content

Commit 69bb614

Browse files
authored
🐛 Fix LGTM alerts in AMP codebase (#22488)
1 parent 2ec0cdc commit 69bb614

File tree

9 files changed

+12
-14
lines changed

9 files changed

+12
-14
lines changed

3p/embedly.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export const CardOptions = {
6060
* Loads embedly card SDK that is consumed by this 3p integration.
6161
*
6262
* @param {!Window} global
63-
* @param {function(!Object)} callback
63+
* @param {function()} callback
6464
* @visibleForTesting
6565
*/
6666
function getEmbedly(global, callback) {
6767
loadScript(global, EMBEDLY_SDK_URL, function() {
68-
callback(global);
68+
callback();
6969
});
7070
}
7171

3p/github.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import {writeScript} from './3p';
2626
*
2727
* @param {!Window} global
2828
* @param {string} scriptSource The source of the script, different for post and comment embeds.
29-
* @param {function(*)} cb
29+
* @param {function()} cb
3030
*/
3131
function getGistJs(global, scriptSource, cb) {
3232
writeScript(global, scriptSource, function() {
33-
cb(global.gist);
33+
cb();
3434
});
3535
}
3636

3p/nameframe.max.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
<script>
66
try {
77
var name_data = JSON.parse(window.name);
8-
if (!name_data || !name_data['creative']) {
8+
if (!name_data || !name_data.creative) {
99
throw new Error('Missing or incorrectly formatted JSON ' +
1010
'input to nameframe');
1111
}
1212
document.open();
13-
document.write(name_data['creative']);
13+
document.write(name_data.creative);
1414
document.close();
15-
delete name_data['creative'];
15+
delete name_data.creative;
1616
window.name = JSON.stringify(name_data);
1717
} catch (err) {
1818
window.parent.postMessage({type: 'no-content', error: err.message}, '*');

build-system/tasks/presubmit-checks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ const forbiddenTermsSrcInclusive = {
896896
'build-system/amp4test.js',
897897
'dist.3p/current/integration.js',
898898
'extensions/amp-iframe/0.1/amp-iframe.js',
899+
'src/3p-frame.js',
899900
'src/config.js',
900901
'testing/local-amp-chrome-extension/background.js',
901902
'tools/errortracker/errortracker.go',

extensions/amp-vimeo/0.1/amp-vimeo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class AmpVimeo extends AMP.BaseElement {
207207
!originMatches(
208208
event,
209209
this.iframe_,
210-
/^(https?:)?\/\/((player|www).)?vimeo.com(?=$|\/)/
210+
/^(https?:)?\/\/((player|www)\.)?vimeo.com(?=$|\/)/
211211
)
212212
) {
213213
return;

src/3p-frame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export function getDevelopmentBootstrapBaseUrl(parentWindow, srcFileBasename) {
291291
*/
292292
function getAdsLocalhost(win) {
293293
let adsUrl = urls.thirdParty; // local dev with a non-localhost server
294-
if (adsUrl.indexOf('ampproject.net') > -1) {
294+
if (adsUrl == 'https://3p.ampproject.net') {
295295
adsUrl = 'http://ads.localhost'; // local dev with a localhost server
296296
}
297297
return adsUrl + ':' + (win.location.port || win.parent.location.port);

validator/build.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
import os
2323
import platform
2424
import re
25-
import shutil
2625
import subprocess
2726
import sys
28-
import tempfile
2927

3028

3129
def Die(msg):

validator/engine/json-testutil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function objToJsonSegments(obj, out, cmpFn) {
9898
// We hack the non-standard "'" into place here because the
9999
// Javascript style guide prefers them (and git5 lint reports
100100
// double quotes as errors).
101-
out.push('\'' + candidate.slice(1, -1).replace('\'', '\\\'') + '\'');
101+
out.push('\'' + candidate.slice(1, -1).replace(/\'/g, '\\\'') + '\'');
102102
} else {
103103
out.push(candidate);
104104
}

validator/webui/build.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
# Polymer project, and unlike for the parent directory there's no
2323
# particular benefit to using Python.
2424

25-
import glob
2625
import logging
2726
import os
2827
import platform
@@ -158,7 +157,7 @@ def Main():
158157
logging.basicConfig(
159158
format='[[%(filename)s %(funcName)s]] - %(message)s',
160159
level=(logging.ERROR if os.environ.get('TRAVIS') else logging.INFO))
161-
nodejs_cmd = GetNodeJsCmd()
160+
GetNodeJsCmd()
162161
CheckPrereqs()
163162
InstallNodeDependencies()
164163
SetupOutDir(out_dir='dist')

0 commit comments

Comments
 (0)