Merge pull request #7774 from timvandermeij/lint
Improve lint coverage and correct code style violations
This commit is contained in:
commit
9295114bdd
@ -3,16 +3,13 @@ l10n/
|
|||||||
docs/
|
docs/
|
||||||
node_modules/
|
node_modules/
|
||||||
examples/
|
examples/
|
||||||
|
external/bcmaps/
|
||||||
external/webL10n/
|
external/webL10n/
|
||||||
external/shelljs/
|
|
||||||
external/jpgjs/
|
|
||||||
external/jasmine/
|
|
||||||
external/cmapscompress/
|
external/cmapscompress/
|
||||||
external/importL10n/
|
|
||||||
external/builder/fixtures_esprima/
|
external/builder/fixtures_esprima/
|
||||||
shared/
|
|
||||||
test/tmp/
|
test/tmp/
|
||||||
test/features/
|
test/features/
|
||||||
|
test/pdfs/
|
||||||
test/resources/
|
test/resources/
|
||||||
test/font/*_spec.js
|
test/font/*_spec.js
|
||||||
*~/
|
*~/
|
||||||
|
4
external/importL10n/locales.js
vendored
4
external/importL10n/locales.js
vendored
@ -66,7 +66,7 @@ function downloadLanguageFiles(root, langCode, callback) {
|
|||||||
var request = https.get(url, function(response) {
|
var request = https.get(url, function(response) {
|
||||||
var content = '';
|
var content = '';
|
||||||
response.setEncoding('utf8');
|
response.setEncoding('utf8');
|
||||||
response.on("data", function(chunk) {
|
response.on('data', function(chunk) {
|
||||||
content += chunk;
|
content += chunk;
|
||||||
});
|
});
|
||||||
response.on('end', function() {
|
response.on('end', function() {
|
||||||
@ -75,7 +75,7 @@ function downloadLanguageFiles(root, langCode, callback) {
|
|||||||
if (downloadsLeft === 0) {
|
if (downloadsLeft === 0) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1000,7 +1000,7 @@ var CalRGBCS = (function CalRGBCSClosure() {
|
|||||||
|
|
||||||
function sRGBTransferFunction(color) {
|
function sRGBTransferFunction(color) {
|
||||||
// See http://en.wikipedia.org/wiki/SRGB.
|
// See http://en.wikipedia.org/wiki/SRGB.
|
||||||
if (color <= 0.0031308){
|
if (color <= 0.0031308) {
|
||||||
return adjustToRange(0, 1, 12.92 * color);
|
return adjustToRange(0, 1, 12.92 * color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,8 +498,7 @@ var calculateSHA512 = (function calculateSHA512Closure() {
|
|||||||
h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
|
h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
|
||||||
h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
|
h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
|
||||||
h7 = new Word64(0x5be0cd19, 0x137e2179);
|
h7 = new Word64(0x5be0cd19, 0x137e2179);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// SHA384 is exactly the same
|
// SHA384 is exactly the same
|
||||||
// except with different starting values and a trimmed result
|
// except with different starting values and a trimmed result
|
||||||
h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
|
h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
|
||||||
@ -618,8 +617,7 @@ var calculateSHA512 = (function calculateSHA512Closure() {
|
|||||||
h5.copyTo(result,40);
|
h5.copyTo(result,40);
|
||||||
h6.copyTo(result,48);
|
h6.copyTo(result,48);
|
||||||
h7.copyTo(result,56);
|
h7.copyTo(result,56);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
result = new Uint8Array(48);
|
result = new Uint8Array(48);
|
||||||
h0.copyTo(result,0);
|
h0.copyTo(result,0);
|
||||||
h1.copyTo(result,8);
|
h1.copyTo(result,8);
|
||||||
@ -1651,11 +1649,9 @@ var PDF20 = (function PDF20Closure() {
|
|||||||
}
|
}
|
||||||
if (remainder === 0) {
|
if (remainder === 0) {
|
||||||
k = calculateSHA256(e, 0, e.length);
|
k = calculateSHA256(e, 0, e.length);
|
||||||
}
|
} else if (remainder === 1) {
|
||||||
else if (remainder === 1) {
|
|
||||||
k = calculateSHA384(e, 0, e.length);
|
k = calculateSHA384(e, 0, e.length);
|
||||||
}
|
} else if (remainder === 2) {
|
||||||
else if (remainder === 2) {
|
|
||||||
k = calculateSHA512(e, 0, e.length);
|
k = calculateSHA512(e, 0, e.length);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@ -1977,8 +1973,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
|||||||
encryptionKey = prepareKeyData(fileIdBytes, passwordBytes,
|
encryptionKey = prepareKeyData(fileIdBytes, passwordBytes,
|
||||||
ownerPassword, userPassword, flags,
|
ownerPassword, userPassword, flags,
|
||||||
revision, keyLength, encryptMetadata);
|
revision, keyLength, encryptMetadata);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
|
var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
|
||||||
var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
|
var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
|
||||||
var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
|
var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
|
||||||
|
@ -296,7 +296,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||||||
for (j = 1, jj = contour.length; j < jj; j++) {
|
for (j = 1, jj = contour.length; j < jj; j++) {
|
||||||
if ((contour[j].flags & 1)) {
|
if ((contour[j].flags & 1)) {
|
||||||
lineTo(contour[j].x, contour[j].y);
|
lineTo(contour[j].x, contour[j].y);
|
||||||
} else if ((contour[j + 1].flags & 1)){
|
} else if ((contour[j + 1].flags & 1)) {
|
||||||
quadraticCurveTo(contour[j].x, contour[j].y,
|
quadraticCurveTo(contour[j].x, contour[j].y,
|
||||||
contour[j + 1].x, contour[j + 1].y);
|
contour[j + 1].x, contour[j + 1].y);
|
||||||
j++;
|
j++;
|
||||||
|
@ -226,7 +226,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||||||
// x_i' = min(max(x_i, Domain_2i), Domain_2i+1)
|
// x_i' = min(max(x_i, Domain_2i), Domain_2i+1)
|
||||||
var domain_2i = domain[i][0];
|
var domain_2i = domain[i][0];
|
||||||
var domain_2i_1 = domain[i][1];
|
var domain_2i_1 = domain[i][1];
|
||||||
var xi = Math.min(Math.max(src[srcOffset +i], domain_2i),
|
var xi = Math.min(Math.max(src[srcOffset + i], domain_2i),
|
||||||
domain_2i_1);
|
domain_2i_1);
|
||||||
|
|
||||||
// e_i = Interpolate(x_i', Domain_2i, Domain_2i+1,
|
// e_i = Interpolate(x_i', Domain_2i, Domain_2i+1,
|
||||||
@ -467,7 +467,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||||||
if (value < bound) {
|
if (value < bound) {
|
||||||
value = bound;
|
value = bound;
|
||||||
} else {
|
} else {
|
||||||
bound = range[i * 2 +1];
|
bound = range[i * 2 + 1];
|
||||||
if (value > bound) {
|
if (value > bound) {
|
||||||
value = bound;
|
value = bound;
|
||||||
}
|
}
|
||||||
@ -1052,7 +1052,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
n = num1.number;
|
n = num1.number;
|
||||||
if (n < 0 || (n|0) !== n || stack.length < n) {
|
if (n < 0 || (n | 0) !== n || stack.length < n) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ast1 = stack[stack.length - n - 1];
|
ast1 = stack[stack.length - n - 1];
|
||||||
@ -1102,7 +1102,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
|
|||||||
}
|
}
|
||||||
j = num2.number;
|
j = num2.number;
|
||||||
n = num1.number;
|
n = num1.number;
|
||||||
if (n <= 0 || (n|0) !== n || (j|0) !== j || stack.length < n) {
|
if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
|
||||||
// ... and integers
|
// ... and integers
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -645,7 +645,7 @@ var JpegImage = (function JpegImageClosure() {
|
|||||||
fileMarker = readUint16();
|
fileMarker = readUint16();
|
||||||
while (fileMarker !== 0xFFD9) { // EOI (End of image)
|
while (fileMarker !== 0xFFD9) { // EOI (End of image)
|
||||||
var i, j, l;
|
var i, j, l;
|
||||||
switch(fileMarker) {
|
switch (fileMarker) {
|
||||||
case 0xFFE0: // APP0 (Application Specific)
|
case 0xFFE0: // APP0 (Application Specific)
|
||||||
case 0xFFE1: // APP1
|
case 0xFFE1: // APP1
|
||||||
case 0xFFE2: // APP2
|
case 0xFFE2: // APP2
|
||||||
|
@ -2135,7 +2135,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
|
|
||||||
// step 1 & 3
|
// step 1 & 3
|
||||||
j = offset - 2;
|
j = offset - 2;
|
||||||
current = delta * x[j -1];
|
current = delta * x[j - 1];
|
||||||
for (n = len + 3; n--; j += 2) {
|
for (n = len + 3; n--; j += 2) {
|
||||||
next = delta * x[j + 1];
|
next = delta * x[j + 1];
|
||||||
x[j] = K * x[j] - current - next;
|
x[j] = K * x[j] - current - next;
|
||||||
|
@ -65,8 +65,7 @@ var MurmurHash3_64 = (function MurmurHash3_64Closure (seed) {
|
|||||||
var code = input.charCodeAt(i);
|
var code = input.charCodeAt(i);
|
||||||
if (code <= 0xff) {
|
if (code <= 0xff) {
|
||||||
data[length++] = code;
|
data[length++] = code;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
data[length++] = code >>> 8;
|
data[length++] = code >>> 8;
|
||||||
data[length++] = code & 0xff;
|
data[length++] = code & 0xff;
|
||||||
}
|
}
|
||||||
|
@ -1230,7 +1230,7 @@ var XRef = (function XRefClosure() {
|
|||||||
} else {
|
} else {
|
||||||
xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
|
xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
|
||||||
}
|
}
|
||||||
if (isDict(xrefEntry)){
|
if (isDict(xrefEntry)) {
|
||||||
xrefEntry.objId = ref.toString();
|
xrefEntry.objId = ref.toString();
|
||||||
} else if (isStream(xrefEntry)) {
|
} else if (isStream(xrefEntry)) {
|
||||||
xrefEntry.dict.objId = ref.toString();
|
xrefEntry.dict.objId = ref.toString();
|
||||||
|
@ -509,7 +509,7 @@ var TextWidgetAnnotationElement = (
|
|||||||
// TODO: This duplicates some of the logic in CanvasGraphics.setFont().
|
// TODO: This duplicates some of the logic in CanvasGraphics.setFont().
|
||||||
var style = element.style;
|
var style = element.style;
|
||||||
style.fontSize = this.data.fontSize + 'px';
|
style.fontSize = this.data.fontSize + 'px';
|
||||||
style.direction = (this.data.fontDirection < 0 ? 'rtl': 'ltr');
|
style.direction = (this.data.fontDirection < 0 ? 'rtl' : 'ltr');
|
||||||
|
|
||||||
if (!font) {
|
if (!font) {
|
||||||
return;
|
return;
|
||||||
|
@ -391,7 +391,7 @@ function compileType3Glyph(imgData) {
|
|||||||
var o = outlines[i];
|
var o = outlines[i];
|
||||||
c.moveTo(o[0], o[1]);
|
c.moveTo(o[0], o[1]);
|
||||||
for (var j = 2, jj = o.length; j < jj; j += 2) {
|
for (var j = 2, jj = o.length; j < jj; j += 2) {
|
||||||
c.lineTo(o[j], o[j+1]);
|
c.lineTo(o[j], o[j + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.fill();
|
c.fill();
|
||||||
|
@ -226,7 +226,7 @@ if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
|
|||||||
function isFontReady(name, callback) {
|
function isFontReady(name, callback) {
|
||||||
called++;
|
called++;
|
||||||
// With setTimeout clamping this gives the font ~100ms to load.
|
// With setTimeout clamping this gives the font ~100ms to load.
|
||||||
if(called > 30) {
|
if (called > 30) {
|
||||||
warn('Load test font never loaded.');
|
warn('Load test font never loaded.');
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
|
@ -307,7 +307,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(opList[x].fn === 'restore') {
|
if (opList[x].fn === 'restore') {
|
||||||
opTree = tmp.pop();
|
opTree = tmp.pop();
|
||||||
} else {
|
} else {
|
||||||
opTree.push(opList[x]);
|
opTree.push(opList[x]);
|
||||||
@ -470,14 +470,14 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
|
|
||||||
for (var x = 0; x < fnArrayLen; x++) {
|
for (var x = 0; x < fnArrayLen; x++) {
|
||||||
var fnId = fnArray[x];
|
var fnId = fnArray[x];
|
||||||
opList.push({'fnId' : fnId, 'fn': REVOPS[fnId], 'args': argsArray[x]});
|
opList.push({'fnId': fnId, 'fn': REVOPS[fnId], 'args': argsArray[x]});
|
||||||
}
|
}
|
||||||
return opListToTree(opList);
|
return opListToTree(opList);
|
||||||
},
|
},
|
||||||
|
|
||||||
executeOpTree: function SVGGraphics_executeOpTree(opTree) {
|
executeOpTree: function SVGGraphics_executeOpTree(opTree) {
|
||||||
var opTreeLen = opTree.length;
|
var opTreeLen = opTree.length;
|
||||||
for(var x = 0; x < opTreeLen; x++) {
|
for (var x = 0; x < opTreeLen; x++) {
|
||||||
var fn = opTree[x].fn;
|
var fn = opTree[x].fn;
|
||||||
var fnId = opTree[x].fnId;
|
var fnId = opTree[x].fnId;
|
||||||
var args = opTree[x].args;
|
var args = opTree[x].args;
|
||||||
@ -733,7 +733,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
|
|
||||||
current.txtElement.setAttributeNS(null, 'transform',
|
current.txtElement.setAttributeNS(null, 'transform',
|
||||||
pm(current.textMatrix) +
|
pm(current.textMatrix) +
|
||||||
' scale(1, -1)' );
|
' scale(1, -1)');
|
||||||
current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
|
current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
|
||||||
current.txtElement.appendChild(current.tspan);
|
current.txtElement.appendChild(current.tspan);
|
||||||
current.txtgrp.appendChild(current.txtElement);
|
current.txtgrp.appendChild(current.txtElement);
|
||||||
@ -1105,7 +1105,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
rect.setAttributeNS(null, 'width', pf(width));
|
rect.setAttributeNS(null, 'width', pf(width));
|
||||||
rect.setAttributeNS(null, 'height', pf(height));
|
rect.setAttributeNS(null, 'height', pf(height));
|
||||||
rect.setAttributeNS(null, 'fill', fillColor);
|
rect.setAttributeNS(null, 'fill', fillColor);
|
||||||
rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId +')');
|
rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
|
||||||
this.defs.appendChild(mask);
|
this.defs.appendChild(mask);
|
||||||
|
|
||||||
this._ensureTransformGroup().appendChild(rect);
|
this._ensureTransformGroup().appendChild(rect);
|
||||||
|
@ -317,11 +317,10 @@ describe('crypto', function() {
|
|||||||
alg = new PDF17();
|
alg = new PDF17();
|
||||||
password = new Uint8Array([117, 115, 101, 114]);
|
password = new Uint8Array([117, 115, 101, 114]);
|
||||||
userValidation = new Uint8Array([117, 169, 4, 32, 159, 101, 22, 220]);
|
userValidation = new Uint8Array([117, 169, 4, 32, 159, 101, 22, 220]);
|
||||||
userPassword = new Uint8Array([
|
userPassword = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79,
|
||||||
131, 242, 143, 160, 87, 2, 138, 134, 79,
|
253, 189, 173, 224, 73, 144, 241, 190, 81,
|
||||||
253, 189, 173, 224, 73, 144, 241, 190, 81,
|
197, 15, 249, 105, 145, 151, 15, 194, 65,
|
||||||
197, 15, 249, 105, 145, 151, 15, 194, 65,
|
3, 1, 126, 187, 221]);
|
||||||
3, 1, 126, 187, 221]);
|
|
||||||
result = alg.checkUserPassword(password, userValidation, userPassword);
|
result = alg.checkUserPassword(password, userValidation, userPassword);
|
||||||
expect(result).toEqual(true);
|
expect(result).toEqual(true);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user