Fixes some static analysis warnings and recommendations

* Useless conditional
* Superfluous trailing arguments
* Useless assignment to local variable
* Misspelled identifier
* JSDoc tag for non-existent parameter
This commit is contained in:
Yury Delendik 2016-05-02 17:34:58 -05:00
parent d20002b6b1
commit 32ce369d88
9 changed files with 32 additions and 43 deletions

View File

@ -331,7 +331,7 @@ var CFFParser = (function CFFParserClosure() {
function parseOperand() { function parseOperand() {
var value = dict[pos++]; var value = dict[pos++];
if (value === 30) { if (value === 30) {
return parseFloatOperand(pos); return parseFloatOperand();
} else if (value === 28) { } else if (value === 28) {
value = dict[pos++]; value = dict[pos++];
value = ((value << 24) | (dict[pos++] << 16)) >> 16; value = ((value << 24) | (dict[pos++] << 16)) >> 16;

View File

@ -1779,17 +1779,15 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
pdfAlgorithm = new PDF17(); pdfAlgorithm = new PDF17();
} }
if (pdfAlgorithm) { if (pdfAlgorithm.checkUserPassword(password, userValidationSalt,
if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
userPassword)) { return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption); } else if (password.length && pdfAlgorithm.checkOwnerPassword(password,
} else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt,
ownerValidationSalt, uBytes,
uBytes, ownerPassword)) {
ownerPassword)) { return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes,
return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
ownerEncryption);
}
} }
return null; return null;

View File

@ -19,33 +19,30 @@
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define('pdfjs/core/fonts', ['exports', 'pdfjs/shared/util', define('pdfjs/core/fonts', ['exports', 'pdfjs/shared/util',
'pdfjs/core/primitives', 'pdfjs/core/stream', 'pdfjs/core/parser', 'pdfjs/core/primitives', 'pdfjs/core/stream', 'pdfjs/core/parser',
'pdfjs/core/glyphlist', 'pdfjs/core/charsets', 'pdfjs/core/glyphlist', 'pdfjs/core/font_renderer',
'pdfjs/core/font_renderer', 'pdfjs/core/encodings', 'pdfjs/core/encodings', 'pdfjs/core/standard_fonts', 'pdfjs/core/unicode',
'pdfjs/core/standard_fonts', 'pdfjs/core/unicode',
'pdfjs/core/type1_parser', 'pdfjs/core/cff_parser'], factory); 'pdfjs/core/type1_parser', 'pdfjs/core/cff_parser'], factory);
} else if (typeof exports !== 'undefined') { } else if (typeof exports !== 'undefined') {
factory(exports, require('../shared/util.js'), require('./primitives.js'), factory(exports, require('../shared/util.js'), require('./primitives.js'),
require('./stream.js'), require('./parser.js'), require('./stream.js'), require('./parser.js'), require('./glyphlist.js'),
require('./glyphlist.js'), require('./charsets.js'),
require('./font_renderer.js'), require('./encodings.js'), require('./font_renderer.js'), require('./encodings.js'),
require('./standard_fonts.js'), require('./unicode.js'), require('./standard_fonts.js'), require('./unicode.js'),
require('./type1_parser.js'), require('./cff_parser.js')); require('./type1_parser.js'), require('./cff_parser.js'));
} else { } else {
factory((root.pdfjsCoreFonts = {}), root.pdfjsSharedUtil, factory((root.pdfjsCoreFonts = {}), root.pdfjsSharedUtil,
root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser,
root.pdfjsCoreGlyphList, root.pdfjsCoreCharsets, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer,
root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts,
root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser,
root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser); root.pdfjsCoreCFFParser);
} }
}(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser,
coreGlyphList, coreCharsets, coreFontRenderer, coreGlyphList, coreFontRenderer, coreEncodings,
coreEncodings, coreStandardFonts, coreUnicode, coreStandardFonts, coreUnicode, coreType1Parser,
coreType1Parser, coreCFFParser) { coreCFFParser) {
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX; var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
var FontType = sharedUtil.FontType; var FontType = sharedUtil.FontType;
var Util = sharedUtil.Util;
var assert = sharedUtil.assert; var assert = sharedUtil.assert;
var bytesToString = sharedUtil.bytesToString; var bytesToString = sharedUtil.bytesToString;
var error = sharedUtil.error; var error = sharedUtil.error;
@ -55,7 +52,6 @@ var isInt = sharedUtil.isInt;
var isNum = sharedUtil.isNum; var isNum = sharedUtil.isNum;
var readUint32 = sharedUtil.readUint32; var readUint32 = sharedUtil.readUint32;
var shadow = sharedUtil.shadow; var shadow = sharedUtil.shadow;
var stringToBytes = sharedUtil.stringToBytes;
var string32 = sharedUtil.string32; var string32 = sharedUtil.string32;
var warn = sharedUtil.warn; var warn = sharedUtil.warn;
var MissingDataException = sharedUtil.MissingDataException; var MissingDataException = sharedUtil.MissingDataException;
@ -63,16 +59,11 @@ var Stream = coreStream.Stream;
var Lexer = coreParser.Lexer; var Lexer = coreParser.Lexer;
var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode; var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode; var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
var ExpertCharset = coreCharsets.ExpertCharset;
var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
var FontRendererFactory = coreFontRenderer.FontRendererFactory; var FontRendererFactory = coreFontRenderer.FontRendererFactory;
var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
var StandardEncoding = coreEncodings.StandardEncoding; var StandardEncoding = coreEncodings.StandardEncoding;
var MacRomanEncoding = coreEncodings.MacRomanEncoding; var MacRomanEncoding = coreEncodings.MacRomanEncoding;
var SymbolSetEncoding = coreEncodings.SymbolSetEncoding; var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding; var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
var ExpertEncoding = coreEncodings.ExpertEncoding;
var getEncoding = coreEncodings.getEncoding; var getEncoding = coreEncodings.getEncoding;
var getStdFontMap = coreStandardFonts.getStdFontMap; var getStdFontMap = coreStandardFonts.getStdFontMap;
var getNonStdFontMap = coreStandardFonts.getNonStdFontMap; var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
@ -2070,7 +2061,7 @@ var Font = (function FontClosure() {
} }
} }
function sanitizeTTPrograms(fpgm, prep, cvt) { function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
var ttContext = { var ttContext = {
functionsDefined: [], functionsDefined: [],
functionsUsed: [], functionsUsed: [],
@ -2827,7 +2818,8 @@ var ErrorFont = (function ErrorFontClosure() {
* @param {Object} properties Font properties object. * @param {Object} properties Font properties object.
* @param {Object} builtInEncoding The encoding contained within the actual font * @param {Object} builtInEncoding The encoding contained within the actual font
* data. * data.
* @param {Array} Array of glyph names where the index is the glyph ID. * @param {Array} glyphNames Array of glyph names where the index is the
* glyph ID.
* @returns {Object} A char code to glyph ID map. * @returns {Object} A char code to glyph ID map.
*/ */
function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) { function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {

View File

@ -1259,7 +1259,7 @@ var JpxImage = (function JpxImageClosure() {
for (j = 0; j < codingpasses; j++) { for (j = 0; j < codingpasses; j++) {
switch (currentCodingpassType) { switch (currentCodingpassType) {
case 0: case 0:
bitModel.runSignificancePropogationPass(); bitModel.runSignificancePropagationPass();
break; break;
case 1: case 1:
bitModel.runMagnitudeRefinementPass(); bitModel.runMagnitudeRefinementPass();
@ -1738,8 +1738,8 @@ var JpxImage = (function JpxImageClosure() {
} }
neighborsSignificance[index] |= 0x80; neighborsSignificance[index] |= 0x80;
}, },
runSignificancePropogationPass: runSignificancePropagationPass:
function BitModel_runSignificancePropogationPass() { function BitModel_runSignificancePropagationPass() {
var decoder = this.decoder; var decoder = this.decoder;
var width = this.width, height = this.height; var width = this.width, height = this.height;
var coefficentsMagnitude = this.coefficentsMagnitude; var coefficentsMagnitude = this.coefficentsMagnitude;

View File

@ -810,7 +810,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
return; return;
} }
stats.time('Rendering'); stats.time('Rendering');
internalRenderTask.initalizeGraphics(transparency); internalRenderTask.initializeGraphics(transparency);
internalRenderTask.operatorListChanged(); internalRenderTask.operatorListChanged();
}, },
function pageDisplayReadPromiseError(reason) { function pageDisplayReadPromiseError(reason) {
@ -1937,8 +1937,8 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
InternalRenderTask.prototype = { InternalRenderTask.prototype = {
initalizeGraphics: initializeGraphics:
function InternalRenderTask_initalizeGraphics(transparency) { function InternalRenderTask_initializeGraphics(transparency) {
if (this.cancelled) { if (this.cancelled) {
return; return;

View File

@ -1302,7 +1302,7 @@ function createPromiseCapability() {
/** /**
* Builds a promise that is resolved when all the passed in promises are * Builds a promise that is resolved when all the passed in promises are
* resolved. * resolved.
* @param {array} array of data and/or promises to wait for. * @param {array} promises array of data and/or promises to wait for.
* @return {Promise} New dependant promise. * @return {Promise} New dependant promise.
*/ */
Promise.all = function Promise_all(promises) { Promise.all = function Promise_all(promises) {

View File

@ -38,7 +38,6 @@
PDFHistory.prototype = { PDFHistory.prototype = {
/** /**
* @param {string} fingerprint * @param {string} fingerprint
* @param {IPDFLinkService} linkService
*/ */
initialize: function pdfHistoryInitialize(fingerprint) { initialize: function pdfHistoryInitialize(fingerprint) {
this.initialized = true; this.initialized = true;

View File

@ -135,7 +135,7 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() {
* Toggle the visibility of the subtree of an outline item. * Toggle the visibility of the subtree of an outline item.
* *
* @param {Element} root - the root of the outline (sub)tree. * @param {Element} root - the root of the outline (sub)tree.
* @param {boolean} state - whether to show the outline (sub)tree. If false, * @param {boolean} show - whether to show the outline (sub)tree. If false,
* the outline subtree rooted at |root| will be collapsed. * the outline subtree rooted at |root| will be collapsed.
* *
* @private * @private

View File

@ -170,7 +170,7 @@ var PDFThumbnailViewer = (function PDFThumbnailViewerClosure() {
}, },
/** /**
* @param {PDFPageView} pageView * @param {PDFThumbnailView} thumbView
* @returns {PDFPage} * @returns {PDFPage}
* @private * @private
*/ */