Function (anonymous_1) | |
---|---|
✓ Was called | var Checker = function() {··· StringChecker.apply(this, arguments); }; |
Function (anonymous_2) | |
---|---|
✓ Was called | Checker.prototype.configure = function(config) {··· StringChecker.prototype.configure.call(this, config); }; |
Function (anonymous_3) | |
---|---|
✓ Was called | Checker.prototype.execute = function() {··· var method = this._configuration.getFix() === true ? this.fixPath : this.checkPath; return method.apply(this, arguments); }; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var method = this._configuration.getFix() === true ? this.fixPath : this.checkPath; |
✓ Negative was returned (: ...) | var method = this._configuration.getFix() === true ? this.fixPath : this.checkPath; |
Function (anonymous_4) | |
---|---|
✓ Was called | Checker.prototype.checkFile = function(path) {··· if (this._configuration.isFileExcluded(path)) { return Vow.resolve(null); } return vowFs.read(path, 'utf8').then(function(data) { return this.checkString(data, path); }, this); }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._configuration.isFileExcluded(path)) {··· return Vow.resolve(null); } |
✓ Negative was executed (else) | }··· return vowFs.read(path, 'utf8').then(function(data) { |
Function (anonymous_5) | |
---|---|
✓ Was called | return vowFs.read(path, 'utf8').then(function(data) {··· return this.checkString(data, path); }, this); |
Function (anonymous_6) | |
---|---|
✓ Was called | Checker.prototype.fixFile = function(path) {··· if (this._configuration.isFileExcluded(path)) { return Vow.resolve(null); } return vowFs.read(path, 'utf8').then(function(data) { var result = this.fixString(data, path); return vowFs.write(path, result.output).then(function() { return result.errors; }); }, this); }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._configuration.isFileExcluded(path)) {··· return Vow.resolve(null); } |
✓ Negative was executed (else) | }··· return vowFs.read(path, 'utf8').then(function(data) { |
Function (anonymous_7) | |
---|---|
✓ Was called | return vowFs.read(path, 'utf8').then(function(data) {··· var result = this.fixString(data, path); return vowFs.write(path, result.output).then(function() { return result.errors; }); }, this); |
Function (anonymous_8) | |
---|---|
✓ Was called | return vowFs.write(path, result.output).then(function() {··· return result.errors; }); |
Function (anonymous_9) | |
---|---|
✓ Was called | Checker.prototype.extractFile = function(path) {··· if (this._configuration.isFileExcluded(path)) { return Vow.resolve(null); } if (!this._configuration.shouldExtractFile(path)) { return Vow.resolve(null); } return vowFs.read(path, 'utf8').then(function(data) { var result = extractJs(path, data); result.sources.forEach(function(script) { this.checkString(script.source, path).getErrorList().forEach(function(error) { error.line += script.line; error.column += script.offset; result.addError(error); }); }, this); return result.errors; }, this); }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._configuration.isFileExcluded(path)) {··· return Vow.resolve(null); } |
✓ Negative was executed (else) | }··· if (!this._configuration.shouldExtractFile(path)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._configuration.shouldExtractFile(path)) {··· return Vow.resolve(null); } |
✓ Negative was executed (else) | }··· return vowFs.read(path, 'utf8').then(function(data) { |
Function (anonymous_10) | |
---|---|
✓ Was called | return vowFs.read(path, 'utf8').then(function(data) {··· var result = extractJs(path, data); result.sources.forEach(function(script) { this.checkString(script.source, path).getErrorList().forEach(function(error) { error.line += script.line; error.column += script.offset; result.addError(error); }); }, this); return result.errors; }, this); |
Function (anonymous_11) | |
---|---|
✓ Was called | result.sources.forEach(function(script) {··· this.checkString(script.source, path).getErrorList().forEach(function(error) { error.line += script.line; error.column += script.offset; result.addError(error); }); }, this); |
Function (anonymous_12) | |
---|---|
✓ Was called | this.checkString(script.source, path).getErrorList().forEach(function(error) {··· error.line += script.line; error.column += script.offset; result.addError(error); }); |
Function (anonymous_13) | |
---|---|
✓ Was called | Checker.prototype.checkDirectory = function(path) {··· return this._processDirectory(path, this.checkFile.bind(this)); }; |
Function (anonymous_14) | |
---|---|
✓ Was called | Checker.prototype.checkPath = function(path) {··· return this._processPath(path, this.checkFile.bind(this)); }; |
Function (anonymous_15) | |
---|---|
✓ Was called | Checker.prototype.fixPath = function(path) {··· return this._processPath(path, this.fixFile.bind(this)); }; |
Function (anonymous_16) | |
---|---|
✓ Was called | Checker.prototype._processDirectory = function(path, fileHandler) {··· return vowFs.listDir(path).then(function(filenames) { return Vow.all(filenames.map(function(filename) { var fullname = path + '/' + filename; if (this._configuration.isFileExcluded(fullname)) { return []; } return vowFs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(fullname, fileHandler); } if (!this._configuration.hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } return fileHandler(fullname); }, this); }, this)).then(function(results) { return [].concat.apply([], results); }); }, this); }; |
Function (anonymous_17) | |
---|---|
✓ Was called | return vowFs.listDir(path).then(function(filenames) {··· return Vow.all(filenames.map(function(filename) { var fullname = path + '/' + filename; if (this._configuration.isFileExcluded(fullname)) { return []; } return vowFs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(fullname, fileHandler); } if (!this._configuration.hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } return fileHandler(fullname); }, this); }, this)).then(function(results) { return [].concat.apply([], results); }); }, this); |
Function (anonymous_18) | |
---|---|
✓ Was called | return Vow.all(filenames.map(function(filename) {··· var fullname = path + '/' + filename; if (this._configuration.isFileExcluded(fullname)) { return []; } return vowFs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(fullname, fileHandler); } if (!this._configuration.hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } return fileHandler(fullname); }, this); }, this)).then(function(results) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._configuration.isFileExcluded(fullname)) {··· return []; } |
✓ Negative was executed (else) | }··· return vowFs.stat(fullname).then(function(stat) { |
Function (anonymous_19) | |
---|---|
✓ Was called | return vowFs.stat(fullname).then(function(stat) {··· if (stat.isDirectory()) { return this._processDirectory(fullname, fileHandler); } if (!this._configuration.hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } return fileHandler(fullname); }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (stat.isDirectory()) {··· return this._processDirectory(fullname, fileHandler); } |
✓ Negative was executed (else) | }··· if (!this._configuration.hasCorrectExtension(fullname)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._configuration.hasCorrectExtension(fullname)) {··· if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } |
✓ Negative was executed (else) | }··· return fileHandler(fullname); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._configuration.shouldExtractFile(fullname)) {··· return []; } |
✓ Negative was executed (else) | }··· return this.extractFile(fullname); |
Function (anonymous_20) | |
---|---|
✓ Was called | }, this)).then(function(results) {··· return [].concat.apply([], results); }); |
Function (anonymous_21) | |
---|---|
✓ Was called | Checker.prototype._processPath = function(path, fileHandler) {··· path = path.replace(/\/$/, ''); return vowFs.exists(path).then(function(exists) { if (!exists) { throw new Error('Path ' + path + ' was not found.'); } return vowFs.stat(path).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(path, fileHandler); } return fileHandler(path).then(function(errors) { if (errors) { return [errors]; } return []; }); }, this); }, this); }; |
Function (anonymous_22) | |
---|---|
✓ Was called | return vowFs.exists(path).then(function(exists) {··· if (!exists) { throw new Error('Path ' + path + ' was not found.'); } return vowFs.stat(path).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(path, fileHandler); } return fileHandler(path).then(function(errors) { if (errors) { return [errors]; } return []; }); }, this); }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!exists) {··· throw new Error('Path ' + path + ' was not found.'); } |
✓ Negative was executed (else) | }··· return vowFs.stat(path).then(function(stat) { |
Function (anonymous_23) | |
---|---|
✓ Was called | return vowFs.stat(path).then(function(stat) {··· if (stat.isDirectory()) { return this._processDirectory(path, fileHandler); } return fileHandler(path).then(function(errors) { if (errors) { return [errors]; } return []; }); }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (stat.isDirectory()) {··· return this._processDirectory(path, fileHandler); } |
✓ Negative was executed (else) | }··· return fileHandler(path).then(function(errors) { |
Function (anonymous_24) | |
---|---|
✓ Was called | return fileHandler(path).then(function(errors) {··· if (errors) { return [errors]; } return []; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (errors) {··· return [errors]; } |
✓ Negative was executed (else) | }··· return []; |
Function (anonymous_25) | |
---|---|
✓ Was called | Checker.prototype.checkStdin = function() {··· return this._processStdin(this.checkString.bind(this)); }; |
Function (anonymous_26) | |
---|---|
✓ Was called | Checker.prototype.fixStdin = function() {··· return this._processStdin(this.fixString.bind(this)); }; |
Function (anonymous_27) | |
---|---|
✓ Was called | Checker.prototype._processStdin = function(stdinHandler) {··· var stdInput = []; var deferred = Vow.defer(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function(chunk) { stdInput.push(chunk); }); process.stdin.on('end', function() { deferred.resolve(stdinHandler(stdInput.join(''))); }); return deferred.promise(); }; |
Function (anonymous_28) | |
---|---|
✓ Was called | process.stdin.on('data', function(chunk) {··· stdInput.push(chunk); }); |
Function (anonymous_29) | |
---|---|
✓ Was called | process.stdin.on('end', function() {··· deferred.resolve(stdinHandler(stdInput.join(''))); }); |
Function (anonymous_30) | |
---|---|
✓ Was called | Checker.prototype._createConfiguration = function() {··· return new NodeConfiguration(); }; |
Function getInternalErrorMessage | |
---|---|
✓ Was called | function getInternalErrorMessage(rule, e) {··· return 'Error running rule ' + rule + ': ' + 'This is an issue with JSCS and not your codebase.\n' + 'Please file an issue (with the stack trace below) at: ' + 'https://github.com/jscs-dev/node-jscs/issues/new\n' + e.stack; } |
Function (anonymous_32) | |
---|---|
✓ Was called | var StringChecker = function() {··· this._configuredRules = []; this._errorsFound = 0; this._maxErrorsExceeded = false; this._configuration = this._createConfiguration(); this._configuration.registerDefaultPresets(); }; |
Function (anonymous_33) | |
---|---|
✓ Was called | registerRule: function(rule) {··· this._configuration.registerRule(rule); }, |
Function (anonymous_34) | |
---|---|
✓ Was called | registerDefaultRules: function() {··· this._configuration.registerDefaultRules(); }, |
Function (anonymous_35) | |
---|---|
✗ Was not called | getProcessedConfig: function() {··· return this._configuration.getProcessedConfig(); }, |
Function (anonymous_36) | |
---|---|
✓ Was called | configure: function(config) {··· this._configuration.load(config); this._configuredRules = this._configuration.getConfiguredRules(); this._maxErrors = this._configuration.getMaxErrors(); }, |
Function (anonymous_37) | |
---|---|
✓ Was called | checkString: function(source, filename) {··· filename = filename || 'input'; var file = this._createJsFileInstance(filename, source); var errors = new Errors(file); file.getParseErrors().forEach(function(parseError) { if (!this._maxErrorsExceeded) { this._addParseError(errors, parseError, file); } }, this); if (!file._program || file._program.firstChild.type === 'EOF') { return errors; } this._checkJsFile(file, errors); return errors; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | filename = filename || 'input'; |
✓ Was returned | filename = filename || 'input'; |
Function (anonymous_38) | |
---|---|
✓ Was called | file.getParseErrors().forEach(function(parseError) {··· if (!this._maxErrorsExceeded) { this._addParseError(errors, parseError, file); } }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._maxErrorsExceeded) {··· this._addParseError(errors, parseError, file); } |
✗ Negative was not executed (else) | }··· }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!file._program || file._program.firstChild.type === 'EOF') {··· return errors; } |
✓ Negative was executed (else) | }··· this._checkJsFile(file, errors); |
Branch LogicalExpression | |
✓ Was returned | if (!file._program || file._program.firstChild.type === 'EOF') { |
✗ Was not returned | if (!file._program || file._program.firstChild.type === 'EOF') { |
Function (anonymous_39) | |
---|---|
✓ Was called | _fixCommonError: function(error) {··· if (error.fix) { // "error.fixed = true" should go first, so rule can // decide for itself (with "error.fixed = false") // if it can fix this particular error error.fixed = true; error.fix(); } return !!error.fixed; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (error.fix) {··· // "error.fixed = true" should go first, so rule can // decide for itself (with "error.fixed = false") // if it can fix this particular error error.fixed = true; error.fix(); } |
✓ Negative was executed (else) | }··· return !!error.fixed; |
Function (anonymous_40) | |
---|---|
✓ Was called | _fixSpecificError: function(file, error) {··· var configuration = this.getConfiguration(); var instance = configuration.getConfiguredRule(error.rule); if (instance && instance._fix) { // "error.fixed = true" should go first, so rule can // decide for itself (with "error.fixed = false") // if it can fix this particular error error.fixed = true; instance._fix(file, error); } return !!error.fixed; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (instance && instance._fix) {··· // "error.fixed = true" should go first, so rule can // decide for itself (with "error.fixed = false") // if it can fix this particular error error.fixed = true; instance._fix(file, error); } |
✓ Negative was executed (else) | }··· return !!error.fixed; |
Branch LogicalExpression | |
✓ Was returned | if (instance && instance._fix) { |
✗ Was not returned | if (instance && instance._fix) { |
Function (anonymous_41) | |
---|---|
✓ Was called | _fixJsFile: function(file, errors) {··· errors.getErrorList().forEach(function(error) { if (error.fixed) { return; } try { // Try to apply fixes for common errors var isFixed = this._fixCommonError(error); // Apply specific fix if (!isFixed) { this._fixSpecificError(file, error); } } catch (e) { error.fixed = false; errors.add( getInternalErrorMessage(error.rule, e), file.getProgram() ); } }, this); }, |
Function (anonymous_42) | |
---|---|
✓ Was called | errors.getErrorList().forEach(function(error) {··· if (error.fixed) { return; } try { // Try to apply fixes for common errors var isFixed = this._fixCommonError(error); // Apply specific fix if (!isFixed) { this._fixSpecificError(file, error); } } catch (e) { error.fixed = false; errors.add( getInternalErrorMessage(error.rule, e), file.getProgram() ); } }, this); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (error.fixed) {··· return; } |
✓ Negative was executed (else) | }··· try { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!isFixed) {··· this._fixSpecificError(file, error); } |
✓ Negative was executed (else) | }··· } catch (e) { |
Function (anonymous_43) | |
---|---|
✓ Was called | _checkJsFile: function(file, errors) {··· if (this._maxErrorsExceeded) { return; } var errorFilter = this._configuration.getErrorFilter(); this._configuredRules.forEach(function(rule) { errors.setCurrentRule(rule.getOptionName()); try { rule.check(file, errors); } catch (e) { errors.setCurrentRule('internalError'); errors.add(getInternalErrorMessage(rule.getOptionName(), e), file.getProgram()); } }, this); this._configuration.getUnsupportedRuleNames().forEach(function(rulename) { errors.add('Unsupported rule: ' + rulename, file.getProgram()); }); var program = file.getProgram(); var tokenIndex = new TokenIndex(program.getFirstToken()); errors.calculateErrorLocations(tokenIndex); errors.filter(function(error) { if (error.element) { return tokenIndex.isRuleEnabled(error.rule, error.element); } else { return true; } }); // sort errors list to show errors as they appear in source errors.getErrorList().sort(function(a, b) { return (a.line - b.line) || (a.column - b.column); }); if (errorFilter) { errors.filter(errorFilter); } if (this.maxErrorsEnabled()) { if (this._maxErrors === -1 || this._maxErrors === null) { this._maxErrorsExceeded = false; } else { this._maxErrorsExceeded = this._errorsFound + errors.getErrorCount() > this._maxErrors; errors.stripErrorList(Math.max(0, this._maxErrors - this._errorsFound)); } } this._errorsFound += errors.getErrorCount(); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._maxErrorsExceeded) {··· return; } |
✓ Negative was executed (else) | }··· var errorFilter = this._configuration.getErrorFilter(); |
Function (anonymous_44) | |
---|---|
✓ Was called | this._configuredRules.forEach(function(rule) {··· errors.setCurrentRule(rule.getOptionName()); try { rule.check(file, errors); } catch (e) { errors.setCurrentRule('internalError'); errors.add(getInternalErrorMessage(rule.getOptionName(), e), file.getProgram()); } }, this); |
Function (anonymous_45) | |
---|---|
✓ Was called | this._configuration.getUnsupportedRuleNames().forEach(function(rulename) {··· errors.add('Unsupported rule: ' + rulename, file.getProgram()); }); |
Function (anonymous_46) | |
---|---|
✓ Was called | errors.filter(function(error) {··· if (error.element) { return tokenIndex.isRuleEnabled(error.rule, error.element); } else { return true; } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (error.element) {··· return tokenIndex.isRuleEnabled(error.rule, error.element); } else { |
✓ Negative was executed (else) | } else {··· return true; } |
Function (anonymous_47) | |
---|---|
✓ Was called | errors.getErrorList().sort(function(a, b) {··· return (a.line - b.line) || (a.column - b.column); }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | return (a.line - b.line) || (a.column - b.column); |
✓ Was returned | return (a.line - b.line) || (a.column - b.column); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (errorFilter) {··· errors.filter(errorFilter); } |
✓ Negative was executed (else) | }··· if (this.maxErrorsEnabled()) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this.maxErrorsEnabled()) {··· if (this._maxErrors === -1 || this._maxErrors === null) { this._maxErrorsExceeded = false; } else { this._maxErrorsExceeded = this._errorsFound + errors.getErrorCount() > this._maxErrors; errors.stripErrorList(Math.max(0, this._maxErrors - this._errorsFound)); } } |
✓ Negative was executed (else) | }··· this._errorsFound += errors.getErrorCount(); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (this._maxErrors === -1 || this._maxErrors === null) {··· this._maxErrorsExceeded = false; } else { |
✓ Negative was executed (else) | } else {··· this._maxErrorsExceeded = this._errorsFound + errors.getErrorCount() > this._maxErrors; errors.stripErrorList(Math.max(0, this._maxErrors - this._errorsFound)); } |
Branch LogicalExpression | |
✓ Was returned | if (this._maxErrors === -1 || this._maxErrors === null) { |
✗ Was not returned | if (this._maxErrors === -1 || this._maxErrors === null) { |
Function (anonymous_48) | |
---|---|
✓ Was called | _addParseError: function(errors, parseError, file) {··· if (this._maxErrorsExceeded) { return; } errors.add(parseError, file.getProgram()); if (this.maxErrorsEnabled()) { this._errorsFound += 1; this._maxErrorsExceeded = this._errorsFound >= this._maxErrors; } }, |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (this._maxErrorsExceeded) {··· return; } |
✓ Negative was executed (else) | }··· errors.add(parseError, file.getProgram()); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this.maxErrorsEnabled()) {··· this._errorsFound += 1; this._maxErrorsExceeded = this._errorsFound >= this._maxErrors; } |
✗ Negative was not executed (else) | }··· }, |
Function (anonymous_49) | |
---|---|
✓ Was called | _createJsFileInstance: function(filename, source) {··· return new JsFile({ filename: filename, source: source, es3: this._configuration.isES3Enabled() }); }, |
Function (anonymous_50) | |
---|---|
✓ Was called | fixString: function(source, filename) {··· filename = filename || 'input'; var file = this._createJsFileInstance(filename, source); var errors = new Errors(file); var parseErrors = file.getParseErrors(); if (parseErrors.length > 0) { parseErrors.forEach(function(parseError) { this._addParseError(errors, parseError, file); }, this); return {output: source, errors: errors}; } else { var attempt = 0; do { // Fill in errors list this._checkJsFile(file, errors); // Apply fixes this._fixJsFile(file, errors); var hasFixes = errors.getErrorList().some(function(err) { return err.fixed; }); if (!hasFixes) { break; } file = this._createJsFileInstance(filename, file.render()); errors = new Errors(file); attempt++; } while (attempt < MAX_FIX_ATTEMPTS); return {output: file.getSource(), errors: errors}; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | filename = filename || 'input'; |
✓ Was returned | filename = filename || 'input'; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parseErrors.length > 0) {··· parseErrors.forEach(function(parseError) { this._addParseError(errors, parseError, file); }, this); return {output: source, errors: errors}; } else { |
✓ Negative was executed (else) | } else {··· var attempt = 0; do { // Fill in errors list this._checkJsFile(file, errors); // Apply fixes this._fixJsFile(file, errors); var hasFixes = errors.getErrorList().some(function(err) { return err.fixed; }); if (!hasFixes) { break; } file = this._createJsFileInstance(filename, file.render()); errors = new Errors(file); attempt++; } while (attempt < MAX_FIX_ATTEMPTS); return {output: file.getSource(), errors: errors}; } |
Function (anonymous_51) | |
---|---|
✓ Was called | parseErrors.forEach(function(parseError) {··· this._addParseError(errors, parseError, file); }, this); |
Function (anonymous_52) | |
---|---|
✓ Was called | var hasFixes = errors.getErrorList().some(function(err) {··· return err.fixed; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!hasFixes) {··· break; } |
✓ Negative was executed (else) | }··· file = this._createJsFileInstance(filename, file.render()); |
Function (anonymous_53) | |
---|---|
✓ Was called | maxErrorsEnabled: function() {··· return this._maxErrors !== null && this._maxErrors !== -1; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | return this._maxErrors !== null && this._maxErrors !== -1; |
✓ Was returned | return this._maxErrors !== null && this._maxErrors !== -1; |
Function (anonymous_54) | |
---|---|
✓ Was called | maxErrorsExceeded: function() {··· return this._maxErrorsExceeded; }, |
Function (anonymous_55) | |
---|---|
✓ Was called | _createConfiguration: function() {··· return new Configuration(); }, |
Function (anonymous_56) | |
---|---|
✓ Was called | getConfiguration: function() {··· return this._configuration; } |
Function (anonymous_57) | |
---|---|
✓ Was called | var Errors = function(file) {··· this._errorList = []; this._file = file; this._currentRule = ''; /** * @type {TokenAssert} * @public */ this.assert = new TokenAssert(file); this.assert.on('error', this._addError.bind(this)); }; |
Function (anonymous_58) | |
---|---|
✓ Was called | add: function(message, element, offset) {··· if (message instanceof Error) { this._addParseError(message); return; } this._addError({ message: message, element: element, offset: offset }); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (message instanceof Error) {··· this._addParseError(message); return; } |
✓ Negative was executed (else) | }··· this._addError({ |
Function (anonymous_59) | |
---|---|
✓ Was called | cast: function(errorInfo) {··· this._addError(errorInfo); }, |
Function (anonymous_60) | |
---|---|
✓ Was called | _addParseError: function(errorInfo) {··· this._errorList.push({ filename: this._file.getFilename(), rule: 'parseError', message: errorInfo.message, line: errorInfo.loc ? errorInfo.loc.line : 1, column: errorInfo.loc ? errorInfo.loc.column : 0 }); }, |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | line: errorInfo.loc ? errorInfo.loc.line : 1, |
✓ Negative was returned (: ...) | line: errorInfo.loc ? errorInfo.loc.line : 1, |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | column: errorInfo.loc ? errorInfo.loc.column : 0 |
✓ Negative was returned (: ...) | column: errorInfo.loc ? errorInfo.loc.column : 0 |
Function (anonymous_61) | |
---|---|
✓ Was called | _addError: function(errorInfo) {··· this._errorList.push({ filename: this._file.getFilename(), rule: this._currentRule, message: this._prepareMessage(errorInfo), element: errorInfo.element, offset: errorInfo.offset, additional: errorInfo.additional, fixed: false, fix: errorInfo.fix }); }, |
Function (anonymous_62) | |
---|---|
✓ Was called | _prepareMessage: function(errorInfo) {··· var rule = errorInfo instanceof Error ? 'parseError' : this._currentRule; if (rule) { return rule + ': ' + errorInfo.message; } return errorInfo.message; }, |
Branch ConditionalExpression | |
---|---|
✗ Positive was not returned (? ...) | var rule = errorInfo instanceof Error ? 'parseError' : this._currentRule; |
✓ Negative was returned (: ...) | var rule = errorInfo instanceof Error ? 'parseError' : this._currentRule; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (rule) {··· return rule + ': ' + errorInfo.message; } |
✓ Negative was executed (else) | }··· return errorInfo.message; |
Function (anonymous_63) | |
---|---|
✓ Was called | getErrorList: function() {··· return this._errorList; }, |
Function (anonymous_64) | |
---|---|
✓ Was called | getFilename: function() {··· return this._file.getFilename(); }, |
Function (anonymous_65) | |
---|---|
✗ Was not called | isEmpty: function() {··· return this._errorList.length === 0; }, |
Function (anonymous_66) | |
---|---|
✗ Was not called | getValidationErrorCount: function() {··· return this._errorList.filter(function(error) { return error.rule !== 'parseError' && error.rule !== 'internalError'; }); }, |
Function (anonymous_67) | |
---|---|
✗ Was not called | return this._errorList.filter(function(error) {··· return error.rule !== 'parseError' && error.rule !== 'internalError'; }); |
Branch LogicalExpression | |
---|---|
✗ Was not returned | return error.rule !== 'parseError' && error.rule !== 'internalError'; |
✗ Was not returned | return error.rule !== 'parseError' && error.rule !== 'internalError'; |
Function (anonymous_68) | |
---|---|
✓ Was called | getErrorCount: function() {··· return this._errorList.length; }, |
Function (anonymous_69) | |
---|---|
✓ Was called | stripErrorList: function(length) {··· this._errorList.splice(length); }, |
Function (anonymous_70) | |
---|---|
✓ Was called | filter: function(filter) {··· this._errorList = this._errorList.filter(filter); }, |
Function (anonymous_71) | |
---|---|
✓ Was called | calculateErrorLocations: function(tokenIndex) {··· this._errorList.forEach(function(error) { var pos = Errors.getPosition(error, tokenIndex); error.line = pos.line; error.column = pos.column; }); }, |
Function (anonymous_72) | |
---|---|
✓ Was called | this._errorList.forEach(function(error) {··· var pos = Errors.getPosition(error, tokenIndex); error.line = pos.line; error.column = pos.column; }); |
Function (anonymous_73) | |
---|---|
✓ Was called | explainError: function(error, colorize) {··· var lineNumber = error.line - 1; var lines = this._file.getLines(); var result = [ renderLine(lineNumber, lines[lineNumber], colorize), renderPointer(error.column, colorize) ]; var i = lineNumber - 1; var linesAround = 2; while (i >= 0 && i >= (lineNumber - linesAround)) { result.unshift(renderLine(i, lines[i], colorize)); i--; } i = lineNumber + 1; while (i < lines.length && i <= (lineNumber + linesAround)) { result.push(renderLine(i, lines[i], colorize)); i++; } result.unshift(formatErrorMessage(error.message, this.getFilename(), colorize)); return result.join('\n'); }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | while (i >= 0 && i >= (lineNumber - linesAround)) { |
✓ Was returned | while (i >= 0 && i >= (lineNumber - linesAround)) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | while (i < lines.length && i <= (lineNumber + linesAround)) { |
✓ Was returned | while (i < lines.length && i <= (lineNumber + linesAround)) { |
Function (anonymous_74) | |
---|---|
✓ Was called | setCurrentRule: function(rule) {··· this._currentRule = rule; } |
Function formatErrorMessage | |
---|---|
✓ Was called | function formatErrorMessage(message, filename, colorize) {··· return (colorize ? chalk.bold(message) : message) + ' at ' + (colorize ? chalk.green(filename) : filename) + ' :'; } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return (colorize ? chalk.bold(message) : message) + |
✓ Negative was returned (: ...) | return (colorize ? chalk.bold(message) : message) + |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | (colorize ? chalk.green(filename) : filename) + ' :'; |
✓ Negative was returned (: ...) | (colorize ? chalk.green(filename) : filename) + ' :'; |
Function prependSpaces | |
---|---|
✓ Was called | function prependSpaces(s, len) {··· while (s.length < len) { s = ' ' + s; } return s; } |
Function renderLine | |
---|---|
✓ Was called | function renderLine(n, line, colorize) {··· // Convert tabs to spaces, so errors in code lines with tabs as indention symbol // could be correctly rendered, plus it will provide less verbose output line = line.replace(/\t/g, ' '); // "n + 1" to print lines in human way (counted from 1) var lineNumber = prependSpaces((n + 1).toString(), 5) + ' |'; return ' ' + (colorize ? chalk.grey(lineNumber) : lineNumber) + line; } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return ' ' + (colorize ? chalk.grey(lineNumber) : lineNumber) + line; |
✓ Negative was returned (: ...) | return ' ' + (colorize ? chalk.grey(lineNumber) : lineNumber) + line; |
Function renderPointer | |
---|---|
✓ Was called | function renderPointer(column, colorize) {··· var res = (new Array(column + 9)).join('-') + '^'; return colorize ? chalk.grey(res) : res; } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return colorize ? chalk.grey(res) : res; |
✓ Negative was returned (: ...) | return colorize ? chalk.grey(res) : res; |
Function (anonymous_79) | |
---|---|
✓ Was called | Errors.getPosition = function(error, tokenIndex) {··· var element = error.element; var offset = error.offset; var rule = error.rule; if (!element) { return EMPTY_POS; } if (offset === undefined) { // TODO: probably should be generalized if (rule === 'validateQuoteMarks') { offset = 0; } else if (element.getSourceCodeLength() === 1) { offset = 0; } else { offset = (element.getNewlineCount() === 0 && Math.ceil(element.getSourceCodeLength() / 2)) || 0; } } var pos = tokenIndex ? tokenIndex.getElementLoc(element) : element.getLoc().start; if (!pos) { return EMPTY_POS; } if (offset === 0) { return pos; } var newlineCount = element.getNewlineCount(); if (newlineCount > 0) { var code = element.getSourceCode(); LINE_SEPARATOR.lastIndex = 0; var lineOffset = 0; var match; var previousOffset = 0; var firstLineColumnOffset = pos.column; while ((match = LINE_SEPARATOR.exec(code)) !== null) { var currentOffset = match.index; if (offset <= currentOffset) { return { line: pos.line + lineOffset, column: firstLineColumnOffset + offset - previousOffset }; } previousOffset = currentOffset + match[0].length; firstLineColumnOffset = 0; lineOffset++; } return { line: pos.line + newlineCount, column: offset - previousOffset }; } else { return { line: pos.line, column: pos.column + offset }; } }; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!element) {··· return EMPTY_POS; } |
✓ Negative was executed (else) | }··· if (offset === undefined) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (offset === undefined) {··· // TODO: probably should be generalized if (rule === 'validateQuoteMarks') { offset = 0; } else if (element.getSourceCodeLength() === 1) { offset = 0; } else { offset = (element.getNewlineCount() === 0 && Math.ceil(element.getSourceCodeLength() / 2)) || 0; } } |
✗ Negative was not executed (else) | }··· var pos = tokenIndex ? tokenIndex.getElementLoc(element) : element.getLoc().start; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (rule === 'validateQuoteMarks') {··· offset = 0; } else if (element.getSourceCodeLength() === 1) { |
✓ Negative was executed (else) | } else if (element.getSourceCodeLength() === 1) {··· offset = 0; } else { offset = (element.getNewlineCount() === 0 && Math.ceil(element.getSourceCodeLength() / 2)) || 0; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (element.getSourceCodeLength() === 1) {··· offset = 0; } else { |
✓ Negative was executed (else) | } else {··· offset = (element.getNewlineCount() === 0 && Math.ceil(element.getSourceCodeLength() / 2)) || 0; } |
Branch LogicalExpression | |
---|---|
✗ Was not returned | offset = (element.getNewlineCount() === 0 && Math.ceil(element.getSourceCodeLength() / 2)) || 0; |
✓ Was returned | offset = (element.getNewlineCount() === 0 && Math.ceil(element.getSourceCodeLength() / 2)) || 0; |
Branch LogicalExpression | |
✓ Was returned | offset = (element.getNewlineCount() === 0 && Math.ceil(element.getSourceCodeLength() / 2)) || 0; |
✗ Was not returned | offset = (element.getNewlineCount() === 0 && Math.ceil(element.getSourceCodeLength() / 2)) || 0; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var pos = tokenIndex ? tokenIndex.getElementLoc(element) : element.getLoc().start; |
✓ Negative was returned (: ...) | var pos = tokenIndex ? tokenIndex.getElementLoc(element) : element.getLoc().start; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!pos) {··· return EMPTY_POS; } |
✓ Negative was executed (else) | }··· if (offset === 0) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (offset === 0) {··· return pos; } |
✓ Negative was executed (else) | }··· var newlineCount = element.getNewlineCount(); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (newlineCount > 0) {··· var code = element.getSourceCode(); LINE_SEPARATOR.lastIndex = 0; var lineOffset = 0; var match; var previousOffset = 0; var firstLineColumnOffset = pos.column; while ((match = LINE_SEPARATOR.exec(code)) !== null) { var currentOffset = match.index; if (offset <= currentOffset) { return { line: pos.line + lineOffset, column: firstLineColumnOffset + offset - previousOffset }; } previousOffset = currentOffset + match[0].length; firstLineColumnOffset = 0; lineOffset++; } return { line: pos.line + newlineCount, column: offset - previousOffset }; } else { |
✓ Negative was executed (else) | } else {··· return { line: pos.line, column: pos.column + offset }; } |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (offset <= currentOffset) {··· return { line: pos.line + lineOffset, column: firstLineColumnOffset + offset - previousOffset }; } |
✗ Negative was not executed (else) | }··· previousOffset = currentOffset + match[0].length; |
Function TokenAssert | |
---|---|
✓ Was called | function TokenAssert(file) {··· EventEmitter.call(this); this._file = file; } |
Function (anonymous_81) | |
---|---|
✓ Was called | TokenAssert.prototype.whitespaceBetween = function(options) {··· options.atLeast = 1; return this.spacesBetween(options); }; |
Function (anonymous_82) | |
---|---|
✓ Was called | TokenAssert.prototype.noWhitespaceBetween = function(options) {··· options.exactly = 0; return this.spacesBetween(options); }; |
Function (anonymous_83) | |
---|---|
✓ Was called | TokenAssert.prototype.spacesBetween = function(options) {··· var token = options.token; var nextToken = options.nextToken; var atLeast = options.atLeast; var atMost = options.atMost; var exactly = options.exactly; if (!token || !nextToken) { return false; } this._validateOptions(options); if (!options.disallowNewLine && !this._file.isOnTheSameLine(token, nextToken)) { return false; } // Only attempt to remove or add lines if there are no comments between the two nodes // as this prevents accidentally moving a valid token onto a line comment ed line var fixed = !options.token.getNextNonWhitespaceToken().isComment; var emitError = function(countPrefix, spaceCount) { var fix = function() { this._file.setWhitespaceBefore(nextToken, new Array(spaceCount + 1).join(' ')); }.bind(this); var msgPostfix = token.value + ' and ' + nextToken.value; if (!options.message) { if (exactly === 0) { // support noWhitespaceBetween options.message = 'Unexpected whitespace between ' + msgPostfix; } else if (exactly !== undefined) { // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } } this.emit('error', { message: options.message, element: token, offset: token.getSourceCodeLength(), fix: fixed ? fix : undefined }); }.bind(this); var spacesBetween = this._file.getDistanceBetween(token, nextToken); if (atLeast !== undefined && spacesBetween < atLeast) { emitError('at least', atLeast); return true; } if (atMost !== undefined && spacesBetween > atMost) { emitError('at most', atMost); return true; } if (exactly !== undefined && spacesBetween !== exactly) { emitError('exactly', exactly); return true; } return false; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!token || !nextToken) {··· return false; } |
✓ Negative was executed (else) | }··· this._validateOptions(options); |
Branch LogicalExpression | |
✓ Was returned | if (!token || !nextToken) { |
✓ Was returned | if (!token || !nextToken) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!options.disallowNewLine && !this._file.isOnTheSameLine(token, nextToken)) {··· return false; } |
✓ Negative was executed (else) | }··· // Only attempt to remove or add lines if there are no comments between the two nodes |
Branch LogicalExpression | |
✓ Was returned | if (!options.disallowNewLine && !this._file.isOnTheSameLine(token, nextToken)) { |
✓ Was returned | if (!options.disallowNewLine && !this._file.isOnTheSameLine(token, nextToken)) { |
Function (anonymous_84) | |
---|---|
✓ Was called | var emitError = function(countPrefix, spaceCount) {··· var fix = function() { this._file.setWhitespaceBefore(nextToken, new Array(spaceCount + 1).join(' ')); }.bind(this); var msgPostfix = token.value + ' and ' + nextToken.value; if (!options.message) { if (exactly === 0) { // support noWhitespaceBetween options.message = 'Unexpected whitespace between ' + msgPostfix; } else if (exactly !== undefined) { // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } } this.emit('error', { message: options.message, element: token, offset: token.getSourceCodeLength(), fix: fixed ? fix : undefined }); }.bind(this); |
Function (anonymous_85) | |
---|---|
✗ Was not called | var fix = function() {··· this._file.setWhitespaceBefore(nextToken, new Array(spaceCount + 1).join(' ')); }.bind(this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!options.message) {··· if (exactly === 0) { // support noWhitespaceBetween options.message = 'Unexpected whitespace between ' + msgPostfix; } else if (exactly !== undefined) { // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } } |
✓ Negative was executed (else) | }··· this.emit('error', { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exactly === 0) {··· // support noWhitespaceBetween options.message = 'Unexpected whitespace between ' + msgPostfix; } else if (exactly !== undefined) { |
✓ Negative was executed (else) | } else if (exactly !== undefined) {··· // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (exactly !== undefined) {··· // support whitespaceBetween (spaces option) options.message = spaceCount + ' spaces required between ' + msgPostfix; } else if (atLeast === 1 && atMost === undefined) { |
✓ Negative was executed (else) | } else if (atLeast === 1 && atMost === undefined) {··· // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (atLeast === 1 && atMost === undefined) {··· // support whitespaceBetween (no spaces option) options.message = 'Missing space between ' + msgPostfix; } else { |
✓ Negative was executed (else) | } else {··· options.message = countPrefix + ' ' + spaceCount + ' spaces required between ' + msgPostfix; } |
Branch LogicalExpression | |
✓ Was returned | } else if (atLeast === 1 && atMost === undefined) { |
✓ Was returned | } else if (atLeast === 1 && atMost === undefined) { |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | fix: fixed ? fix : undefined |
✓ Negative was returned (: ...) | fix: fixed ? fix : undefined |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (atLeast !== undefined && spacesBetween < atLeast) {··· emitError('at least', atLeast); return true; } |
✓ Negative was executed (else) | }··· if (atMost !== undefined && spacesBetween > atMost) { |
Branch LogicalExpression | |
✓ Was returned | if (atLeast !== undefined && spacesBetween < atLeast) { |
✓ Was returned | if (atLeast !== undefined && spacesBetween < atLeast) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (atMost !== undefined && spacesBetween > atMost) {··· emitError('at most', atMost); return true; } |
✓ Negative was executed (else) | }··· if (exactly !== undefined && spacesBetween !== exactly) { |
Branch LogicalExpression | |
✓ Was returned | if (atMost !== undefined && spacesBetween > atMost) { |
✓ Was returned | if (atMost !== undefined && spacesBetween > atMost) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exactly !== undefined && spacesBetween !== exactly) {··· emitError('exactly', exactly); return true; } |
✓ Negative was executed (else) | }··· return false; |
Branch LogicalExpression | |
✓ Was returned | if (exactly !== undefined && spacesBetween !== exactly) { |
✓ Was returned | if (exactly !== undefined && spacesBetween !== exactly) { |
Function (anonymous_86) | |
---|---|
✓ Was called | TokenAssert.prototype.indentation = function(options) {··· var token = options.token; var lineNumber = options.lineNumber; var actual = options.actual; var expected = options.expected; var indentChar = options.indentChar; if (actual === expected) { return false; } this.emit('error', { message: 'Expected indentation of ' + expected + ' characters', line: lineNumber, column: expected, fix: function() { var newWhitespace = (new Array(expected + 1)).join(indentChar); this._updateWhitespaceByLine(token, function(lines) { lines[lines.length - 1] = newWhitespace; return lines; }); if (token.isComment) { this._updateCommentWhitespace(token, indentChar, actual, expected); } }.bind(this) }); return true; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (actual === expected) {··· return false; } |
✓ Negative was executed (else) | }··· this.emit('error', { |
Function (anonymous_87) | |
---|---|
✓ Was called | fix: function() {··· var newWhitespace = (new Array(expected + 1)).join(indentChar); this._updateWhitespaceByLine(token, function(lines) { lines[lines.length - 1] = newWhitespace; return lines; }); if (token.isComment) { this._updateCommentWhitespace(token, indentChar, actual, expected); } }.bind(this) |
Function (anonymous_88) | |
---|---|
✓ Was called | this._updateWhitespaceByLine(token, function(lines) {··· lines[lines.length - 1] = newWhitespace; return lines; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (token.isComment) {··· this._updateCommentWhitespace(token, indentChar, actual, expected); } |
✗ Negative was not executed (else) | }··· }.bind(this) |
Function (anonymous_89) | |
---|---|
✓ Was called | TokenAssert.prototype._updateWhitespaceByLine = function(token, callback) {··· var lineBreak = this._file.getLineBreakStyle(); var lines = this._file.getWhitespaceBefore(token).split(/\r\n|\r|\n/); lines = callback(lines); this._file.setWhitespaceBefore(token, lines.join(lineBreak)); }; |
Function (anonymous_90) | |
---|---|
✓ Was called | TokenAssert.prototype._updateCommentWhitespace = function(token, indentChar, actual, expected) {··· var difference = expected - actual; var tokenLines = token.value.split(/\r\n|\r|\n/); var i = 1; if (difference >= 0) { var lineWhitespace = (new Array(difference + 1)).join(indentChar); for (; i < tokenLines.length; i++) { tokenLines[i] = tokenLines[i] === '' ? '' : lineWhitespace + tokenLines[i]; } } else { for (; i < tokenLines.length; i++) { tokenLines[i] = tokenLines[i].substring(-difference); } } var newComment = new Token('CommentBlock', tokenLines.join(this._file.getLineBreakStyle())); token.parentElement.replaceChild(newComment, token); }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (difference >= 0) {··· var lineWhitespace = (new Array(difference + 1)).join(indentChar); for (; i < tokenLines.length; i++) { tokenLines[i] = tokenLines[i] === '' ? '' : lineWhitespace + tokenLines[i]; } } else { |
✓ Negative was executed (else) | } else {··· for (; i < tokenLines.length; i++) { tokenLines[i] = tokenLines[i].substring(-difference); } } |
Branch ConditionalExpression | |
---|---|
✗ Positive was not returned (? ...) | tokenLines[i] = tokenLines[i] === '' ? '' : lineWhitespace + tokenLines[i]; |
✓ Negative was returned (: ...) | tokenLines[i] = tokenLines[i] === '' ? '' : lineWhitespace + tokenLines[i]; |
Function (anonymous_91) | |
---|---|
✓ Was called | TokenAssert.prototype.sameLine = function(options) {··· options.exactly = 0; return this.linesBetween(options); }; |
Function (anonymous_92) | |
---|---|
✓ Was called | TokenAssert.prototype.differentLine = function(options) {··· options.atLeast = 1; return this.linesBetween(options); }; |
Function (anonymous_93) | |
---|---|
✓ Was called | TokenAssert.prototype.linesBetween = function(options) {··· var token = options.token; var nextToken = options.nextToken; var atLeast = options.atLeast; var atMost = options.atMost; var exactly = options.exactly; if (!token || !nextToken) { return false; } this._validateOptions(options); // Only attempt to remove or add lines if there are no comments between the two nodes // as this prevents accidentally moving a valid token onto a line comment ed line var fixed = !options.token.getNextNonWhitespaceToken().isComment; var linesBetween = this._file.getLineCountBetween(token, nextToken); var emitError = function(countPrefix, lineCount) { var msgPrefix = token.value + ' and ' + nextToken.value; var fix = function() { this._augmentLineCount(options, lineCount); }.bind(this); if (!options.message) { if (exactly === 0) { // support sameLine options.message = msgPrefix + ' should be on the same line'; } else if (atLeast === 1 && atMost === undefined) { // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } } this.emit('error', { message: options.message, element: token, offset: token.getSourceCodeLength(), fix: fixed ? fix : undefined }); }.bind(this); if (atLeast !== undefined && linesBetween < atLeast) { emitError('at least', atLeast); return true; } if (atMost !== undefined && linesBetween > atMost) { emitError('at most', atMost); return true; } if (exactly !== undefined && linesBetween !== exactly) { emitError('exactly', exactly); return true; } return false; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!token || !nextToken) {··· return false; } |
✓ Negative was executed (else) | }··· this._validateOptions(options); |
Branch LogicalExpression | |
✓ Was returned | if (!token || !nextToken) { |
✓ Was returned | if (!token || !nextToken) { |
Function (anonymous_94) | |
---|---|
✓ Was called | var emitError = function(countPrefix, lineCount) {··· var msgPrefix = token.value + ' and ' + nextToken.value; var fix = function() { this._augmentLineCount(options, lineCount); }.bind(this); if (!options.message) { if (exactly === 0) { // support sameLine options.message = msgPrefix + ' should be on the same line'; } else if (atLeast === 1 && atMost === undefined) { // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } } this.emit('error', { message: options.message, element: token, offset: token.getSourceCodeLength(), fix: fixed ? fix : undefined }); }.bind(this); |
Function (anonymous_95) | |
---|---|
✓ Was called | var fix = function() {··· this._augmentLineCount(options, lineCount); }.bind(this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!options.message) {··· if (exactly === 0) { // support sameLine options.message = msgPrefix + ' should be on the same line'; } else if (atLeast === 1 && atMost === undefined) { // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } } |
✓ Negative was executed (else) | }··· this.emit('error', { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exactly === 0) {··· // support sameLine options.message = msgPrefix + ' should be on the same line'; } else if (atLeast === 1 && atMost === undefined) { |
✓ Negative was executed (else) | } else if (atLeast === 1 && atMost === undefined) {··· // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (atLeast === 1 && atMost === undefined) {··· // support differentLine options.message = msgPrefix + ' should be on different lines'; } else { |
✓ Negative was executed (else) | } else {··· // support linesBetween options.message = msgPrefix + ' should have ' + countPrefix + ' ' + lineCount + ' line(s) between them'; } |
Branch LogicalExpression | |
✓ Was returned | } else if (atLeast === 1 && atMost === undefined) { |
✓ Was returned | } else if (atLeast === 1 && atMost === undefined) { |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | fix: fixed ? fix : undefined |
✓ Negative was returned (: ...) | fix: fixed ? fix : undefined |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (atLeast !== undefined && linesBetween < atLeast) {··· emitError('at least', atLeast); return true; } |
✓ Negative was executed (else) | }··· if (atMost !== undefined && linesBetween > atMost) { |
Branch LogicalExpression | |
✓ Was returned | if (atLeast !== undefined && linesBetween < atLeast) { |
✓ Was returned | if (atLeast !== undefined && linesBetween < atLeast) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (atMost !== undefined && linesBetween > atMost) {··· emitError('at most', atMost); return true; } |
✓ Negative was executed (else) | }··· if (exactly !== undefined && linesBetween !== exactly) { |
Branch LogicalExpression | |
✓ Was returned | if (atMost !== undefined && linesBetween > atMost) { |
✓ Was returned | if (atMost !== undefined && linesBetween > atMost) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exactly !== undefined && linesBetween !== exactly) {··· emitError('exactly', exactly); return true; } |
✓ Negative was executed (else) | }··· return false; |
Branch LogicalExpression | |
✓ Was returned | if (exactly !== undefined && linesBetween !== exactly) { |
✓ Was returned | if (exactly !== undefined && linesBetween !== exactly) { |
Function (anonymous_96) | |
---|---|
✓ Was called | TokenAssert.prototype._validateOptions = function(options) {··· var token = options.token; var nextToken = options.nextToken; var atLeast = options.atLeast; var atMost = options.atMost; var exactly = options.exactly; if (token === nextToken) { throw new Error('You cannot specify the same token as both token and nextToken'); } if (atLeast === undefined && atMost === undefined && exactly === undefined) { throw new Error('You must specify at least one option'); } if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { throw new Error('You cannot specify atLeast or atMost with exactly'); } if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { throw new Error('atLeast and atMost are in conflict'); } }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (token === nextToken) {··· throw new Error('You cannot specify the same token as both token and nextToken'); } |
✓ Negative was executed (else) | }··· if (atLeast === undefined && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | exactly === undefined) {··· throw new Error('You must specify at least one option'); } |
✓ Negative was executed (else) | }··· if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
Branch LogicalExpression | |
✓ Was returned | exactly === undefined) { |
✓ Was returned | if (atLeast === undefined &&··· atMost === undefined && |
Branch LogicalExpression | |
✓ Was returned | atMost === undefined && |
✓ Was returned | if (atLeast === undefined && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) {··· throw new Error('You cannot specify atLeast or atMost with exactly'); } |
✓ Negative was executed (else) | }··· if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
Branch LogicalExpression | |
✓ Was returned | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
✓ Was returned | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
Branch LogicalExpression | |
✓ Was returned | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
✓ Was returned | if (exactly !== undefined && (atLeast !== undefined || atMost !== undefined)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) {··· throw new Error('atLeast and atMost are in conflict'); } |
✓ Negative was executed (else) | }··· }; |
Branch LogicalExpression | |
✓ Was returned | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
✓ Was returned | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
Branch LogicalExpression | |
✓ Was returned | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
✓ Was returned | if (atLeast !== undefined && atMost !== undefined && atMost < atLeast) { |
Function (anonymous_97) | |
---|---|
✓ Was called | TokenAssert.prototype._augmentLineCount = function(options, lineCount) {··· var token = options.nextToken; if (lineCount === 0) { if (options.stickToPreviousToken) { var nextToken = this._file.getNextToken(token, { includeComments: true }); this._file.setWhitespaceBefore(nextToken, this._file.getWhitespaceBefore(token)); } this._file.setWhitespaceBefore(token, ' '); return; } this._updateWhitespaceByLine(token, function(lines) { var currentLineCount = lines.length; var lastLine = lines[lines.length - 1]; if (currentLineCount <= lineCount) { // add additional lines that maintain the same indentation as the former last line for (; currentLineCount <= lineCount; currentLineCount++) { lines[lines.length - 1] = ''; lines.push(lastLine); } } else { // remove lines and then ensure that the new last line maintains the previous indentation lines = lines.slice(0, lineCount + 1); lines[lines.length - 1] = lastLine; } return lines; }); }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lineCount === 0) {··· if (options.stickToPreviousToken) { var nextToken = this._file.getNextToken(token, { includeComments: true }); this._file.setWhitespaceBefore(nextToken, this._file.getWhitespaceBefore(token)); } this._file.setWhitespaceBefore(token, ' '); return; } |
✓ Negative was executed (else) | }··· this._updateWhitespaceByLine(token, function(lines) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.stickToPreviousToken) {··· var nextToken = this._file.getNextToken(token, { includeComments: true }); this._file.setWhitespaceBefore(nextToken, this._file.getWhitespaceBefore(token)); } |
✗ Negative was not executed (else) | }··· this._file.setWhitespaceBefore(token, ' '); |
Function (anonymous_98) | |
---|---|
✓ Was called | this._updateWhitespaceByLine(token, function(lines) {··· var currentLineCount = lines.length; var lastLine = lines[lines.length - 1]; if (currentLineCount <= lineCount) { // add additional lines that maintain the same indentation as the former last line for (; currentLineCount <= lineCount; currentLineCount++) { lines[lines.length - 1] = ''; lines.push(lastLine); } } else { // remove lines and then ensure that the new last line maintains the previous indentation lines = lines.slice(0, lineCount + 1); lines[lines.length - 1] = lastLine; } return lines; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentLineCount <= lineCount) {··· // add additional lines that maintain the same indentation as the former last line for (; currentLineCount <= lineCount; currentLineCount++) { lines[lines.length - 1] = ''; lines.push(lastLine); } } else { |
✓ Negative was executed (else) | } else {··· // remove lines and then ensure that the new last line maintains the previous indentation lines = lines.slice(0, lineCount + 1); lines[lines.length - 1] = lastLine; } |
Function (anonymous_99) | |
---|---|
✓ Was called | var JsFile = function(params) {··· params = params || {}; this._parseErrors = []; this._filename = params.filename; this._source = params.source; this._es3 = params.es3 || false; this._lineBreaks = null; this._lines = this._source.split(/\r\n|\r|\n/); var parser = new Parser({ strictMode: false, languageExtensions: { gritDirectives: true, appleInstrumentationDirectives: true } }); try { this._program = parser.parse(this._source); } catch (e) { this._parseErrors.push(e); this._program = new Program([ new Token('EOF', '') ]); } // Lazy initialization this._scopes = null; }; |
Branch LogicalExpression | |
---|---|
✗ Was not returned | params = params || {}; |
✓ Was returned | params = params || {}; |
Branch LogicalExpression | |
---|---|
✓ Was returned | this._es3 = params.es3 || false; |
✓ Was returned | this._es3 = params.es3 || false; |
Function (anonymous_100) | |
---|---|
✗ Was not called | getProgram: function() {··· return this._program; }, |
Function (anonymous_101) | |
---|---|
✓ Was called | getLineBreakStyle: function() {··· var lineBreaks = this.getLineBreaks(); return lineBreaks.length ? lineBreaks[0] : '\n'; }, |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return lineBreaks.length ? lineBreaks[0] : '\n'; |
✓ Negative was returned (: ...) | return lineBreaks.length ? lineBreaks[0] : '\n'; |
Function (anonymous_102) | |
---|---|
✓ Was called | getLineBreaks: function() {··· if (this._lineBreaks === null) { this._lineBreaks = this._source.match(/\r\n|\r|\n/g) || []; } return this._lineBreaks; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._lineBreaks === null) {··· this._lineBreaks = this._source.match(/\r\n|\r|\n/g) || []; } |
✓ Negative was executed (else) | }··· return this._lineBreaks; |
Branch LogicalExpression | |
---|---|
✓ Was returned | this._lineBreaks = this._source.match(/\r\n|\r|\n/g) || []; |
✓ Was returned | this._lineBreaks = this._source.match(/\r\n|\r|\n/g) || []; |
Function (anonymous_103) | |
---|---|
✓ Was called | setWhitespaceBefore: function(token, whitespace) {··· var prevToken = token.getPreviousToken(); var ws = new Token('Whitespace', whitespace); var fragment = new Fragment(ws); if (prevToken && prevToken.isWhitespace) { if (whitespace === '') { prevToken.remove(); return; } prevToken.parentElement.replaceChild(fragment, prevToken); return; } this._setTokenBefore(token, fragment); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken && prevToken.isWhitespace) {··· if (whitespace === '') { prevToken.remove(); return; } prevToken.parentElement.replaceChild(fragment, prevToken); return; } |
✓ Negative was executed (else) | }··· this._setTokenBefore(token, fragment); |
Branch LogicalExpression | |
✓ Was returned | if (prevToken && prevToken.isWhitespace) { |
✓ Was returned | if (prevToken && prevToken.isWhitespace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (whitespace === '') {··· prevToken.remove(); return; } |
✓ Negative was executed (else) | }··· prevToken.parentElement.replaceChild(fragment, prevToken); |
Function (anonymous_104) | |
---|---|
✓ Was called | _setTokenBefore: function(token, fragment) {··· var parent = token; var grandpa = parent.parentElement; while (grandpa) { try { grandpa.insertChildBefore(fragment, parent); break; } catch (e) {} parent = grandpa; grandpa = parent.parentElement; } }, |
Function (anonymous_105) | |
---|---|
✓ Was called | getWhitespaceBefore: function(token) {··· if (!token.getPreviousToken) { console.log(token); } var prev = token.getPreviousToken(); if (prev && prev.isWhitespace) { return prev.getSourceCode(); } return ''; }, |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!token.getPreviousToken) {··· console.log(token); } |
✓ Negative was executed (else) | }··· var prev = token.getPreviousToken(); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prev && prev.isWhitespace) {··· return prev.getSourceCode(); } |
✓ Negative was executed (else) | }··· return ''; |
Branch LogicalExpression | |
✓ Was returned | if (prev && prev.isWhitespace) { |
✓ Was returned | if (prev && prev.isWhitespace) { |
Function (anonymous_106) | |
---|---|
✓ Was called | getFirstNodeToken: function(node) {··· return node.getFirstToken(); }, |
Function (anonymous_107) | |
---|---|
✓ Was called | getLastNodeToken: function(node) {··· return node.getLastToken(); }, |
Function (anonymous_108) | |
---|---|
✓ Was called | getFirstToken: function(/*options*/) {··· return this._program.getFirstToken(); }, |
Function (anonymous_109) | |
---|---|
✓ Was called | getLastToken: function(/*options*/) {··· return this._program.getLastToken(); }, |
Function (anonymous_110) | |
---|---|
✓ Was called | getPrevToken: function(token, options) {··· if (options && options.includeComments) { return token.getPreviousNonWhitespaceToken(); } return token.getPreviousCodeToken(); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options && options.includeComments) {··· return token.getPreviousNonWhitespaceToken(); } |
✓ Negative was executed (else) | }··· return token.getPreviousCodeToken(); |
Branch LogicalExpression | |
✓ Was returned | if (options && options.includeComments) { |
✓ Was returned | if (options && options.includeComments) { |
Function (anonymous_111) | |
---|---|
✓ Was called | getNextToken: function(token, options) {··· if (options && options.includeComments) { return token.getNextNonWhitespaceToken(); } else { return token.getNextCodeToken(); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options && options.includeComments) {··· return token.getNextNonWhitespaceToken(); } else { |
✓ Negative was executed (else) | } else {··· return token.getNextCodeToken(); } |
Branch LogicalExpression | |
✓ Was returned | if (options && options.includeComments) { |
✓ Was returned | if (options && options.includeComments) { |
Function (anonymous_112) | |
---|---|
✓ Was called | findPrevToken: function(token, type, value) {··· var prevToken = this.getPrevToken(token); while (prevToken) { if (prevToken.type === type && (value === undefined || prevToken.value === value)) { return prevToken; } prevToken = this.getPrevToken(prevToken); } return prevToken; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.type === type && (value === undefined || prevToken.value === value)) {··· return prevToken; } |
✓ Negative was executed (else) | }··· prevToken = this.getPrevToken(prevToken); |
Branch LogicalExpression | |
✓ Was returned | if (prevToken.type === type && (value === undefined || prevToken.value === value)) { |
✓ Was returned | if (prevToken.type === type && (value === undefined || prevToken.value === value)) { |
Branch LogicalExpression | |
✓ Was returned | if (prevToken.type === type && (value === undefined || prevToken.value === value)) { |
✓ Was returned | if (prevToken.type === type && (value === undefined || prevToken.value === value)) { |
Function (anonymous_113) | |
---|---|
✓ Was called | findNextToken: function(token, type, value) {··· var nextToken = token.getNextToken(); while (nextToken) { if (nextToken.type === type && (value === undefined || nextToken.value === value)) { return nextToken; } nextToken = nextToken.getNextToken(); } return nextToken; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.type === type && (value === undefined || nextToken.value === value)) {··· return nextToken; } |
✓ Negative was executed (else) | }··· nextToken = nextToken.getNextToken(); |
Branch LogicalExpression | |
✓ Was returned | if (nextToken.type === type && (value === undefined || nextToken.value === value)) { |
✓ Was returned | if (nextToken.type === type && (value === undefined || nextToken.value === value)) { |
Branch LogicalExpression | |
✓ Was returned | if (nextToken.type === type && (value === undefined || nextToken.value === value)) { |
✓ Was returned | if (nextToken.type === type && (value === undefined || nextToken.value === value)) { |
Function (anonymous_114) | |
---|---|
✓ Was called | findPrevOperatorToken: function(token, value) {··· return this.findPrevToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); }, |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return this.findPrevToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); |
✓ Negative was returned (: ...) | return this.findPrevToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); |
Function (anonymous_115) | |
---|---|
✓ Was called | findNextOperatorToken: function(token, value) {··· return this.findNextToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); }, |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return this.findNextToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); |
✓ Negative was returned (: ...) | return this.findNextToken(token, value in KEYWORD_OPERATORS ? 'Keyword' : 'Punctuator', value); |
Function (anonymous_116) | |
---|---|
✓ Was called | iterate: function(cb, tree) {··· return treeIterator.iterate(tree || this._program, cb); }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | return treeIterator.iterate(tree || this._program, cb); |
✓ Was returned | return treeIterator.iterate(tree || this._program, cb); |
Function (anonymous_117) | |
---|---|
✓ Was called | getNodesByType: function(type) {··· type = Array.isArray(type) ? type : [type]; var result = []; for (var i = 0, l = type.length; i < l; i++) { var nodes = this._program.selectNodesByType(type[i]); if (nodes) { result = result.concat(nodes); } } return result; }, |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | type = Array.isArray(type) ? type : [type]; |
✓ Negative was returned (: ...) | type = Array.isArray(type) ? type : [type]; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nodes) {··· result = result.concat(nodes); } |
✗ Negative was not executed (else) | }··· } |
Function (anonymous_118) | |
---|---|
✓ Was called | iterateNodesByType: function(type, cb, context) {··· return this.getNodesByType(type).forEach(cb, context || this); }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | return this.getNodesByType(type).forEach(cb, context || this); |
✗ Was not returned | return this.getNodesByType(type).forEach(cb, context || this); |
Function (anonymous_119) | |
---|---|
✓ Was called | iterateTokensByType: function(type, cb) {··· var tokens; if (Array.isArray(type)) { tokens = []; for (var i = 0; i < type.length; i++) { var items = this._program.selectTokensByType(type[i]); tokens = tokens.concat(items); } } else { tokens = this._program.selectTokensByType(type); } tokens.forEach(cb); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Array.isArray(type)) {··· tokens = []; for (var i = 0; i < type.length; i++) { var items = this._program.selectTokensByType(type[i]); tokens = tokens.concat(items); } } else { |
✓ Negative was executed (else) | } else {··· tokens = this._program.selectTokensByType(type); } |
Function (anonymous_120) | |
---|---|
✓ Was called | iterateTokensByTypeAndValue: function(type, value, cb) {··· var values = (typeof value === 'string') ? [value] : value; var valueIndex = {}; values.forEach(function(type) { valueIndex[type] = true; }); this.iterateTokensByType(type, function(token) { if (valueIndex[token.value]) { cb(token); } }); }, |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var values = (typeof value === 'string') ? [value] : value; |
✓ Negative was returned (: ...) | var values = (typeof value === 'string') ? [value] : value; |
Function (anonymous_121) | |
---|---|
✓ Was called | values.forEach(function(type) {··· valueIndex[type] = true; }); |
Function (anonymous_122) | |
---|---|
✓ Was called | this.iterateTokensByType(type, function(token) {··· if (valueIndex[token.value]) { cb(token); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (valueIndex[token.value]) {··· cb(token); } |
✗ Negative was not executed (else) | }··· }); |
Function (anonymous_123) | |
---|---|
✗ Was not called | getFirstTokenOnLineWith: function(element, options) {··· options = options || {}; var firstToken = element; if (element.isComment && !options.includeComments) { firstToken = null; } if (element.isWhitespace && !options.includeWhitespace) { firstToken = null; } var currentToken = element.getPreviousToken(); while (currentToken) { if (currentToken.isWhitespace) { if (currentToken.getNewlineCount() > 0 || !currentToken.getPreviousToken()) { if (options.includeWhitespace) { firstToken = currentToken; } break; } } else if (currentToken.isComment) { if (options.includeComments) { firstToken = currentToken; break; } if (currentToken.getNewlineCount() > 0) { break; } } else { firstToken = currentToken; } currentToken = currentToken.getPreviousToken(); } if (firstToken) { return firstToken; } currentToken = element.getNextToken(); while (currentToken) { if (currentToken.isWhitespace) { if (currentToken.getNewlineCount() > 0 || !currentToken.getNextToken()) { if (options.includeWhitespace) { firstToken = currentToken; } break; } } else if (currentToken.isComment) { if (options.includeComments) { firstToken = currentToken; break; } if (currentToken.getNewlineCount() > 0) { break; } } else { firstToken = currentToken; } currentToken = currentToken.getNextToken(); } return firstToken; }, |
Branch LogicalExpression | |
---|---|
✗ Was not returned | options = options || {}; |
✗ Was not returned | options = options || {}; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (element.isComment && !options.includeComments) {··· firstToken = null; } |
✗ Negative was not executed (else) | }··· if (element.isWhitespace && !options.includeWhitespace) { |
Branch LogicalExpression | |
✗ Was not returned | if (element.isComment && !options.includeComments) { |
✗ Was not returned | if (element.isComment && !options.includeComments) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (element.isWhitespace && !options.includeWhitespace) {··· firstToken = null; } |
✗ Negative was not executed (else) | }··· var currentToken = element.getPreviousToken(); |
Branch LogicalExpression | |
✗ Was not returned | if (element.isWhitespace && !options.includeWhitespace) { |
✗ Was not returned | if (element.isWhitespace && !options.includeWhitespace) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken.isWhitespace) {··· if (currentToken.getNewlineCount() > 0 || !currentToken.getPreviousToken()) { if (options.includeWhitespace) { firstToken = currentToken; } break; } } else if (currentToken.isComment) { |
✗ Negative was not executed (else) | } else if (currentToken.isComment) {··· if (options.includeComments) { firstToken = currentToken; break; } if (currentToken.getNewlineCount() > 0) { break; } } else { firstToken = currentToken; } |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken.getNewlineCount() > 0 || !currentToken.getPreviousToken()) {··· if (options.includeWhitespace) { firstToken = currentToken; } break; } |
✗ Negative was not executed (else) | }··· } else if (currentToken.isComment) { |
Branch LogicalExpression | |
✗ Was not returned | if (currentToken.getNewlineCount() > 0 || !currentToken.getPreviousToken()) { |
✗ Was not returned | if (currentToken.getNewlineCount() > 0 || !currentToken.getPreviousToken()) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (options.includeWhitespace) {··· firstToken = currentToken; } |
✗ Negative was not executed (else) | }··· break; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | } else if (currentToken.isComment) {··· if (options.includeComments) { firstToken = currentToken; break; } if (currentToken.getNewlineCount() > 0) { break; } } else { |
✗ Negative was not executed (else) | } else {··· firstToken = currentToken; } |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (options.includeComments) {··· firstToken = currentToken; break; } |
✗ Negative was not executed (else) | }··· if (currentToken.getNewlineCount() > 0) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken.getNewlineCount() > 0) {··· break; } |
✗ Negative was not executed (else) | }··· } else { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (firstToken) {··· return firstToken; } |
✗ Negative was not executed (else) | }··· currentToken = element.getNextToken(); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken.isWhitespace) {··· if (currentToken.getNewlineCount() > 0 || !currentToken.getNextToken()) { if (options.includeWhitespace) { firstToken = currentToken; } break; } } else if (currentToken.isComment) { |
✗ Negative was not executed (else) | } else if (currentToken.isComment) {··· if (options.includeComments) { firstToken = currentToken; break; } if (currentToken.getNewlineCount() > 0) { break; } } else { firstToken = currentToken; } |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken.getNewlineCount() > 0 || !currentToken.getNextToken()) {··· if (options.includeWhitespace) { firstToken = currentToken; } break; } |
✗ Negative was not executed (else) | }··· } else if (currentToken.isComment) { |
Branch LogicalExpression | |
✗ Was not returned | if (currentToken.getNewlineCount() > 0 || !currentToken.getNextToken()) { |
✗ Was not returned | if (currentToken.getNewlineCount() > 0 || !currentToken.getNextToken()) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (options.includeWhitespace) {··· firstToken = currentToken; } |
✗ Negative was not executed (else) | }··· break; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | } else if (currentToken.isComment) {··· if (options.includeComments) { firstToken = currentToken; break; } if (currentToken.getNewlineCount() > 0) { break; } } else { |
✗ Negative was not executed (else) | } else {··· firstToken = currentToken; } |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (options.includeComments) {··· firstToken = currentToken; break; } |
✗ Negative was not executed (else) | }··· if (currentToken.getNewlineCount() > 0) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken.getNewlineCount() > 0) {··· break; } |
✗ Negative was not executed (else) | }··· } else { |
Function (anonymous_124) | |
---|---|
✓ Was called | getLastTokenOnLine: function(lineNumber, options) {··· options = options || {}; var loc; var token = this._program.getLastToken(); var currentToken; while (token) { loc = token.getLoc(); currentToken = token; token = token.getPreviousToken(); if (loc.start.line <= lineNumber && loc.end.line >= lineNumber) { // Since whitespace tokens can contain newlines we need to check // if position is in the range, not exact match if (currentToken.isWhitespace && !options.includeWhitespace) { continue; } } if (loc.start.line === lineNumber || loc.end.line === lineNumber) { if (currentToken.isComment && !options.includeComments) { continue; } return currentToken; } } return null; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options = options || {}; |
✓ Was returned | options = options || {}; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (loc.start.line <= lineNumber && loc.end.line >= lineNumber) {··· // Since whitespace tokens can contain newlines we need to check // if position is in the range, not exact match if (currentToken.isWhitespace && !options.includeWhitespace) { continue; } } |
✓ Negative was executed (else) | }··· if (loc.start.line === lineNumber || loc.end.line === lineNumber) { |
Branch LogicalExpression | |
✓ Was returned | if (loc.start.line <= lineNumber && loc.end.line >= lineNumber) { |
✓ Was returned | if (loc.start.line <= lineNumber && loc.end.line >= lineNumber) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken.isWhitespace && !options.includeWhitespace) {··· continue; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (currentToken.isWhitespace && !options.includeWhitespace) { |
✓ Was returned | if (currentToken.isWhitespace && !options.includeWhitespace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (loc.start.line === lineNumber || loc.end.line === lineNumber) {··· if (currentToken.isComment && !options.includeComments) { continue; } return currentToken; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (loc.start.line === lineNumber || loc.end.line === lineNumber) { |
✓ Was returned | if (loc.start.line === lineNumber || loc.end.line === lineNumber) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken.isComment && !options.includeComments) {··· continue; } |
✓ Negative was executed (else) | }··· return currentToken; |
Branch LogicalExpression | |
✓ Was returned | if (currentToken.isComment && !options.includeComments) { |
✓ Was returned | if (currentToken.isComment && !options.includeComments) { |
Function (anonymous_125) | |
---|---|
✓ Was called | getDialect: function() {··· if (this._es3) { return 'es3'; } return 'es6'; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._es3) {··· return 'es3'; } |
✓ Negative was executed (else) | }··· return 'es6'; |
Function (anonymous_126) | |
---|---|
✓ Was called | getSource: function() {··· return this._source; }, |
Function (anonymous_127) | |
---|---|
✓ Was called | getTree: function() {··· return this._program || {}; }, |
Branch LogicalExpression | |
---|---|
✗ Was not returned | return this._program || {}; |
✓ Was returned | return this._program || {}; |
Function (anonymous_128) | |
---|---|
✓ Was called | getComments: function() {··· var comments = []; var token = this._program.getFirstToken(); while (token) { if (token.isComment) { comments[comments.length] = token; } token = token.getNextToken(); } return comments; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (token.isComment) {··· comments[comments.length] = token; } |
✓ Negative was executed (else) | }··· token = token.getNextToken(); |
Function (anonymous_129) | |
---|---|
✓ Was called | getFilename: function() {··· return this._filename; }, |
Function (anonymous_130) | |
---|---|
✓ Was called | getLines: function() {··· return this._lines; }, |
Function (anonymous_131) | |
---|---|
✓ Was called | getScopes: function() {··· if (!this._scopes) { this._scopes = new ScopesApi(this._program); } return this._scopes; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._scopes) {··· this._scopes = new ScopesApi(this._program); } |
✗ Negative was not executed (else) | }··· return this._scopes; |
Function (anonymous_132) | |
---|---|
✗ Was not called | isOnTheSameLine: function(tokenBefore, tokenAfter) {··· if (tokenBefore === tokenAfter) { return true; } tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); tokenAfter = tokenAfter instanceof Token ? tokenAfter : tokenAfter.getFirstToken(); var currentToken = tokenBefore; while (currentToken) { if (currentToken === tokenAfter) { return true; } if (currentToken !== tokenBefore && currentToken.getNewlineCount() > 0) { return false; } currentToken = currentToken.getNextToken(); } return false; }, |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (tokenBefore === tokenAfter) {··· return true; } |
✗ Negative was not executed (else) | }··· tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); |
Branch ConditionalExpression | |
---|---|
✗ Positive was not returned (? ...) | tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); |
✗ Negative was not returned (: ...) | tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); |
Branch ConditionalExpression | |
---|---|
✗ Positive was not returned (? ...) | tokenAfter = tokenAfter instanceof Token ? tokenAfter : tokenAfter.getFirstToken(); |
✗ Negative was not returned (: ...) | tokenAfter = tokenAfter instanceof Token ? tokenAfter : tokenAfter.getFirstToken(); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken === tokenAfter) {··· return true; } |
✗ Negative was not executed (else) | }··· if (currentToken !== tokenBefore && currentToken.getNewlineCount() > 0) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken !== tokenBefore && currentToken.getNewlineCount() > 0) {··· return false; } |
✗ Negative was not executed (else) | }··· currentToken = currentToken.getNextToken(); |
Branch LogicalExpression | |
✗ Was not returned | if (currentToken !== tokenBefore && currentToken.getNewlineCount() > 0) { |
✗ Was not returned | if (currentToken !== tokenBefore && currentToken.getNewlineCount() > 0) { |
Function (anonymous_133) | |
---|---|
✗ Was not called | getDistanceBetween: function(tokenBefore, tokenAfter) {··· if (tokenBefore === tokenAfter) { return 0; } tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); tokenAfter = tokenAfter instanceof Token ? tokenAfter : tokenAfter.getFirstToken(); var currentToken = tokenBefore.getNextToken(); var distance = 0; while (currentToken) { if (currentToken === tokenAfter) { break; } distance += currentToken.getSourceCodeLength(); currentToken = currentToken.getNextToken(); } return distance; }, |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (tokenBefore === tokenAfter) {··· return 0; } |
✗ Negative was not executed (else) | }··· tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); |
Branch ConditionalExpression | |
---|---|
✗ Positive was not returned (? ...) | tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); |
✗ Negative was not returned (: ...) | tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); |
Branch ConditionalExpression | |
---|---|
✗ Positive was not returned (? ...) | tokenAfter = tokenAfter instanceof Token ? tokenAfter : tokenAfter.getFirstToken(); |
✗ Negative was not returned (: ...) | tokenAfter = tokenAfter instanceof Token ? tokenAfter : tokenAfter.getFirstToken(); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken === tokenAfter) {··· break; } |
✗ Negative was not executed (else) | }··· distance += currentToken.getSourceCodeLength(); |
Function (anonymous_134) | |
---|---|
✗ Was not called | getLineCountBetween: function(tokenBefore, tokenAfter) {··· if (tokenBefore === tokenAfter) { return 0; } tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); tokenAfter = tokenAfter instanceof Token ? tokenAfter : tokenAfter.getFirstToken(); var currentToken = tokenBefore.getNextToken(); var lineCount = 0; while (currentToken) { if (currentToken === tokenAfter) { break; } lineCount += currentToken.getNewlineCount(); currentToken = currentToken.getNextToken(); } return lineCount; }, |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (tokenBefore === tokenAfter) {··· return 0; } |
✗ Negative was not executed (else) | }··· tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); |
Branch ConditionalExpression | |
---|---|
✗ Positive was not returned (? ...) | tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); |
✗ Negative was not returned (: ...) | tokenBefore = tokenBefore instanceof Token ? tokenBefore : tokenBefore.getLastToken(); |
Branch ConditionalExpression | |
---|---|
✗ Positive was not returned (? ...) | tokenAfter = tokenAfter instanceof Token ? tokenAfter : tokenAfter.getFirstToken(); |
✗ Negative was not returned (: ...) | tokenAfter = tokenAfter instanceof Token ? tokenAfter : tokenAfter.getFirstToken(); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentToken === tokenAfter) {··· break; } |
✗ Negative was not executed (else) | }··· lineCount += currentToken.getNewlineCount(); |
Function (anonymous_135) | |
---|---|
✓ Was called | getLinesWithCommentsRemoved: function() {··· var lines = this.getLines().concat(); this.getComments().concat().reverse().forEach(function(comment) { var loc = comment.getLoc(); var startLine = loc.start.line; var startCol = loc.start.column; var endLine = loc.end.line; var endCol = loc.end.column; var i = startLine - 1; if (startLine === endLine) { // Remove tralling spaces (see gh-1968) lines[i] = lines[i].replace(/\*\/\s+/, '\*\/'); lines[i] = lines[i].substring(0, startCol) + lines[i].substring(endCol); } else { lines[i] = lines[i].substring(0, startCol); for (var x = i + 1; x < endLine - 1; x++) { lines[x] = ''; } lines[x] = lines[x].substring(endCol); } }); return lines; }, |
Function (anonymous_136) | |
---|---|
✓ Was called | this.getComments().concat().reverse().forEach(function(comment) {··· var loc = comment.getLoc(); var startLine = loc.start.line; var startCol = loc.start.column; var endLine = loc.end.line; var endCol = loc.end.column; var i = startLine - 1; if (startLine === endLine) { // Remove tralling spaces (see gh-1968) lines[i] = lines[i].replace(/\*\/\s+/, '\*\/'); lines[i] = lines[i].substring(0, startCol) + lines[i].substring(endCol); } else { lines[i] = lines[i].substring(0, startCol); for (var x = i + 1; x < endLine - 1; x++) { lines[x] = ''; } lines[x] = lines[x].substring(endCol); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (startLine === endLine) {··· // Remove tralling spaces (see gh-1968) lines[i] = lines[i].replace(/\*\/\s+/, '\*\/'); lines[i] = lines[i].substring(0, startCol) + lines[i].substring(endCol); } else { |
✓ Negative was executed (else) | } else {··· lines[i] = lines[i].substring(0, startCol); for (var x = i + 1; x < endLine - 1; x++) { lines[x] = ''; } lines[x] = lines[x].substring(endCol); } |
Function (anonymous_137) | |
---|---|
✓ Was called | render: function() {··· return this._program.getSourceCode(); }, |
Function (anonymous_138) | |
---|---|
✓ Was called | getParseErrors: function() {··· return this._parseErrors; } |
Function iterate | |
---|---|
✓ Was called | module.exports.iterate = function iterate(node, cb) {··· if ('type' in node) { estraverse.traverse(node, { enter: function(node, parent) { var parentCollection = []; // parentCollection support var path = this.path(); if (path) { var collectionKey; while (path.length > 0) { var pathElement = path.pop(); if (typeof pathElement === 'string') { collectionKey = pathElement; break; } } parentCollection = parent[collectionKey]; if (!Array.isArray(parentCollection)) { parentCollection = [parentCollection]; } } if (cb(node, parent, parentCollection) === false) { return estraverse.VisitorOption.Skip; } }, keys: VISITOR_KEYS }); } }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('type' in node) {··· estraverse.traverse(node, { enter: function(node, parent) { var parentCollection = []; // parentCollection support var path = this.path(); if (path) { var collectionKey; while (path.length > 0) { var pathElement = path.pop(); if (typeof pathElement === 'string') { collectionKey = pathElement; break; } } parentCollection = parent[collectionKey]; if (!Array.isArray(parentCollection)) { parentCollection = [parentCollection]; } } if (cb(node, parent, parentCollection) === false) { return estraverse.VisitorOption.Skip; } }, keys: VISITOR_KEYS }); } |
✓ Negative was executed (else) | }··· }; |
Function (anonymous_140) | |
---|---|
✓ Was called | enter: function(node, parent) {··· var parentCollection = []; // parentCollection support var path = this.path(); if (path) { var collectionKey; while (path.length > 0) { var pathElement = path.pop(); if (typeof pathElement === 'string') { collectionKey = pathElement; break; } } parentCollection = parent[collectionKey]; if (!Array.isArray(parentCollection)) { parentCollection = [parentCollection]; } } if (cb(node, parent, parentCollection) === false) { return estraverse.VisitorOption.Skip; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (path) {··· var collectionKey; while (path.length > 0) { var pathElement = path.pop(); if (typeof pathElement === 'string') { collectionKey = pathElement; break; } } parentCollection = parent[collectionKey]; if (!Array.isArray(parentCollection)) { parentCollection = [parentCollection]; } } |
✓ Negative was executed (else) | }··· if (cb(node, parent, parentCollection) === false) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof pathElement === 'string') {··· collectionKey = pathElement; break; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!Array.isArray(parentCollection)) {··· parentCollection = [parentCollection]; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (cb(node, parent, parentCollection) === false) {··· return estraverse.VisitorOption.Skip; } |
✓ Negative was executed (else) | }··· }, |
Function parseRuleNames | |
---|---|
✓ Was called | function parseRuleNames(text, enabled) {··· text = text.trim(); if (!text) { return {'*': enabled}; } return text.split(',').reduce(function(result, ruleName) { ruleName = ruleName.trim(); if (ruleName) { result[ruleName] = enabled; } return result; }, {}); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!text) {··· return {'*': enabled}; } |
✓ Negative was executed (else) | }··· return text.split(',').reduce(function(result, ruleName) { |
Function (anonymous_142) | |
---|---|
✓ Was called | return text.split(',').reduce(function(result, ruleName) {··· ruleName = ruleName.trim(); if (ruleName) { result[ruleName] = enabled; } return result; }, {}); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (ruleName) {··· result[ruleName] = enabled; } |
✓ Negative was executed (else) | }··· return result; |
Function TokenIndex | |
---|---|
✓ Was called | function TokenIndex(firstToken) {··· this._buildIndex(firstToken); } |
Function (anonymous_144) | |
---|---|
✓ Was called | TokenIndex.prototype._buildIndex = function(firstToken) {··· this._hasPragmas = false; var tokens = []; var index = []; var positions = []; var currentPosition = 0; var currentToken = firstToken; var lastBlockState = {'*': true}; var tokenState; var previousLoc = {line: 1, column: 0}; while (currentToken) { tokens.push(currentToken); currentToken.__loc = previousLoc; var newlineCount = currentToken.getNewlineCount(); if (newlineCount > 0) { var lines = currentToken.getSourceCodeLines(); previousLoc = { line: previousLoc.line + newlineCount, column: lines[lines.length - 1].length }; } else { previousLoc = { line: previousLoc.line, column: previousLoc.column + currentToken.getSourceCodeLength() }; } if (currentToken.isComment) { var value = currentToken.value; var blockMatch = BLOCK_REGEXP.exec(value); if (blockMatch) { this._hasPragmas = true; lastBlockState = assign({}, lastBlockState, parseRuleNames(blockMatch[2], blockMatch[1] === 'en')); tokenState = lastBlockState; } else { var lineMatch = LINE_REGEXP.exec(value); if (lineMatch) { this._hasPragmas = true; var ignoreState = parseRuleNames(lineMatch[1], false); index.push(null); var ignoreToken = currentToken.getPreviousToken(); var i = index.length - 1; while (ignoreToken) { i--; index[i] = assign({}, index[i], ignoreState); if (ignoreToken.getNewlineCount() > 0) { break; } ignoreToken = ignoreToken.getPreviousToken(); } ignoreToken = currentToken.getNextToken(); while (ignoreToken) { index.push(ignoreState); if (ignoreToken.getNewlineCount() > 0) { break; } ignoreToken = ignoreToken.getNextToken(); } tokenState = assign({}, lastBlockState, ignoreState); } else { tokenState = lastBlockState; } } } else { tokenState = lastBlockState; } if (index[currentPosition]) { tokenState = assign({}, tokenState, index[currentPosition]); } index[currentPosition] = tokenState; currentPosition++; currentToken = currentToken.getNextToken(); } this._tokens = tokens; this._index = index; this._positions = positions; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (newlineCount > 0) {··· var lines = currentToken.getSourceCodeLines(); previousLoc = { line: previousLoc.line + newlineCount, column: lines[lines.length - 1].length }; } else { |
✓ Negative was executed (else) | } else {··· previousLoc = { line: previousLoc.line, column: previousLoc.column + currentToken.getSourceCodeLength() }; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken.isComment) {··· var value = currentToken.value; var blockMatch = BLOCK_REGEXP.exec(value); if (blockMatch) { this._hasPragmas = true; lastBlockState = assign({}, lastBlockState, parseRuleNames(blockMatch[2], blockMatch[1] === 'en')); tokenState = lastBlockState; } else { var lineMatch = LINE_REGEXP.exec(value); if (lineMatch) { this._hasPragmas = true; var ignoreState = parseRuleNames(lineMatch[1], false); index.push(null); var ignoreToken = currentToken.getPreviousToken(); var i = index.length - 1; while (ignoreToken) { i--; index[i] = assign({}, index[i], ignoreState); if (ignoreToken.getNewlineCount() > 0) { break; } ignoreToken = ignoreToken.getPreviousToken(); } ignoreToken = currentToken.getNextToken(); while (ignoreToken) { index.push(ignoreState); if (ignoreToken.getNewlineCount() > 0) { break; } ignoreToken = ignoreToken.getNextToken(); } tokenState = assign({}, lastBlockState, ignoreState); } else { tokenState = lastBlockState; } } } else { |
✓ Negative was executed (else) | } else {··· tokenState = lastBlockState; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (blockMatch) {··· this._hasPragmas = true; lastBlockState = assign({}, lastBlockState, parseRuleNames(blockMatch[2], blockMatch[1] === 'en')); tokenState = lastBlockState; } else { |
✓ Negative was executed (else) | } else {··· var lineMatch = LINE_REGEXP.exec(value); if (lineMatch) { this._hasPragmas = true; var ignoreState = parseRuleNames(lineMatch[1], false); index.push(null); var ignoreToken = currentToken.getPreviousToken(); var i = index.length - 1; while (ignoreToken) { i--; index[i] = assign({}, index[i], ignoreState); if (ignoreToken.getNewlineCount() > 0) { break; } ignoreToken = ignoreToken.getPreviousToken(); } ignoreToken = currentToken.getNextToken(); while (ignoreToken) { index.push(ignoreState); if (ignoreToken.getNewlineCount() > 0) { break; } ignoreToken = ignoreToken.getNextToken(); } tokenState = assign({}, lastBlockState, ignoreState); } else { tokenState = lastBlockState; } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lineMatch) {··· this._hasPragmas = true; var ignoreState = parseRuleNames(lineMatch[1], false); index.push(null); var ignoreToken = currentToken.getPreviousToken(); var i = index.length - 1; while (ignoreToken) { i--; index[i] = assign({}, index[i], ignoreState); if (ignoreToken.getNewlineCount() > 0) { break; } ignoreToken = ignoreToken.getPreviousToken(); } ignoreToken = currentToken.getNextToken(); while (ignoreToken) { index.push(ignoreState); if (ignoreToken.getNewlineCount() > 0) { break; } ignoreToken = ignoreToken.getNextToken(); } tokenState = assign({}, lastBlockState, ignoreState); } else { |
✓ Negative was executed (else) | } else {··· tokenState = lastBlockState; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (ignoreToken.getNewlineCount() > 0) {··· break; } |
✓ Negative was executed (else) | }··· ignoreToken = ignoreToken.getPreviousToken(); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (ignoreToken.getNewlineCount() > 0) {··· break; } |
✓ Negative was executed (else) | }··· ignoreToken = ignoreToken.getNextToken(); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (index[currentPosition]) {··· tokenState = assign({}, tokenState, index[currentPosition]); } |
✓ Negative was executed (else) | }··· index[currentPosition] = tokenState; |
Function (anonymous_145) | |
---|---|
✓ Was called | TokenIndex.prototype.isRuleEnabled = function(ruleName, element) {··· if (!this._hasPragmas) { return true; } var pos = this._tokens.indexOf(element.getFirstToken()); if (pos !== -1) { var state = this._index[pos]; if (ruleName in state) { return state[ruleName]; } return state['*']; } return true; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._hasPragmas) {··· return true; } |
✓ Negative was executed (else) | }··· var pos = this._tokens.indexOf(element.getFirstToken()); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (pos !== -1) {··· var state = this._index[pos]; if (ruleName in state) { return state[ruleName]; } return state['*']; } |
✗ Negative was not executed (else) | }··· return true; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (ruleName in state) {··· return state[ruleName]; } |
✓ Negative was executed (else) | }··· return state['*']; |
Function (anonymous_146) | |
---|---|
✗ Was not called | TokenIndex.prototype.getElementLoc = function(element) {··· return element.getFirstToken().__loc || { line: 1, column: 0 }; }; |
Branch LogicalExpression | |
---|---|
✗ Was not returned | return element.getFirstToken().__loc || {··· line: 1, column: 0 }; |
✗ Was not returned | return element.getFirstToken().__loc || { |
Function Configuration | |
---|---|
✓ Was called | function Configuration() {··· /** * List of the registered (not used) presets. * * @protected * @type {Object} */ this._presets = {}; /** * Name of the preset (if used). * * @protected * @type {String|null} */ this._presetName = null; /** * List of loaded presets. * * @protected * @type {String|null} */ this._loadedPresets = []; /** * List of rules instances. * * @protected * @type {Object} */ this._rules = {}; /** * List of configurated rule instances. * * @protected * @type {Object} */ this._ruleSettings = {}; /** * List of configured rules. * * @protected * @type {Array} */ this._configuredRules = []; /** * List of unsupported rules. * * @protected * @type {Array} */ this._unsupportedRuleNames = []; /** * File extensions that would be checked. * * @protected * @type {Array} */ this._fileExtensions = []; /** * List of defined options (not complete). * * @protected * @type {Array} */ this._definedOptions = []; /** * Default file extensions that would be checked. * * @protected * @type {Array} */ this._defaultFileExtensions = ['.js']; /** * Exclusion masks. * * @protected * @type {Array} */ this._excludedFileMasks = []; /** * Default exclusion masks, will be rewritten if user has their own masks. * * @protected * @type {Array} */ this._defaultExcludedFileMasks = ['.git/**', 'node_modules/**']; /** * List of existing files that falls under exclusion masks. * * @protected * @type {Array} */ this._excludedFileMatchers = []; /** * Extraction masks. * * @protected * @type {Array} */ this._extractFileMasks = []; /** * Default extractions masks. * * @protected * @type {Array} */ this._defaultExtractFileMasks = ['**/*.+(htm|html|xhtml)']; /** * List of file matchers from which to extract JavaScript. * * @protected * @type {Array} */ this._extractFileMatchers = []; /** * Maxixum amount of error that would be reportered. * * @protected * @type {Number} */ this._maxErrors = defaults.maxErrors; /** * JSCS CWD. * * @protected * @type {String} */ this._basePath = defaults.cwd; /** * List of overrided options (usually from CLI). * * @protected * @type {Object} */ this._overrides = {}; /** * Is "ES3" mode enabled?. * * @protected * @type {Boolean} */ this._es3Enabled = false; /** * A filter function that determines whether or not to report an error. * * @protected * @type {Function|null} */ this._errorFilter = null; } |
Function (anonymous_148) | |
---|---|
✓ Was called | Configuration.prototype.load = function(config) {··· // Load all the options this._processConfig(config); // Load defaults if they weren't set this._loadDefaults(config); // Load and apply all the rules this._useRules(); }; |
Function (anonymous_149) | |
---|---|
✓ Was called | Configuration.prototype._loadDefaults = function() {··· if (!this._isDefined('excludeFiles')) { this._loadExcludedFiles(this._defaultExcludedFileMasks); } if (!this._isDefined('fileExtensions')) { this._loadFileExtensions(this._defaultFileExtensions); } }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('excludeFiles')) {··· this._loadExcludedFiles(this._defaultExcludedFileMasks); } |
✓ Negative was executed (else) | }··· if (!this._isDefined('fileExtensions')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('fileExtensions')) {··· this._loadFileExtensions(this._defaultFileExtensions); } |
✓ Negative was executed (else) | }··· }; |
Function (anonymous_150) | |
---|---|
✓ Was called | Configuration.prototype.getProcessedConfig = function() {··· var result = {}; Object.keys(this._ruleSettings).forEach(function(key) { result[key] = this._ruleSettings[key]; }, this); result.excludeFiles = this._excludedFileMasks; result.fileExtensions = this._fileExtensions; result.extract = this._extractFileMasks; result.maxErrors = this._maxErrors; result.preset = this._presetName; result.es3 = this._es3Enabled; result.errorFilter = this._errorFilter; return result; }; |
Function (anonymous_151) | |
---|---|
✓ Was called | Object.keys(this._ruleSettings).forEach(function(key) {··· result[key] = this._ruleSettings[key]; }, this); |
Function (anonymous_152) | |
---|---|
✓ Was called | Configuration.prototype.getConfiguredRules = function() {··· return this._configuredRules; }; |
Function (anonymous_153) | |
---|---|
✓ Was called | Configuration.prototype.getConfiguredRule = function(name) {··· return this._configuredRules.filter(function(rule) { return rule.getOptionName() === name; })[0] || null; }; |
Function (anonymous_154) | |
---|---|
✓ Was called | return this._configuredRules.filter(function(rule) {··· return rule.getOptionName() === name; })[0] || null; |
Branch LogicalExpression | |
✓ Was returned | })[0] || null; |
✓ Was returned | return this._configuredRules.filter(function(rule) {··· return rule.getOptionName() === name; })[0] || null; |
Function (anonymous_155) | |
---|---|
✓ Was called | Configuration.prototype.getUnsupportedRuleNames = function() {··· return this._unsupportedRuleNames; }; |
Function (anonymous_156) | |
---|---|
✓ Was called | Configuration.prototype.getExcludedFileMasks = function() {··· return this._excludedFileMasks; }; |
Function (anonymous_157) | |
---|---|
✓ Was called | Configuration.prototype.isFileExcluded = function(filePath) {··· filePath = path.resolve(filePath); return this._excludedFileMatchers.some(function(matcher) { return matcher.match(filePath); }); }; |
Function (anonymous_158) | |
---|---|
✓ Was called | return this._excludedFileMatchers.some(function(matcher) {··· return matcher.match(filePath); }); |
Function (anonymous_159) | |
---|---|
✗ Was not called | Configuration.prototype.hasCorrectExtension = function(testPath) {··· var extension = path.extname(testPath).toLowerCase(); var basename = path.basename(testPath).toLowerCase(); var fileExtensions = this.getFileExtensions(); return !( fileExtensions.indexOf(extension) < 0 && fileExtensions.indexOf(basename) < 0 && fileExtensions.indexOf('*') < 0 ); }; |
Branch LogicalExpression | |
---|---|
✗ Was not returned | fileExtensions.indexOf('*') < 0 |
✗ Was not returned | fileExtensions.indexOf(extension) < 0 &&··· fileExtensions.indexOf(basename) < 0 && |
Branch LogicalExpression | |
✗ Was not returned | fileExtensions.indexOf(basename) < 0 && |
✗ Was not returned | fileExtensions.indexOf(extension) < 0 && |
Function (anonymous_160) | |
---|---|
✓ Was called | Configuration.prototype.getFileExtensions = function() {··· return this._fileExtensions; }; |
Function (anonymous_161) | |
---|---|
✓ Was called | Configuration.prototype.getExtractFileMasks = function() {··· return this._extractFileMasks; }; |
Function (anonymous_162) | |
---|---|
✓ Was called | Configuration.prototype.shouldExtractFile = function(filePath) {··· filePath = path.resolve(filePath); return this._extractFileMatchers.some(function(matcher) { return matcher.match(filePath); }); }; |
Function (anonymous_163) | |
---|---|
✓ Was called | return this._extractFileMatchers.some(function(matcher) {··· return matcher.match(filePath); }); |
Function (anonymous_164) | |
---|---|
✓ Was called | Configuration.prototype.getMaxErrors = function() {··· return this._maxErrors; }; |
Function (anonymous_165) | |
---|---|
✓ Was called | Configuration.prototype.getFix = function() {··· return !!this._fix; }; |
Function (anonymous_166) | |
---|---|
✓ Was called | Configuration.prototype.isES3Enabled = function() {··· return this._es3Enabled; }; |
Function (anonymous_167) | |
---|---|
✓ Was called | Configuration.prototype.getErrorFilter = function() {··· return this._errorFilter; }; |
Function (anonymous_168) | |
---|---|
✓ Was called | Configuration.prototype.getBasePath = function() {··· return this._basePath; }; |
Function (anonymous_169) | |
---|---|
✓ Was called | Configuration.prototype.override = function(overrides) {··· Object.keys(overrides).forEach(function(key) { this._overrides[key] = overrides[key]; }, this); }; |
Function (anonymous_170) | |
---|---|
✓ Was called | Object.keys(overrides).forEach(function(key) {··· this._overrides[key] = overrides[key]; }, this); |
Function (anonymous_171) | |
---|---|
✓ Was called | Configuration.prototype._getOptionsFromConfig = function(config) {··· return Object.keys(config).reduce(function(options, key) { if (BUILTIN_OPTIONS[key]) { options[key] = config[key]; } return options; }, {}); }; |
Function (anonymous_172) | |
---|---|
✓ Was called | return Object.keys(config).reduce(function(options, key) {··· if (BUILTIN_OPTIONS[key]) { options[key] = config[key]; } return options; }, {}); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (BUILTIN_OPTIONS[key]) {··· options[key] = config[key]; } |
✓ Negative was executed (else) | }··· return options; |
Function (anonymous_173) | |
---|---|
✓ Was called | Configuration.prototype._errorOnRemovedOptions = function(config) {··· var errors = ['Config values to remove in 3.0:']; if (config.hasOwnProperty('esprima')) { errors.push('The `esprima` option since CST uses babylon (the babel parser) under the hood'); } if (config.hasOwnProperty('esprimaOptions')) { errors.push('The `esprimaOptions` option.'); } if (config.hasOwnProperty('esnext')) { errors.push('The `esnext` option is enabled by default.'); } if (config.hasOwnProperty('verbose')) { errors.push('The `verbose` option is enabled by default.'); } if (errors.length > 1) { throw new Error(errors.join('\n')); } }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (config.hasOwnProperty('esprima')) {··· errors.push('The `esprima` option since CST uses babylon (the babel parser) under the hood'); } |
✓ Negative was executed (else) | }··· if (config.hasOwnProperty('esprimaOptions')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (config.hasOwnProperty('esprimaOptions')) {··· errors.push('The `esprimaOptions` option.'); } |
✓ Negative was executed (else) | }··· if (config.hasOwnProperty('esnext')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (config.hasOwnProperty('esnext')) {··· errors.push('The `esnext` option is enabled by default.'); } |
✓ Negative was executed (else) | }··· if (config.hasOwnProperty('verbose')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (config.hasOwnProperty('verbose')) {··· errors.push('The `verbose` option is enabled by default.'); } |
✓ Negative was executed (else) | }··· if (errors.length > 1) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (errors.length > 1) {··· throw new Error(errors.join('\n')); } |
✓ Negative was executed (else) | }··· }; |
Function (anonymous_174) | |
---|---|
✓ Was called | Configuration.prototype._processConfig = function(config) {··· var overrides = this._overrides; var currentConfig = {}; // Copy configuration so original config would be intact copyConfiguration(config, currentConfig); // Override the properties copyConfiguration(overrides, currentConfig); this._errorOnRemovedOptions(currentConfig); // NOTE: options is a separate object to ensure that future options must be added // to BUILTIN_OPTIONS to work, which also assures they aren't mistaken for a rule var options = this._getOptionsFromConfig(currentConfig); // Base path if (this._basePath === defaults.cwd && options.configPath) { assert( typeof options.configPath === 'string', '`configPath` option requires string value' ); this._basePath = path.dirname(options.configPath); } if (options.hasOwnProperty('plugins')) { assert(Array.isArray(options.plugins), '`plugins` option requires array value'); options.plugins.forEach(function(plugin) { this._loadPlugin(plugin, options.configPath); }, this); if (!this._isDefined('plugins')) { this._definedOptions.push('plugins'); } } if (options.hasOwnProperty('additionalRules')) { assert(Array.isArray(options.additionalRules), '`additionalRules` option requires array value'); options.additionalRules.forEach(function(rule) { this._loadAdditionalRule(rule, options.configPath); }, this); if (!this._isDefined('additionalRules')) { this._definedOptions.push('additionalRules'); } } if (options.hasOwnProperty('extract')) { this._loadExtract(options.extract); } if (options.hasOwnProperty('fileExtensions')) { this._loadFileExtensions(options.fileExtensions); } if (options.hasOwnProperty('excludeFiles')) { this._loadExcludedFiles(options.excludeFiles); } if (options.hasOwnProperty('fix')) { this._loadFix(options.fix); } this._loadMaxError(options); if (options.hasOwnProperty('es3')) { this._loadES3(options.es3); } if (options.hasOwnProperty('errorFilter')) { this._loadErrorFilter(options.errorFilter, options.configPath); } // Apply presets if (options.hasOwnProperty('preset')) { this._loadPreset(options.preset, options.configPath); } this._loadRules(currentConfig); }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._basePath === defaults.cwd && options.configPath) {··· assert( typeof options.configPath === 'string', '`configPath` option requires string value' ); this._basePath = path.dirname(options.configPath); } |
✓ Negative was executed (else) | }··· if (options.hasOwnProperty('plugins')) { |
Branch LogicalExpression | |
✓ Was returned | if (this._basePath === defaults.cwd && options.configPath) { |
✓ Was returned | if (this._basePath === defaults.cwd && options.configPath) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('plugins')) {··· assert(Array.isArray(options.plugins), '`plugins` option requires array value'); options.plugins.forEach(function(plugin) { this._loadPlugin(plugin, options.configPath); }, this); if (!this._isDefined('plugins')) { this._definedOptions.push('plugins'); } } |
✓ Negative was executed (else) | }··· if (options.hasOwnProperty('additionalRules')) { |
Function (anonymous_175) | |
---|---|
✓ Was called | options.plugins.forEach(function(plugin) {··· this._loadPlugin(plugin, options.configPath); }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('plugins')) {··· this._definedOptions.push('plugins'); } |
✗ Negative was not executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('additionalRules')) {··· assert(Array.isArray(options.additionalRules), '`additionalRules` option requires array value'); options.additionalRules.forEach(function(rule) { this._loadAdditionalRule(rule, options.configPath); }, this); if (!this._isDefined('additionalRules')) { this._definedOptions.push('additionalRules'); } } |
✓ Negative was executed (else) | }··· if (options.hasOwnProperty('extract')) { |
Function (anonymous_176) | |
---|---|
✓ Was called | options.additionalRules.forEach(function(rule) {··· this._loadAdditionalRule(rule, options.configPath); }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('additionalRules')) {··· this._definedOptions.push('additionalRules'); } |
✗ Negative was not executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('extract')) {··· this._loadExtract(options.extract); } |
✓ Negative was executed (else) | }··· if (options.hasOwnProperty('fileExtensions')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('fileExtensions')) {··· this._loadFileExtensions(options.fileExtensions); } |
✓ Negative was executed (else) | }··· if (options.hasOwnProperty('excludeFiles')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('excludeFiles')) {··· this._loadExcludedFiles(options.excludeFiles); } |
✓ Negative was executed (else) | }··· if (options.hasOwnProperty('fix')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('fix')) {··· this._loadFix(options.fix); } |
✓ Negative was executed (else) | }··· this._loadMaxError(options); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('es3')) {··· this._loadES3(options.es3); } |
✓ Negative was executed (else) | }··· if (options.hasOwnProperty('errorFilter')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('errorFilter')) {··· this._loadErrorFilter(options.errorFilter, options.configPath); } |
✓ Negative was executed (else) | }··· // Apply presets |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('preset')) {··· this._loadPreset(options.preset, options.configPath); } |
✓ Negative was executed (else) | }··· this._loadRules(currentConfig); |
Function (anonymous_177) | |
---|---|
✓ Was called | Configuration.prototype._loadPlugin = function(plugin) {··· assert(typeof plugin === 'function', '`plugin` should be a function'); plugin(this); }; |
Function (anonymous_178) | |
---|---|
✓ Was called | Configuration.prototype._loadRules = function(config) {··· Object.keys(config).forEach(function(key) { // Only rules should be processed if (BUILTIN_OPTIONS[key]) { return; } if (this._rules[key]) { var optionValue = config[key]; // Disable rule it it equals "false" or "null" if (optionValue === null || optionValue === false) { delete this._ruleSettings[key]; } else { this._ruleSettings[key] = config[key]; } } else if (this._unsupportedRuleNames.indexOf(key) === -1) { this._unsupportedRuleNames.push(key); } }, this); }; |
Function (anonymous_179) | |
---|---|
✓ Was called | Object.keys(config).forEach(function(key) {··· // Only rules should be processed if (BUILTIN_OPTIONS[key]) { return; } if (this._rules[key]) { var optionValue = config[key]; // Disable rule it it equals "false" or "null" if (optionValue === null || optionValue === false) { delete this._ruleSettings[key]; } else { this._ruleSettings[key] = config[key]; } } else if (this._unsupportedRuleNames.indexOf(key) === -1) { this._unsupportedRuleNames.push(key); } }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (BUILTIN_OPTIONS[key]) {··· return; } |
✓ Negative was executed (else) | }··· if (this._rules[key]) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._rules[key]) {··· var optionValue = config[key]; // Disable rule it it equals "false" or "null" if (optionValue === null || optionValue === false) { delete this._ruleSettings[key]; } else { this._ruleSettings[key] = config[key]; } } else if (this._unsupportedRuleNames.indexOf(key) === -1) { |
✓ Negative was executed (else) | } else if (this._unsupportedRuleNames.indexOf(key) === -1) {··· this._unsupportedRuleNames.push(key); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (optionValue === null || optionValue === false) {··· delete this._ruleSettings[key]; } else { |
✓ Negative was executed (else) | } else {··· this._ruleSettings[key] = config[key]; } |
Branch LogicalExpression | |
✓ Was returned | if (optionValue === null || optionValue === false) { |
✓ Was returned | if (optionValue === null || optionValue === false) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (this._unsupportedRuleNames.indexOf(key) === -1) {··· this._unsupportedRuleNames.push(key); } |
✓ Negative was executed (else) | }··· }, this); |
Function (anonymous_180) | |
---|---|
✓ Was called | Configuration.prototype._loadErrorFilter = function(errorFilter) {··· assert( typeof errorFilter === 'function' || errorFilter === null, '`errorFilter` option requires a function or null value' ); this._errorFilter = errorFilter; if (!this._isDefined('errorFilter')) { this._definedOptions.push('errorFilter'); } }; |
Branch LogicalExpression | |
---|---|
✗ Was not returned | errorFilter === null, |
✓ Was returned | typeof errorFilter === 'function' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('errorFilter')) {··· this._definedOptions.push('errorFilter'); } |
✗ Negative was not executed (else) | }··· }; |
Function (anonymous_181) | |
---|---|
✓ Was called | Configuration.prototype._loadES3 = function(es3) {··· assert( typeof es3 === 'boolean' || es3 === null, '`es3` option requires boolean or null value' ); this._es3Enabled = Boolean(es3); if (!this._isDefined('es3')) { this._definedOptions.push('es3'); } }; |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof es3 === 'boolean' || es3 === null, |
✓ Was returned | typeof es3 === 'boolean' || es3 === null, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('es3')) {··· this._definedOptions.push('es3'); } |
✗ Negative was not executed (else) | }··· }; |
Function (anonymous_182) | |
---|---|
✓ Was called | Configuration.prototype._loadMaxError = function(options) {··· // If "fix" option is enabled, set to Inifinity, otherwise this option // doesn't make sense with "fix" conjunction if (this._fix === true) { this._maxErrors = Infinity; return; } if (!options.hasOwnProperty('maxErrors')) { return; } var maxErrors = options.maxErrors === null ? null : Number(options.maxErrors); assert( maxErrors === -1 || maxErrors > 0 || maxErrors === null, '`maxErrors` option requires -1, null value or positive number' ); this._maxErrors = maxErrors; if (!this._isDefined('fix')) { this._definedOptions.push('fix'); } }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._fix === true) {··· this._maxErrors = Infinity; return; } |
✓ Negative was executed (else) | }··· if (!options.hasOwnProperty('maxErrors')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!options.hasOwnProperty('maxErrors')) {··· return; } |
✓ Negative was executed (else) | }··· var maxErrors = options.maxErrors === null ? null : Number(options.maxErrors); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var maxErrors = options.maxErrors === null ? null : Number(options.maxErrors); |
✓ Negative was returned (: ...) | var maxErrors = options.maxErrors === null ? null : Number(options.maxErrors); |
Branch LogicalExpression | |
---|---|
✓ Was returned | maxErrors === -1 || maxErrors > 0 || maxErrors === null, |
✓ Was returned | maxErrors === -1 || maxErrors > 0 || maxErrors === null, |
Branch LogicalExpression | |
✓ Was returned | maxErrors === -1 || maxErrors > 0 || maxErrors === null, |
✗ Was not returned | maxErrors === -1 || maxErrors > 0 || maxErrors === null, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('fix')) {··· this._definedOptions.push('fix'); } |
✓ Negative was executed (else) | }··· }; |
Function (anonymous_183) | |
---|---|
✓ Was called | Configuration.prototype._loadFix = function(fix) {··· fix = fix === null ? false : fix; assert( typeof fix === 'boolean', '`fix` option requires boolean or null value' ); this._fix = fix; if (!this._isDefined('fix')) { this._definedOptions.push('fix'); } }; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | fix = fix === null ? false : fix; |
✓ Negative was returned (: ...) | fix = fix === null ? false : fix; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('fix')) {··· this._definedOptions.push('fix'); } |
✗ Negative was not executed (else) | }··· }; |
Function (anonymous_184) | |
---|---|
✓ Was called | Configuration.prototype._loadPreset = function(preset) {··· if (this._loadedPresets.indexOf(preset) > -1) { return; } // Do not keep adding preset from CLI (#2087) delete this._overrides.preset; this._loadedPresets.push(preset); // If preset is loaded from another preset - preserve the original name if (!this._presetName) { this._presetName = preset; } assert(typeof preset === 'string', '`preset` option requires string value'); var presetData = this._presets[preset]; assert(Boolean(presetData), 'Preset "' + preset + '" does not exist'); if (!this._isDefined('preset')) { this._definedOptions.push('preset'); } // Process config from the preset this._processConfig(this._presets[preset]); }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._loadedPresets.indexOf(preset) > -1) {··· return; } |
✓ Negative was executed (else) | }··· // Do not keep adding preset from CLI (#2087) |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._presetName) {··· this._presetName = preset; } |
✓ Negative was executed (else) | }··· assert(typeof preset === 'string', '`preset` option requires string value'); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('preset')) {··· this._definedOptions.push('preset'); } |
✓ Negative was executed (else) | }··· // Process config from the preset |
Function (anonymous_185) | |
---|---|
✓ Was called | Configuration.prototype._loadFileExtensions = function(extensions) {··· assert( typeof extensions === 'string' || Array.isArray(extensions), '`fileExtensions` option requires string or array value' ); this._fileExtensions = this._fileExtensions.concat(extensions).map(function(ext) { return ext.toLowerCase(); }); if (!this._isDefined('fileExtensions')) { this._definedOptions.push('fileExtensions'); } }; |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof extensions === 'string' || Array.isArray(extensions), |
✓ Was returned | typeof extensions === 'string' || Array.isArray(extensions), |
Function (anonymous_186) | |
---|---|
✓ Was called | this._fileExtensions = this._fileExtensions.concat(extensions).map(function(ext) {··· return ext.toLowerCase(); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('fileExtensions')) {··· this._definedOptions.push('fileExtensions'); } |
✓ Negative was executed (else) | }··· }; |
Function (anonymous_187) | |
---|---|
✓ Was called | Configuration.prototype._isDefined = function(name) {··· return this._definedOptions.indexOf(name) > -1; }; |
Function (anonymous_188) | |
---|---|
✓ Was called | Configuration.prototype._loadExcludedFiles = function(masks) {··· assert(Array.isArray(masks), '`excludeFiles` option requires array value'); this._excludedFileMasks = this._excludedFileMasks.concat(masks); this._excludedFileMatchers = this._excludedFileMasks.map(function(fileMask) { return new minimatch.Minimatch(path.resolve(this._basePath, fileMask), { dot: true }); }, this); if (!this._isDefined('excludeFiles')) { this._definedOptions.push('excludeFiles'); } }; |
Function (anonymous_189) | |
---|---|
✓ Was called | this._excludedFileMatchers = this._excludedFileMasks.map(function(fileMask) {··· return new minimatch.Minimatch(path.resolve(this._basePath, fileMask), { dot: true }); }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('excludeFiles')) {··· this._definedOptions.push('excludeFiles'); } |
✓ Negative was executed (else) | }··· }; |
Function (anonymous_190) | |
---|---|
✓ Was called | Configuration.prototype._loadExtract = function(masks) {··· if (masks === true) { masks = this._defaultExtractFileMasks; } else if (masks === false) { masks = []; } assert(Array.isArray(masks), '`extract` option should be array of strings'); this._extractFileMasks = masks.slice(); this._extractFileMatchers = this._extractFileMasks.map(function(fileMask) { return new minimatch.Minimatch(path.resolve(this._basePath, fileMask), { dot: true }); }, this); if (!this._isDefined('extract')) { this._definedOptions.push('extract'); } }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (masks === true) {··· masks = this._defaultExtractFileMasks; } else if (masks === false) { |
✓ Negative was executed (else) | } else if (masks === false) {··· masks = []; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (masks === false) {··· masks = []; } |
✓ Negative was executed (else) | }··· assert(Array.isArray(masks), '`extract` option should be array of strings'); |
Function (anonymous_191) | |
---|---|
✓ Was called | this._extractFileMatchers = this._extractFileMasks.map(function(fileMask) {··· return new minimatch.Minimatch(path.resolve(this._basePath, fileMask), { dot: true }); }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isDefined('extract')) {··· this._definedOptions.push('extract'); } |
✗ Negative was not executed (else) | }··· }; |
Function (anonymous_192) | |
---|---|
✓ Was called | Configuration.prototype._loadAdditionalRule = function(additionalRule) {··· assert(typeof additionalRule === 'object', '`additionalRule` should be an object'); this.registerRule(additionalRule); }; |
Function (anonymous_193) | |
---|---|
✓ Was called | Configuration.prototype.usePlugin = function(plugin) {··· this._loadPlugin(plugin); }; |
Function (anonymous_194) | |
---|---|
✓ Was called | Configuration.prototype._useRules = function() {··· this._configuredRules = []; Object.keys(this._ruleSettings).forEach(function(optionName) { var rule = this._rules[optionName]; rule.configure(this._ruleSettings[optionName]); this._configuredRules.push(rule); }, this); }; |
Function (anonymous_195) | |
---|---|
✓ Was called | Object.keys(this._ruleSettings).forEach(function(optionName) {··· var rule = this._rules[optionName]; rule.configure(this._ruleSettings[optionName]); this._configuredRules.push(rule); }, this); |
Function (anonymous_196) | |
---|---|
✓ Was called | Configuration.prototype.registerRule = function(rule) {··· if (typeof rule === 'function') { var RuleClass = rule; rule = new RuleClass(); } var optionName = rule.getOptionName(); assert(!this._rules.hasOwnProperty(optionName), 'Rule "' + optionName + '" is already registered'); this._rules[optionName] = rule; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof rule === 'function') {··· var RuleClass = rule; rule = new RuleClass(); } |
✓ Negative was executed (else) | }··· var optionName = rule.getOptionName(); |
Function (anonymous_197) | |
---|---|
✓ Was called | Configuration.prototype.getRegisteredRules = function() {··· var rules = this._rules; return Object.keys(rules).map(function(ruleOptionName) { return rules[ruleOptionName]; }); }; |
Function (anonymous_198) | |
---|---|
✓ Was called | return Object.keys(rules).map(function(ruleOptionName) {··· return rules[ruleOptionName]; }); |
Function (anonymous_199) | |
---|---|
✓ Was called | Configuration.prototype.registerPreset = function(presetName, presetConfig) {··· assert(_.isPlainObject(presetConfig), 'Preset should be an object'); for (var key in presetConfig) { assert(typeof presetConfig[key] !== 'function', 'Preset should be an JSON object'); } this._presets[presetName] = presetConfig; }; |
Function (anonymous_200) | |
---|---|
✓ Was called | Configuration.prototype.getRegisteredPresets = function() {··· return this._presets; }; |
Function (anonymous_201) | |
---|---|
✓ Was called | Configuration.prototype.hasPreset = function(presetName) {··· return this._presets.hasOwnProperty(presetName); }; |
Function (anonymous_202) | |
---|---|
✓ Was called | Configuration.prototype.getPresetName = function() {··· return this._presetName; }; |
Function (anonymous_203) | |
---|---|
✓ Was called | Configuration.prototype.registerDefaultRules = function() {··· var dir = path.join(__dirname, '../rules'); fs.readdirSync(dir).forEach(function(rule) { this.registerRule( require(path.join(dir, rule)) ); }, this); }; |
Function (anonymous_204) | |
---|---|
✓ Was called | fs.readdirSync(dir).forEach(function(rule) {··· this.registerRule( require(path.join(dir, rule)) ); }, this); |
Function (anonymous_205) | |
---|---|
✓ Was called | Configuration.prototype.registerDefaultPresets = function() {··· var dir = path.join(__dirname, '../../presets/'); fs.readdirSync(dir).forEach(function(preset) { var name = preset.split('.')[0]; var p = path.join(dir, preset); this.registerPreset(name, require(p)); }, this); this.registerPreset('wikimedia', require('jscs-preset-wikimedia')); }; |
Function (anonymous_206) | |
---|---|
✓ Was called | fs.readdirSync(dir).forEach(function(preset) {··· var name = preset.split('.')[0]; var p = path.join(dir, preset); this.registerPreset(name, require(p)); }, this); |
Function copyConfiguration | |
---|---|
✓ Was called | function copyConfiguration(source, dest) {··· Object.keys(source).forEach(function(key) { dest[key] = source[key]; }); if (source.configPath) { dest.configPath = source.configPath; } } |
Function (anonymous_208) | |
---|---|
✓ Was called | Object.keys(source).forEach(function(key) {··· dest[key] = source[key]; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (source.configPath) {··· dest.configPath = source.configPath; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_209) | |
---|---|
✓ Was called | var HtmlFile = function(params) {··· this._filename = params.filename; this._lines = params.source.split(rLineSplit); }; |
Function (anonymous_210) | |
---|---|
✓ Was called | getFilename: function() {··· return this._filename; }, |
Function (anonymous_211) | |
---|---|
✓ Was called | getLines: function() {··· return this._lines; } |
Function getScripts | |
---|---|
✓ Was called | function getScripts(html) {··· function onopen(name, attrs) { // tag should be a <script> if (name !== 'script' || // ignore scripts with src attribute attrs.src || // script tag should has no type attribute or attribute should be equal to text/javascript (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { return; } // store script content start pos scriptStartPos = parser.endIndex + 1; } function onclose() { if (!scriptStartPos) { return; } // get script content var scriptEndPos = parser.startIndex; var source = html.substring(scriptStartPos, scriptEndPos); // store script content only if it contains non-whitespace characters if (rHasNonWhitespace.test(source)) { scripts.push({ source: source, start: scriptStartPos, end: scriptEndPos }); } // reset script start position scriptStartPos = 0; } var scriptStartPos = 0; var scripts = []; var parser = new htmlparser.Parser({ onopentag: onopen, onclosetag: onclose }); parser.parseComplete(html); return scripts; } |
Function onopen | |
---|---|
✓ Was called | function onopen(name, attrs) {··· // tag should be a <script> if (name !== 'script' || // ignore scripts with src attribute attrs.src || // script tag should has no type attribute or attribute should be equal to text/javascript (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { return; } // store script content start pos scriptStartPos = parser.endIndex + 1; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) {··· return; } |
✓ Negative was executed (else) | }··· // store script content start pos |
Branch LogicalExpression | |
✓ Was returned | (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { |
✓ Was returned | if (name !== 'script' ||··· // ignore scripts with src attribute attrs.src || |
Branch LogicalExpression | |
✓ Was returned | attrs.src || |
✓ Was returned | if (name !== 'script' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { |
✓ Was returned | (attrs.type && attrs.type.toLowerCase() !== 'text/javascript')) { |
Function onclose | |
---|---|
✓ Was called | function onclose() {··· if (!scriptStartPos) { return; } // get script content var scriptEndPos = parser.startIndex; var source = html.substring(scriptStartPos, scriptEndPos); // store script content only if it contains non-whitespace characters if (rHasNonWhitespace.test(source)) { scripts.push({ source: source, start: scriptStartPos, end: scriptEndPos }); } // reset script start position scriptStartPos = 0; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!scriptStartPos) {··· return; } |
✓ Negative was executed (else) | }··· // get script content |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (rHasNonWhitespace.test(source)) {··· scripts.push({ source: source, start: scriptStartPos, end: scriptEndPos }); } |
✓ Negative was executed (else) | }··· // reset script start position |
Function normalizeSource | |
---|---|
✓ Was called | function normalizeSource(source) {··· var lines = source.split(rLineSplit); var lineCount = lines.length; var tabOnlyOffset = false; var spaceOnlyOffset = false; var offset; // remove first list if it's an empty string // usually <script> starts with new line if (!rHasNonWhitespace.test(lines[0])) { lines.shift(); } // replace last line by empty string if it contains only whitespaces // it helps avoid disallowTrailingWhitespace errors on last line if (!rHasNonWhitespace.test(lines[lines.length - 1])) { lines[lines.length - 1] = ''; } // calculate min line offset offset = Math.min.apply(null, lines.map(function(line) { // skip empty lines if (!line) { return Infinity; } // fetch whitespaces at the line beginning var offsetStr = line.match(/^\s*/)[0]; var tabCount = offsetStr.match(/\t*/)[0].length; if (offsetStr.length === line.length) { return 0; } // mixed spaces and tabs in one offset -> don't remove offsets if (tabCount && tabCount !== offsetStr.length) { return 0; } if (tabCount) { if (spaceOnlyOffset) { // no spaces, but previous offset has ony spaces -> mixed spaces and tabs return 0; } else { // remember offset contains only tabs tabOnlyOffset = true; } } else { if (tabOnlyOffset) { // no tabs, but previous offset has only tabs -> mixed spaces and tabs return 0; } else { // remember offset contains only spaces spaceOnlyOffset = true; } } return offsetStr.length; })); // remove common offsets if possible if (offset) { lines = lines.map(function(line) { return line.substr(offset); }); } return { source: lines.join('\n'), offset: offset, lineCount: lineCount }; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!rHasNonWhitespace.test(lines[0])) {··· lines.shift(); } |
✓ Negative was executed (else) | }··· // replace last line by empty string if it contains only whitespaces |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!rHasNonWhitespace.test(lines[lines.length - 1])) {··· lines[lines.length - 1] = ''; } |
✓ Negative was executed (else) | }··· // calculate min line offset |
Function (anonymous_216) | |
---|---|
✓ Was called | offset = Math.min.apply(null, lines.map(function(line) {··· // skip empty lines if (!line) { return Infinity; } // fetch whitespaces at the line beginning var offsetStr = line.match(/^\s*/)[0]; var tabCount = offsetStr.match(/\t*/)[0].length; if (offsetStr.length === line.length) { return 0; } // mixed spaces and tabs in one offset -> don't remove offsets if (tabCount && tabCount !== offsetStr.length) { return 0; } if (tabCount) { if (spaceOnlyOffset) { // no spaces, but previous offset has ony spaces -> mixed spaces and tabs return 0; } else { // remember offset contains only tabs tabOnlyOffset = true; } } else { if (tabOnlyOffset) { // no tabs, but previous offset has only tabs -> mixed spaces and tabs return 0; } else { // remember offset contains only spaces spaceOnlyOffset = true; } } return offsetStr.length; })); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!line) {··· return Infinity; } |
✓ Negative was executed (else) | }··· // fetch whitespaces at the line beginning |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (offsetStr.length === line.length) {··· return 0; } |
✓ Negative was executed (else) | }··· // mixed spaces and tabs in one offset -> don't remove offsets |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (tabCount && tabCount !== offsetStr.length) {··· return 0; } |
✓ Negative was executed (else) | }··· if (tabCount) { |
Branch LogicalExpression | |
✓ Was returned | if (tabCount && tabCount !== offsetStr.length) { |
✓ Was returned | if (tabCount && tabCount !== offsetStr.length) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (tabCount) {··· if (spaceOnlyOffset) { // no spaces, but previous offset has ony spaces -> mixed spaces and tabs return 0; } else { // remember offset contains only tabs tabOnlyOffset = true; } } else { |
✓ Negative was executed (else) | } else {··· if (tabOnlyOffset) { // no tabs, but previous offset has only tabs -> mixed spaces and tabs return 0; } else { // remember offset contains only spaces spaceOnlyOffset = true; } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (spaceOnlyOffset) {··· // no spaces, but previous offset has ony spaces -> mixed spaces and tabs return 0; } else { |
✓ Negative was executed (else) | } else {··· // remember offset contains only tabs tabOnlyOffset = true; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (tabOnlyOffset) {··· // no tabs, but previous offset has only tabs -> mixed spaces and tabs return 0; } else { |
✓ Negative was executed (else) | } else {··· // remember offset contains only spaces spaceOnlyOffset = true; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (offset) {··· lines = lines.map(function(line) { return line.substr(offset); }); } |
✓ Negative was executed (else) | }··· return { |
Function (anonymous_217) | |
---|---|
✓ Was called | lines = lines.map(function(line) {··· return line.substr(offset); }); |
Function extractJs | |
---|---|
✓ Was called | function extractJs(filename, data) {··· var errors = new Errors(new HtmlFile({ filename: filename, source: data })); var scripts = getScripts(data); var sources = []; var line = 1; var lastHtmlPos = 0; scripts.forEach(function(scriptInfo) { // fetch script source and normalize it var normalized = normalizeSource(scriptInfo.source); // add line offset before script line += data.substring(lastHtmlPos, scriptInfo.start).split(rLineSplit).length - 1; sources.push({ source: normalized.source, offset: normalized.offset, line: line }); // save offsets for next fragment line += normalized.lineCount - 1; lastHtmlPos = scriptInfo.end; }); return { sources: sources, errors: errors, addError: function(error) { errors._errorList.push({ filename: filename, rule: error.rule, message: error.message, line: error.line, column: error.column }); } }; } |
Function (anonymous_219) | |
---|---|
✓ Was called | scripts.forEach(function(scriptInfo) {··· // fetch script source and normalize it var normalized = normalizeSource(scriptInfo.source); // add line offset before script line += data.substring(lastHtmlPos, scriptInfo.start).split(rLineSplit).length - 1; sources.push({ source: normalized.source, offset: normalized.offset, line: line }); // save offsets for next fragment line += normalized.lineCount - 1; lastHtmlPos = scriptInfo.end; }); |
Function (anonymous_220) | |
---|---|
✓ Was called | addError: function(error) {··· errors._errorList.push({ filename: filename, rule: error.rule, message: error.message, line: error.line, column: error.column }); } |
Function req | |
---|---|
✓ Was called | function req(entity, dir) {··· return require( resolve.sync(entity, { basedir: dir }) ); } |
Function NodeConfiguration | |
---|---|
✓ Was called | function NodeConfiguration() {··· Configuration.call(this); this._basePath = process.cwd(); } |
Function (anonymous_223) | |
---|---|
✓ Was called | NodeConfiguration.prototype.overrideFromCLI = function(program) {··· var overrides = {}; OVERRIDE_OPTIONS.forEach(function(option) { if (option in program) { overrides[option] = program[option]; } }); this.override(overrides); }; |
Function (anonymous_224) | |
---|---|
✓ Was called | OVERRIDE_OPTIONS.forEach(function(option) {··· if (option in program) { overrides[option] = program[option]; } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (option in program) {··· overrides[option] = program[option]; } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_225) | |
---|---|
✓ Was called | NodeConfiguration.prototype.loadExternal = function(external, type, config) {··· assert( typeof external === 'string' || external === null, '"' + type + '" option requires a string or null value' ); if (external === null) { return null; } var dir = config ? path.dirname(config) : this._basePath; var get = function(prefix, postfix) { prefix = prefix || ''; postfix = postfix || ''; try { return finder( utils.normalizePath(prefix + external + postfix, dir), dir ); } catch (e) {} return null; }.bind(this); var finder; if (type === 'preset') { finder = configFinder.getContent; } else { finder = req; } var content; if (external.indexOf('jscs-') !== 0) { content = get('jscs-'); if (!content && type === 'preset') { content = get('jscs-preset-') || get('jscs-config-'); if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { content = get('jscs-', '.json') || get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || get('jscs-config-', '.js'); } } } return content || get(); }; |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof external === 'string' || external === null, |
✓ Was returned | typeof external === 'string' || external === null, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (external === null) {··· return null; } |
✓ Negative was executed (else) | }··· var dir = config ? path.dirname(config) : this._basePath; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var dir = config ? path.dirname(config) : this._basePath; |
✓ Negative was returned (: ...) | var dir = config ? path.dirname(config) : this._basePath; |
Function (anonymous_226) | |
---|---|
✓ Was called | var get = function(prefix, postfix) {··· prefix = prefix || ''; postfix = postfix || ''; try { return finder( utils.normalizePath(prefix + external + postfix, dir), dir ); } catch (e) {} return null; }.bind(this); |
Branch LogicalExpression | |
---|---|
✓ Was returned | prefix = prefix || ''; |
✓ Was returned | prefix = prefix || ''; |
Branch LogicalExpression | |
---|---|
✓ Was returned | postfix = postfix || ''; |
✓ Was returned | postfix = postfix || ''; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (type === 'preset') {··· finder = configFinder.getContent; } else { |
✓ Negative was executed (else) | } else {··· finder = req; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (external.indexOf('jscs-') !== 0) {··· content = get('jscs-'); if (!content && type === 'preset') { content = get('jscs-preset-') || get('jscs-config-'); if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { content = get('jscs-', '.json') || get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || get('jscs-config-', '.js'); } } } |
✓ Negative was executed (else) | }··· return content || get(); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!content && type === 'preset') {··· content = get('jscs-preset-') || get('jscs-config-'); if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { content = get('jscs-', '.json') || get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || get('jscs-config-', '.js'); } } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (!content && type === 'preset') { |
✓ Was returned | if (!content && type === 'preset') { |
Branch LogicalExpression | |
---|---|
✓ Was returned | content = get('jscs-preset-') || get('jscs-config-'); |
✓ Was returned | content = get('jscs-preset-') || get('jscs-config-'); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) {··· content = get('jscs-', '.json') || get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || get('jscs-config-', '.js'); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { |
✓ Was returned | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { |
Branch LogicalExpression | |
✓ Was returned | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { |
✓ Was returned | if (!content && external.indexOf('/') !== -1 && !external.split('.')[1]) { |
Branch LogicalExpression | |
---|---|
✗ Was not returned | get('jscs-config-', '.js'); |
✓ Was returned | content = get('jscs-', '.json') ||··· get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || get('jscs-preset-', '.js') || |
Branch LogicalExpression | |
✗ Was not returned | get('jscs-preset-', '.js') || |
✓ Was returned | content = get('jscs-', '.json') ||··· get('jscs-', '.js') || get('jscs-preset-', '.json') || get('jscs-config-', '.json') || |
Branch LogicalExpression | |
✗ Was not returned | get('jscs-config-', '.json') || |
✓ Was returned | content = get('jscs-', '.json') ||··· get('jscs-', '.js') || get('jscs-preset-', '.json') || |
Branch LogicalExpression | |
✓ Was returned | get('jscs-preset-', '.json') || |
✓ Was returned | content = get('jscs-', '.json') ||··· get('jscs-', '.js') || |
Branch LogicalExpression | |
✓ Was returned | get('jscs-', '.js') || |
✓ Was returned | content = get('jscs-', '.json') || |
Branch LogicalExpression | |
---|---|
✓ Was returned | return content || get(); |
✓ Was returned | return content || get(); |
Function (anonymous_227) | |
---|---|
✓ Was called | NodeConfiguration.prototype._loadPlugin = function(plugin, config) {··· if (typeof plugin !== 'function') { plugin = this.loadExternal(plugin, 'plugin', config); } return Configuration.prototype._loadPlugin.call(this, plugin); }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof plugin !== 'function') {··· plugin = this.loadExternal(plugin, 'plugin', config); } |
✓ Negative was executed (else) | }··· return Configuration.prototype._loadPlugin.call(this, plugin); |
Function (anonymous_228) | |
---|---|
✓ Was called | NodeConfiguration.prototype._loadPreset = function(preset, config) {··· var name = path.basename(preset).split('.')[0]; try { this.registerPreset(name, this.loadExternal(preset, 'preset', config)); } catch (e) { var registeredPresets = this.getRegisteredPresets(); if (preset in registeredPresets) { Configuration.prototype._loadPreset.call(this, preset); return; } } // If preset is an external module, error will be thrown by the caller Configuration.prototype._loadPreset.call(this, name); }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (preset in registeredPresets) {··· Configuration.prototype._loadPreset.call(this, preset); return; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_229) | |
---|---|
✓ Was called | NodeConfiguration.prototype._loadErrorFilter = function(filter, config) {··· Configuration.prototype._loadErrorFilter.call( this, this.loadExternal(filter, 'errorFilter', config) ); }; |
Function (anonymous_230) | |
---|---|
✓ Was called | NodeConfiguration.prototype._loadAdditionalRule = function(additionalRule, config) {··· config = config || this._basePath; if (typeof additionalRule === 'string') { if (glob.hasMagic(additionalRule)) { // In some cases there might not be a config // like if options are defined through direct initialization (grunt plugin case) config = fs.statSync(config).isDirectory() ? config : path.dirname(config); glob.sync(path.resolve(config, additionalRule)).forEach(function(p) { var Rule = require(p); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); }, this); } else { var Rule = this.loadExternal(additionalRule, 'rule', config); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); } } else { Configuration.prototype._loadAdditionalRule.call(this, additionalRule); } }; |
Branch LogicalExpression | |
---|---|
✓ Was returned | config = config || this._basePath; |
✓ Was returned | config = config || this._basePath; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof additionalRule === 'string') {··· if (glob.hasMagic(additionalRule)) { // In some cases there might not be a config // like if options are defined through direct initialization (grunt plugin case) config = fs.statSync(config).isDirectory() ? config : path.dirname(config); glob.sync(path.resolve(config, additionalRule)).forEach(function(p) { var Rule = require(p); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); }, this); } else { var Rule = this.loadExternal(additionalRule, 'rule', config); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); } } else { |
✓ Negative was executed (else) | } else {··· Configuration.prototype._loadAdditionalRule.call(this, additionalRule); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (glob.hasMagic(additionalRule)) {··· // In some cases there might not be a config // like if options are defined through direct initialization (grunt plugin case) config = fs.statSync(config).isDirectory() ? config : path.dirname(config); glob.sync(path.resolve(config, additionalRule)).forEach(function(p) { var Rule = require(p); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); }, this); } else { |
✓ Negative was executed (else) | } else {··· var Rule = this.loadExternal(additionalRule, 'rule', config); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | config = fs.statSync(config).isDirectory() ? config : path.dirname(config); |
✓ Negative was returned (: ...) | config = fs.statSync(config).isDirectory() ? config : path.dirname(config); |
Function (anonymous_231) | |
---|---|
✓ Was called | glob.sync(path.resolve(config, additionalRule)).forEach(function(p) {··· var Rule = require(p); Configuration.prototype._loadAdditionalRule.call(this, new Rule()); }, this); |
Function (anonymous_232) | |
---|---|
✓ Was called | exports.isValidIdentifierName = function(name, dialect) {··· dialect = dialect || 'es5'; var identifierRegex = dialect === 'es5' ? IDENTIFIER_NAME_ES5_RE : IDENTIFIER_NAME_ES6_RE; return !reservedWords.check(name, dialect, true) && identifierRegex.test(name); }; |
Branch LogicalExpression | |
---|---|
✓ Was returned | dialect = dialect || 'es5'; |
✓ Was returned | dialect = dialect || 'es5'; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var identifierRegex = dialect === 'es5' ? IDENTIFIER_NAME_ES5_RE : IDENTIFIER_NAME_ES6_RE; |
✓ Negative was returned (: ...) | var identifierRegex = dialect === 'es5' ? IDENTIFIER_NAME_ES5_RE : IDENTIFIER_NAME_ES6_RE; |
Branch LogicalExpression | |
---|---|
✓ Was returned | return !reservedWords.check(name, dialect, true) && identifierRegex.test(name); |
✓ Was returned | return !reservedWords.check(name, dialect, true) && identifierRegex.test(name); |
Function (anonymous_233) | |
---|---|
✓ Was called | exports.isSnakeCased = function(name) {··· return SNAKE_CASE_RE.test(name); }; |
Function (anonymous_234) | |
---|---|
✓ Was called | exports.getFunctionNodeFromIIFE = function(node) {··· if (node.type !== 'CallExpression') { return null; } var callee = node.callee; if (callee.type === 'FunctionExpression') { return callee; } if (callee.type === 'MemberExpression' && callee.object.type === 'FunctionExpression' && callee.property.type === 'Identifier' && (callee.property.name === 'call' || callee.property.name === 'apply') ) { return callee.object; } return null; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type !== 'CallExpression') {··· return null; } |
✓ Negative was executed (else) | }··· var callee = node.callee; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (callee.type === 'FunctionExpression') {··· return callee; } |
✓ Negative was executed (else) | }··· if (callee.type === 'MemberExpression' && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return callee.object; } |
✓ Negative was executed (else) | }··· return null; |
Branch LogicalExpression | |
✓ Was returned | (callee.property.name === 'call' || callee.property.name === 'apply') |
✓ Was returned | if (callee.type === 'MemberExpression' &&··· callee.object.type === 'FunctionExpression' && callee.property.type === 'Identifier' && |
Branch LogicalExpression | |
✓ Was returned | callee.property.type === 'Identifier' && |
✓ Was returned | if (callee.type === 'MemberExpression' &&··· callee.object.type === 'FunctionExpression' && |
Branch LogicalExpression | |
✓ Was returned | callee.object.type === 'FunctionExpression' && |
✓ Was returned | if (callee.type === 'MemberExpression' && |
Branch LogicalExpression | |
---|---|
✓ Was returned | (callee.property.name === 'call' || callee.property.name === 'apply') |
✓ Was returned | (callee.property.name === 'call' || callee.property.name === 'apply') |
Function (anonymous_235) | |
---|---|
✓ Was called | exports.trimUnderscores = function(name) {··· var res = name.replace(TRAILING_UNDERSCORES_RE, ''); return res ? res : name; }; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return res ? res : name; |
✓ Negative was returned (: ...) | return res ? res : name; |
Function (anonymous_236) | |
---|---|
✓ Was called | exports.isRelativePath = function(path) {··· // Logic from: https://github.com/joyent/node/blob/4f1ae11a62b97052bc83756f8cb8700cc1f61661/lib/module.js#L237 var start = path.substring(0, 2); return start === './' || start === '..'; }; |
Branch LogicalExpression | |
---|---|
✓ Was returned | return start === './' || start === '..'; |
✓ Was returned | return start === './' || start === '..'; |
Function (anonymous_237) | |
---|---|
✓ Was called | exports.normalizePath = function(filepath, basePath) {··· if (this.isRelativePath(filepath)) { return path.resolve(basePath, filepath); } return filepath; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this.isRelativePath(filepath)) {··· return path.resolve(basePath, filepath); } |
✓ Negative was executed (else) | }··· return filepath; |
Function (anonymous_238) | |
---|---|
✓ Was called | exports.promisify = function(fn) {··· return function() { var deferred = Vow.defer(); var args = [].slice.call(arguments); args.push(function(err, result) { if (err) { deferred.reject(err); } else { deferred.resolve(result); } }); fn.apply(null, args); return deferred.promise(); }; }; |
Function (anonymous_239) | |
---|---|
✓ Was called | return function() {··· var deferred = Vow.defer(); var args = [].slice.call(arguments); args.push(function(err, result) { if (err) { deferred.reject(err); } else { deferred.resolve(result); } }); fn.apply(null, args); return deferred.promise(); }; |
Function (anonymous_240) | |
---|---|
✓ Was called | args.push(function(err, result) {··· if (err) { deferred.reject(err); } else { deferred.resolve(result); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (err) {··· deferred.reject(err); } else { |
✓ Negative was executed (else) | } else {··· deferred.resolve(result); } |
Function (anonymous_241) | |
---|---|
✓ Was called | exports.isPragma = function(additionalExceptions) {··· var pragmaKeywords = [ 'eslint', 'eslint-env', 'eslint-enable', 'eslint-disable', 'eslint-disable-line', 'eslint-disable-next-line', 'global', 'jshint', 'jslint', 'globals', 'falls through', 'exported', 'jscs:', 'jscs:enable', 'jscs:disable', 'jscs:ignore', 'istanbul' ]; if (additionalExceptions && Array.isArray(additionalExceptions)) { pragmaKeywords = pragmaKeywords.concat(additionalExceptions); } return function(comment) { // pragmaKeywords precede a space or the end of the comment var trimmedComment = comment.trim() + ' '; for (var i = 0; i < pragmaKeywords.length; i++) { if (trimmedComment.indexOf(pragmaKeywords[i] + ' ') === 0) { return true; } } return false; }; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (additionalExceptions && Array.isArray(additionalExceptions)) {··· pragmaKeywords = pragmaKeywords.concat(additionalExceptions); } |
✓ Negative was executed (else) | }··· return function(comment) { |
Branch LogicalExpression | |
✓ Was returned | if (additionalExceptions && Array.isArray(additionalExceptions)) { |
✓ Was returned | if (additionalExceptions && Array.isArray(additionalExceptions)) { |
Function (anonymous_242) | |
---|---|
✓ Was called | return function(comment) {··· // pragmaKeywords precede a space or the end of the comment var trimmedComment = comment.trim() + ' '; for (var i = 0; i < pragmaKeywords.length; i++) { if (trimmedComment.indexOf(pragmaKeywords[i] + ' ') === 0) { return true; } } return false; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (trimmedComment.indexOf(pragmaKeywords[i] + ' ') === 0) {··· return true; } |
✓ Negative was executed (else) | }··· } |
Function cli | |
---|---|
✓ Was called | module.exports = function cli(program) {··· var reporter; var config; var checkerPromise; var defer = Vow.defer(); var promise = defer.promise(); var checker = new Checker(); var args = program.args; var returnArgs = { checker: checker, reporter: program.reporter, promise: promise }; function handleMaxErrors() { if (checker.maxErrorsExceeded()) { console.error('Too many errors... Increase `maxErrors` configuration option value to see more.'); } } promise.always(function(status) { exit(status.valueOf()); }); try { config = configFile.load(program.config); } catch (e) { console.error('Config source is corrupted -', e.toString()); defer.reject(5); return returnArgs; } /** * Trying to load config. * Custom config path can be specified using '-c' option. */ if (!config && !program.preset && !program.autoConfigure) { if (program.config) { console.error('Configuration source', program.config, 'was not found.'); } else { console.error('No configuration found. Add a .jscsrc file to your project root or use the -c option.'); } defer.reject(4); return returnArgs; } if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { console.error('No input files specified. Try option --help for usage information.'); defer.reject(3); return returnArgs; } reporter = configFile.getReporter(program.reporter, program.colors); returnArgs.reporter = reporter.path; if (!reporter.writer) { console.error('Reporter "%s" does not exist.', program.reporter); returnArgs.reporter = reporter.path; defer.reject(6); return returnArgs; } if (!config) { config = {}; } // To run autoconfigure over all errors in the path if (program.autoConfigure) { program.maxErrors = Infinity; } checker.getConfiguration().overrideFromCLI(program); checker.getConfiguration().registerDefaultRules(); try { checker.configure(config); } catch (e) { console.error(e.message); defer.reject(1); return returnArgs; } if (program.autoConfigure) { var generator = new ConfigGenerator(); generator .generate(program.autoConfigure) .then(function() { defer.resolve(0); }, function(error) { console.error('Configuration generation failed due to ', error); defer.reject(7); }); return returnArgs; } // Handle usage like 'cat myfile.js | jscs' or 'jscs -'' var usedDash = args[args.length - 1] === '-'; if (!args.length || usedDash) { // So the dash doesn't register as a file if (usedDash) { args.length--; } if (program.fix) { return { promise: checker.fixStdin().then(function(result) { process.stdout.write(result.output); }), checker: checker }; } checkerPromise = checker.checkStdin().then(function(errors) { return [errors]; }); } // Processing specified files and dirs. if (args.length) { checkerPromise = Vow.all(args.map(checker.execute, checker)).then(function(results) { return [].concat.apply([], results); }); } checkerPromise.then(function(errorsCollection) { reporter.writer(errorsCollection); handleMaxErrors(); errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { defer.reject(2); } }); defer.resolve(0); }).fail(function(e) { console.error(e.stack); defer.reject(1); }); return returnArgs; }; |
Function handleMaxErrors | |
---|---|
✓ Was called | function handleMaxErrors() {··· if (checker.maxErrorsExceeded()) { console.error('Too many errors... Increase `maxErrors` configuration option value to see more.'); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (checker.maxErrorsExceeded()) {··· console.error('Too many errors... Increase `maxErrors` configuration option value to see more.'); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_245) | |
---|---|
✓ Was called | promise.always(function(status) {··· exit(status.valueOf()); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!config && !program.preset && !program.autoConfigure) {··· if (program.config) { console.error('Configuration source', program.config, 'was not found.'); } else { console.error('No configuration found. Add a .jscsrc file to your project root or use the -c option.'); } defer.reject(4); return returnArgs; } |
✓ Negative was executed (else) | }··· if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
Branch LogicalExpression | |
✓ Was returned | if (!config && !program.preset && !program.autoConfigure) { |
✓ Was returned | if (!config && !program.preset && !program.autoConfigure) { |
Branch LogicalExpression | |
✓ Was returned | if (!config && !program.preset && !program.autoConfigure) { |
✓ Was returned | if (!config && !program.preset && !program.autoConfigure) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (program.config) {··· console.error('Configuration source', program.config, 'was not found.'); } else { |
✓ Negative was executed (else) | } else {··· console.error('No configuration found. Add a .jscsrc file to your project root or use the -c option.'); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') {··· console.error('No input files specified. Try option --help for usage information.'); defer.reject(3); return returnArgs; } |
✓ Negative was executed (else) | }··· reporter = configFile.getReporter(program.reporter, program.colors); |
Branch LogicalExpression | |
✓ Was returned | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
✓ Was returned | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
Branch LogicalExpression | |
✓ Was returned | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
✓ Was returned | if (!args.length && process.stdin.isTTY && typeof program.autoConfigure !== 'string') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!reporter.writer) {··· console.error('Reporter "%s" does not exist.', program.reporter); returnArgs.reporter = reporter.path; defer.reject(6); return returnArgs; } |
✓ Negative was executed (else) | }··· if (!config) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!config) {··· config = {}; } |
✓ Negative was executed (else) | }··· // To run autoconfigure over all errors in the path |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (program.autoConfigure) {··· program.maxErrors = Infinity; } |
✓ Negative was executed (else) | }··· checker.getConfiguration().overrideFromCLI(program); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (program.autoConfigure) {··· var generator = new ConfigGenerator(); generator .generate(program.autoConfigure) .then(function() { defer.resolve(0); }, function(error) { console.error('Configuration generation failed due to ', error); defer.reject(7); }); return returnArgs; } |
✓ Negative was executed (else) | }··· // Handle usage like 'cat myfile.js | jscs' or 'jscs -'' |
Function (anonymous_246) | |
---|---|
✓ Was called | .then(function() {··· defer.resolve(0); }, function(error) { |
Function (anonymous_247) | |
---|---|
✓ Was called | }, function(error) {··· console.error('Configuration generation failed due to ', error); defer.reject(7); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!args.length || usedDash) {··· // So the dash doesn't register as a file if (usedDash) { args.length--; } if (program.fix) { return { promise: checker.fixStdin().then(function(result) { process.stdout.write(result.output); }), checker: checker }; } checkerPromise = checker.checkStdin().then(function(errors) { return [errors]; }); } |
✓ Negative was executed (else) | }··· // Processing specified files and dirs. |
Branch LogicalExpression | |
✓ Was returned | if (!args.length || usedDash) { |
✓ Was returned | if (!args.length || usedDash) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (usedDash) { args.length--; } |
✓ Negative was executed (else) | if (usedDash) { args.length--; }··· if (program.fix) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (program.fix) {··· return { promise: checker.fixStdin().then(function(result) { process.stdout.write(result.output); }), checker: checker }; } |
✓ Negative was executed (else) | }··· checkerPromise = checker.checkStdin().then(function(errors) { |
Function (anonymous_248) | |
---|---|
✓ Was called | promise: checker.fixStdin().then(function(result) {··· process.stdout.write(result.output); }), |
Function (anonymous_249) | |
---|---|
✓ Was called | checkerPromise = checker.checkStdin().then(function(errors) {··· return [errors]; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (args.length) {··· checkerPromise = Vow.all(args.map(checker.execute, checker)).then(function(results) { return [].concat.apply([], results); }); } |
✓ Negative was executed (else) | }··· checkerPromise.then(function(errorsCollection) { |
Function (anonymous_250) | |
---|---|
✓ Was called | checkerPromise = Vow.all(args.map(checker.execute, checker)).then(function(results) {··· return [].concat.apply([], results); }); |
Function (anonymous_251) | |
---|---|
✓ Was called | checkerPromise.then(function(errorsCollection) {··· reporter.writer(errorsCollection); handleMaxErrors(); errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { defer.reject(2); } }); defer.resolve(0); }).fail(function(e) { |
Function (anonymous_252) | |
---|---|
✓ Was called | errorsCollection.forEach(function(errors) {··· if (!errors.isEmpty()) { defer.reject(2); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!errors.isEmpty()) {··· defer.reject(2); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_253) | |
---|---|
✓ Was called | }).fail(function(e) {··· console.error(e.stack); defer.reject(1); }); |
Function Generator | |
---|---|
✓ Was called | function Generator() {··· this._config = {}; } |
Function (anonymous_255) | |
---|---|
✓ Was called | Generator.prototype.generate = function(path) {··· var checker = getChecker(); var _path = utils.normalizePath(path, checker.getConfiguration().getBasePath()); var presetNames = Object.keys(checker.getConfiguration().getRegisteredPresets()); var statsForPresets; console.log('Checking', _path, 'against the presets'); return Vow .all(presetNames.map(this._checkAgainstPreset.bind(this, _path))) .then(function(resultsPerPreset) { statsForPresets = this._generateStatsForPresets(resultsPerPreset, presetNames); return statsForPresets; }.bind(this)) .then(this._showErrorCounts.bind(this)) .then(this._getUserPresetChoice.bind(this, prompts[0])) .then(function showViolatedRules(choiceObj) { var presetIndex = choiceObj[prompts[0].name] - 1; var presetName = statsForPresets[presetIndex].name; console.log('You chose the ' + presetName + ' preset'); this._config.preset = presetName; var errorStats = getErrorsByRuleName(statsForPresets[presetIndex].errors); var violatedRuleCount = Object.keys(errorStats).length; if (!violatedRuleCount) { return this._config; } console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); var errorPrompts = generateRuleHandlingPrompts(errorStats); return this._getUserViolationChoices(errorPrompts) .then(this._handleViolatedRules.bind(this, errorPrompts)) .then(function() { return this._config; }.bind(this)); }.bind(this)) .then(function flushConfig() { fs.writeFileSync(process.cwd() + '/.jscsrc', JSON.stringify(this._config, null, '\t')); console.log('Generated a .jscsrc configuration file in ' + process.cwd()); }.bind(this)); }; |
Function (anonymous_256) | |
---|---|
✓ Was called | .then(function(resultsPerPreset) {··· statsForPresets = this._generateStatsForPresets(resultsPerPreset, presetNames); return statsForPresets; }.bind(this)) |
Function showViolatedRules | |
---|---|
✓ Was called | .then(function showViolatedRules(choiceObj) {··· var presetIndex = choiceObj[prompts[0].name] - 1; var presetName = statsForPresets[presetIndex].name; console.log('You chose the ' + presetName + ' preset'); this._config.preset = presetName; var errorStats = getErrorsByRuleName(statsForPresets[presetIndex].errors); var violatedRuleCount = Object.keys(errorStats).length; if (!violatedRuleCount) { return this._config; } console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); var errorPrompts = generateRuleHandlingPrompts(errorStats); return this._getUserViolationChoices(errorPrompts) .then(this._handleViolatedRules.bind(this, errorPrompts)) .then(function() { return this._config; }.bind(this)); }.bind(this)) |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!violatedRuleCount) { return this._config; } |
✓ Negative was executed (else) | if (!violatedRuleCount) { return this._config; }··· console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); |
✗ Negative was not returned (: ...) | console.log(_path + ' violates ' + violatedRuleCount + ' rule' + (violatedRuleCount > 1 ? 's' : '')); |
Function (anonymous_258) | |
---|---|
✗ Was not called | .then(function() {··· return this._config; }.bind(this)); |
Function flushConfig | |
---|---|
✗ Was not called | .then(function flushConfig() {··· fs.writeFileSync(process.cwd() + '/.jscsrc', JSON.stringify(this._config, null, '\t')); console.log('Generated a .jscsrc configuration file in ' + process.cwd()); }.bind(this)); |
Function (anonymous_260) | |
---|---|
✓ Was called | Generator.prototype._generateStatsForPresets = function(resultsPerPreset, presetNames) {··· return resultsPerPreset.map(function(presetResults, idx) { var errorCollection = [].concat.apply([], presetResults); var presetStats = { name: presetNames[idx], sum: 0, errors: [] }; errorCollection.forEach(function(error) { presetStats.sum += error.getErrorCount(); presetStats.errors = presetStats.errors.concat(error.getErrorList()); }); return presetStats; }); }; |
Function (anonymous_261) | |
---|---|
✓ Was called | return resultsPerPreset.map(function(presetResults, idx) {··· var errorCollection = [].concat.apply([], presetResults); var presetStats = { name: presetNames[idx], sum: 0, errors: [] }; errorCollection.forEach(function(error) { presetStats.sum += error.getErrorCount(); presetStats.errors = presetStats.errors.concat(error.getErrorList()); }); return presetStats; }); |
Function (anonymous_262) | |
---|---|
✓ Was called | errorCollection.forEach(function(error) {··· presetStats.sum += error.getErrorCount(); presetStats.errors = presetStats.errors.concat(error.getErrorList()); }); |
Function (anonymous_263) | |
---|---|
✓ Was called | Generator.prototype._showErrorCounts = function(statsForPresets) {··· var table = getTable(); statsForPresets.forEach(function(presetStats, idx) { table.push([idx + 1, presetStats.name, presetStats.sum, getUniqueErrorNames(presetStats.errors).length]); }); console.log(table.toString()); }; |
Function (anonymous_264) | |
---|---|
✓ Was called | statsForPresets.forEach(function(presetStats, idx) {··· table.push([idx + 1, presetStats.name, presetStats.sum, getUniqueErrorNames(presetStats.errors).length]); }); |
Function (anonymous_265) | |
---|---|
✓ Was called | Generator.prototype._getUserPresetChoice = function(prompt) {··· return this._showPrompt(prompt); }; |
Function (anonymous_266) | |
---|---|
✓ Was called | Generator.prototype._getUserViolationChoices = function(errorPrompts) {··· return this._showPrompt(errorPrompts); }; |
Function (anonymous_267) | |
---|---|
✗ Was not called | Generator.prototype._handleViolatedRules = function(errorPrompts, choices) {··· errorPrompts.forEach(function(errorPrompt) { var userChoice = choices[errorPrompt.name]; if (userChoice && userChoice.toLowerCase() === 'e') { this._config[errorPrompt.associatedRuleName] = null; } }, this); }; |
Function (anonymous_268) | |
---|---|
✗ Was not called | errorPrompts.forEach(function(errorPrompt) {··· var userChoice = choices[errorPrompt.name]; if (userChoice && userChoice.toLowerCase() === 'e') { this._config[errorPrompt.associatedRuleName] = null; } }, this); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (userChoice && userChoice.toLowerCase() === 'e') {··· this._config[errorPrompt.associatedRuleName] = null; } |
✗ Negative was not executed (else) | }··· }, this); |
Branch LogicalExpression | |
✗ Was not returned | if (userChoice && userChoice.toLowerCase() === 'e') { |
✗ Was not returned | if (userChoice && userChoice.toLowerCase() === 'e') { |
Function (anonymous_269) | |
---|---|
✓ Was called | Generator.prototype._checkAgainstPreset = function(path, presetName) {··· var checker = getChecker(); checker.configure({preset: presetName, maxErrors: Infinity}); return checker.checkPath(path); }; |
Function getChecker | |
---|---|
✓ Was called | function getChecker() {··· var checker = new Checker(); checker.registerDefaultRules(); return checker; } |
Function generateRuleHandlingPrompts | |
---|---|
✓ Was called | function generateRuleHandlingPrompts(errors) {··· // Generate list of rule names, sorted by violation count (descending) var violatedRuleNames = Object.keys(errors); violatedRuleNames.sort(function(a, b) { return errors[b].violations - errors[a].violations; }); return violatedRuleNames.map(function(ruleName) { var violationCount = errors[ruleName].violations; var fileCount = Object.keys(errors[ruleName].files).length; var prompt = assign({}, prompts[1]); prompt.associatedRuleName = ruleName; prompt.name = chalk.green(ruleName) + ' (' + violationCount + ' violation' + (violationCount > 1 ? 's' : '') + ' in ' + fileCount + ' file' + (fileCount > 1 ? 's' : '') + '):\n ' + prompt.name; return prompt; }); } |
Function (anonymous_272) | |
---|---|
✓ Was called | violatedRuleNames.sort(function(a, b) {··· return errors[b].violations - errors[a].violations; }); |
Function (anonymous_273) | |
---|---|
✓ Was called | return violatedRuleNames.map(function(ruleName) {··· var violationCount = errors[ruleName].violations; var fileCount = Object.keys(errors[ruleName].files).length; var prompt = assign({}, prompts[1]); prompt.associatedRuleName = ruleName; prompt.name = chalk.green(ruleName) + ' (' + violationCount + ' violation' + (violationCount > 1 ? 's' : '') + ' in ' + fileCount + ' file' + (fileCount > 1 ? 's' : '') + '):\n ' + prompt.name; return prompt; }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | ' (' + violationCount + ' violation' + (violationCount > 1 ? 's' : '') + |
✓ Negative was returned (: ...) | ' (' + violationCount + ' violation' + (violationCount > 1 ? 's' : '') + |
Branch ConditionalExpression | |
---|---|
✗ Positive was not returned (? ...) | ' in ' + fileCount + ' file' + (fileCount > 1 ? 's' : '') + '):\n ' + |
✓ Negative was returned (: ...) | ' in ' + fileCount + ' file' + (fileCount > 1 ? 's' : '') + '):\n ' + |
Function getErrorsByRuleName | |
---|---|
✓ Was called | function getErrorsByRuleName(errorsList) {··· var errors = {}; errorsList.forEach(function(error) { var rulename = error.rule; errors[rulename] = errors[rulename] || { files: {}, violations: 0 }; errors[rulename].violations += 1; errors[rulename].files[error.filename] = true; }); return errors; } |
Function (anonymous_275) | |
---|---|
✓ Was called | errorsList.forEach(function(error) {··· var rulename = error.rule; errors[rulename] = errors[rulename] || { files: {}, violations: 0 }; errors[rulename].violations += 1; errors[rulename].files[error.filename] = true; }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | errors[rulename] = errors[rulename] || {··· files: {}, violations: 0 }; |
✓ Was returned | errors[rulename] = errors[rulename] || { |
Function getUniqueErrorNames | |
---|---|
✓ Was called | function getUniqueErrorNames(errorsList) {··· var errorNameLUT = {}; errorsList.forEach(function(error) { errorNameLUT[error.rule] = true; }); return Object.keys(errorNameLUT); } |
Function (anonymous_277) | |
---|---|
✓ Was called | errorsList.forEach(function(error) {··· errorNameLUT[error.rule] = true; }); |
Function getTable | |
---|---|
✓ Was called | function getTable() {··· return new Table({ chars: { top: '', 'top-mid': '', 'top-left': '', 'top-right': '', bottom: '', 'bottom-mid': '', 'bottom-left': '', 'bottom-right': '', left: '', 'left-mid': '', mid: '', 'mid-mid': '', right: '', 'right-mid': '' , middle: ' ' }, style: { 'padding-left': 0, 'padding-right': 0 }, head: ['', 'Preset', '#Errors', '#Rules'] }); } |
Function escapeAttrValue | |
---|---|
✓ Was called | function escapeAttrValue(attrValue) {··· return String(attrValue) .replace(/&/g, '&') .replace(/"/g, '"') .replace(/</g, '<') .replace(/>/g, '>'); } |
Function (anonymous_280) | |
---|---|
✓ Was called | module.exports = function(errorCollection) {··· console.log('<?xml version="1.0" encoding="utf-8"?>\n<checkstyle version="4.3">'); errorCollection.forEach(function(errors) { console.log(' <file name="' + escapeAttrValue(errors.getFilename()) + '">'); errors.getErrorList().forEach(function(error) { console.log( ' <error ' + 'line="' + error.line + '" ' + 'column="' + (error.column + 1) + '" ' + 'severity="error" ' + 'message="' + escapeAttrValue(error.message) + '" ' + 'source="jscs" />' ); }); console.log(' </file>'); }); console.log('</checkstyle>'); }; |
Function (anonymous_281) | |
---|---|
✓ Was called | errorCollection.forEach(function(errors) {··· console.log(' <file name="' + escapeAttrValue(errors.getFilename()) + '">'); errors.getErrorList().forEach(function(error) { console.log( ' <error ' + 'line="' + error.line + '" ' + 'column="' + (error.column + 1) + '" ' + 'severity="error" ' + 'message="' + escapeAttrValue(error.message) + '" ' + 'source="jscs" />' ); }); console.log(' </file>'); }); |
Function (anonymous_282) | |
---|---|
✓ Was called | errors.getErrorList().forEach(function(error) {··· console.log( ' <error ' + 'line="' + error.line + '" ' + 'column="' + (error.column + 1) + '" ' + 'severity="error" ' + 'message="' + escapeAttrValue(error.message) + '" ' + 'source="jscs" />' ); }); |
Function (anonymous_283) | |
---|---|
✓ Was called | module.exports = function(errorsCollection) {··· var errorCount = 0; /** * Formatting every error set. */ errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error, true) + '\n'); }); } }); if (errorCount) { /** * Printing summary. */ console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); } }; |
Function (anonymous_284) | |
---|---|
✓ Was called | errorsCollection.forEach(function(errors) {··· if (!errors.isEmpty()) { /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error, true) + '\n'); }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!errors.isEmpty()) {··· /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error, true) + '\n'); }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_285) | |
---|---|
✓ Was called | errors.getErrorList().forEach(function(error) {··· errorCount++; console.log(errors.explainError(error, true) + '\n'); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (errorCount) {··· /** * Printing summary. */ console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); } |
✓ Negative was executed (else) | }··· }; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); |
✓ Negative was returned (: ...) | console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); |
Function (anonymous_286) | |
---|---|
✓ Was called | module.exports = function(errorsCollection) {··· var errorCount = 0; /** * Formatting every error set. */ errorsCollection.forEach(function(errors) { var file = errors.getFilename(); if (!errors.isEmpty()) { errors.getErrorList().forEach(function(error) { errorCount++; console.log(util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message)); }); } }); }; |
Function (anonymous_287) | |
---|---|
✓ Was called | errorsCollection.forEach(function(errors) {··· var file = errors.getFilename(); if (!errors.isEmpty()) { errors.getErrorList().forEach(function(error) { errorCount++; console.log(util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message)); }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!errors.isEmpty()) {··· errors.getErrorList().forEach(function(error) { errorCount++; console.log(util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message)); }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_288) | |
---|---|
✓ Was called | errors.getErrorList().forEach(function(error) {··· errorCount++; console.log(util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message)); }); |
Function (anonymous_289) | |
---|---|
✓ Was called | module.exports = function(errorsCollection) {··· errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { var file = errors.getFilename(); var out = errors.getErrorList().map(function(error) { return util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message); }); console.log(out.join('\n')); } }); }; |
Function (anonymous_290) | |
---|---|
✓ Was called | errorsCollection.forEach(function(errors) {··· if (!errors.isEmpty()) { var file = errors.getFilename(); var out = errors.getErrorList().map(function(error) { return util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message); }); console.log(out.join('\n')); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!errors.isEmpty()) {··· var file = errors.getFilename(); var out = errors.getErrorList().map(function(error) { return util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message); }); console.log(out.join('\n')); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_291) | |
---|---|
✓ Was called | var out = errors.getErrorList().map(function(error) {··· return util.format('%s: line %d, col %d, %s', file, error.line, error.column, error.message); }); |
Function (anonymous_292) | |
---|---|
✓ Was called | module.exports = function(errorsCollection) {··· var jsonOutput = {}; var anyError = false; errorsCollection.forEach(function(errors) { var file = errors.getFilename(); var arr = jsonOutput[file] = []; if (!errors.isEmpty()) { anyError = true; } errors.getErrorList().forEach(function(error) { arr.push({ line: error.line, column: error.column + 1, message: error.message }); }); }); if (anyError) { console.log(JSON.stringify(jsonOutput)); } }; |
Function (anonymous_293) | |
---|---|
✓ Was called | errorsCollection.forEach(function(errors) {··· var file = errors.getFilename(); var arr = jsonOutput[file] = []; if (!errors.isEmpty()) { anyError = true; } errors.getErrorList().forEach(function(error) { arr.push({ line: error.line, column: error.column + 1, message: error.message }); }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!errors.isEmpty()) {··· anyError = true; } |
✓ Negative was executed (else) | }··· errors.getErrorList().forEach(function(error) { |
Function (anonymous_294) | |
---|---|
✓ Was called | errors.getErrorList().forEach(function(error) {··· arr.push({ line: error.line, column: error.column + 1, message: error.message }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (anyError) {··· console.log(JSON.stringify(jsonOutput)); } |
✓ Negative was executed (else) | }··· }; |
Function (anonymous_295) | |
---|---|
✓ Was called | module.exports = function(errorCollection) {··· var i = 0; var testsuite = xml.create('testsuite'); testsuite.att('name', 'JSCS'); testsuite.att('tests', errorCollection.length); errorCollection.forEach(function(errors) { var errorsCount = errors.getErrorCount(); var testcase = testsuite.ele('testcase', { name: errors.getFilename(), failures: errorsCount }); i += errorsCount; errors.getErrorList().forEach(function(error) { testcase.ele('failure', {}, errors.explainError(error)); }); }); testsuite.att('failures', i); console.log(testsuite.end({pretty: true})); }; |
Function (anonymous_296) | |
---|---|
✓ Was called | errorCollection.forEach(function(errors) {··· var errorsCount = errors.getErrorCount(); var testcase = testsuite.ele('testcase', { name: errors.getFilename(), failures: errorsCount }); i += errorsCount; errors.getErrorList().forEach(function(error) { testcase.ele('failure', {}, errors.explainError(error)); }); }); |
Function (anonymous_297) | |
---|---|
✓ Was called | errors.getErrorList().forEach(function(error) {··· testcase.ele('failure', {}, errors.explainError(error)); }); |
Function (anonymous_298) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_299) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_300) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowAnonymousFunctions'; }, |
Function (anonymous_301) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['FunctionExpression', 'FunctionDeclaration'], function(node) { if (node.id === null) { errors.add('Anonymous functions need to be named', node); } }); } |
Function (anonymous_302) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionExpression', 'FunctionDeclaration'], function(node) {··· if (node.id === null) { errors.add('Anonymous functions need to be named', node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.id === null) {··· errors.add('Anonymous functions need to be named', node); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_303) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_304) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_305) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowArrayDestructuringReturn'; }, |
Function (anonymous_306) | |
---|---|
✓ Was called | check: function(file, errors) {··· var addError = function(node) { errors.add( 'Array destructuring is not allowed for return, ' + 'use object destructuring instead', node ); }; var isViolationDetected = function(maybeArrayPattern, maybeCallExpression) { return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; }; file.iterateNodesByType(['VariableDeclaration', 'AssignmentExpression'], function(node) { if (node.type === 'VariableDeclaration') { node.declarations.forEach(function(declaration) { if (!isViolationDetected(declaration.id, declaration.init)) { return; } addError(declaration.init); }); } if (node.type === 'AssignmentExpression') { if (!isViolationDetected(node.left, node.right)) { return; } addError(node.right); } }); } |
Function (anonymous_307) | |
---|---|
✓ Was called | var addError = function(node) {··· errors.add( 'Array destructuring is not allowed for return, ' + 'use object destructuring instead', node ); }; |
Function (anonymous_308) | |
---|---|
✓ Was called | var isViolationDetected = function(maybeArrayPattern, maybeCallExpression) {··· return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; }; |
Branch LogicalExpression | |
---|---|
✓ Was returned | maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; |
✗ Was not returned | return maybeCallExpression && maybeCallExpression.type === 'CallExpression' &&··· maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; |
Branch LogicalExpression | |
✓ Was returned | maybeArrayPattern && maybeArrayPattern.type === 'ArrayPattern'; |
✗ Was not returned | return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && |
Branch LogicalExpression | |
✓ Was returned | return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && |
✗ Was not returned | return maybeCallExpression && maybeCallExpression.type === 'CallExpression' && |
Function (anonymous_309) | |
---|---|
✓ Was called | file.iterateNodesByType(['VariableDeclaration', 'AssignmentExpression'], function(node) {··· if (node.type === 'VariableDeclaration') { node.declarations.forEach(function(declaration) { if (!isViolationDetected(declaration.id, declaration.init)) { return; } addError(declaration.init); }); } if (node.type === 'AssignmentExpression') { if (!isViolationDetected(node.left, node.right)) { return; } addError(node.right); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'VariableDeclaration') {··· node.declarations.forEach(function(declaration) { if (!isViolationDetected(declaration.id, declaration.init)) { return; } addError(declaration.init); }); } |
✓ Negative was executed (else) | }··· if (node.type === 'AssignmentExpression') { |
Function (anonymous_310) | |
---|---|
✓ Was called | node.declarations.forEach(function(declaration) {··· if (!isViolationDetected(declaration.id, declaration.init)) { return; } addError(declaration.init); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!isViolationDetected(declaration.id, declaration.init)) {··· return; } |
✓ Negative was executed (else) | }··· addError(declaration.init); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'AssignmentExpression') {··· if (!isViolationDetected(node.left, node.right)) { return; } addError(node.right); } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!isViolationDetected(node.left, node.right)) {··· return; } |
✓ Negative was executed (else) | }··· addError(node.right); |
Function (anonymous_311) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_312) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_313) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowArrowFunctions'; }, |
Function (anonymous_314) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ArrowFunctionExpression'], function(node) { errors.add('Do not use arrow functions', node); }); } |
Function (anonymous_315) | |
---|---|
✓ Was called | file.iterateNodesByType(['ArrowFunctionExpression'], function(node) {··· errors.add('Do not use arrow functions', node); }); |
Function (anonymous_316) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_317) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_318) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowCapitalizedComments'; }, |
Function (anonymous_319) | |
---|---|
✓ Was called | check: function(file, errors) {··· var letterPattern = require('../../patterns/L'); var lowerCasePattern = require('../../patterns/Ll'); file.iterateTokensByType(['CommentLine', 'CommentBlock'], function(comment) { var stripped = comment.value.replace(/[\n\s\*]/g, ''); var firstChar = stripped[0]; if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) { errors.add( 'Comments must start with a lowercase letter', comment ); } }); } |
Function (anonymous_320) | |
---|---|
✓ Was called | file.iterateTokensByType(['CommentLine', 'CommentBlock'], function(comment) {··· var stripped = comment.value.replace(/[\n\s\*]/g, ''); var firstChar = stripped[0]; if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) { errors.add( 'Comments must start with a lowercase letter', comment ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) {··· errors.add( 'Comments must start with a lowercase letter', comment ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) { |
✓ Was returned | if (letterPattern.test(firstChar) && !lowerCasePattern.test(firstChar)) { |
Function (anonymous_321) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_322) | |
---|---|
✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); if (typeof options !== 'object') { assert( options === true, optionName + ' option requires either a true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } assert( Array.isArray(options.allExcept), 'Property `allExcept` in ' + optionName + ' should be an array of strings' ); this._exceptFunction = options.allExcept.indexOf('function') > -1; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, optionName + ' option requires either a true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
✓ Negative was executed (else) | }··· assert( |
Function (anonymous_323) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowCommaBeforeLineBreak'; }, |
Function (anonymous_324) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptFunction = this._exceptFunction; function canSkip(token) { var node = token.parentElement; if (node.getNewlineCount() === 0) { return true; } // exception for function params if ( node.params && file.isOnTheSameLine(node.params[0], node.params[node.params.length - 1]) ) { return true; } // See #1841 if (!exceptFunction || !node.properties) { return false; } return node.properties.some(function(property) { return property.value.type === 'FunctionExpression'; }); } file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var nextToken = token.getNextCodeToken(); if (canSkip(token) || nextToken.value === ',') { return; } errors.assert.sameLine({ token: token, nextToken: nextToken, message: 'Commas should be placed on the same line as value' }); errors.assert.differentLine({ token: token.getPreviousCodeToken(), nextToken: token, message: 'Commas should be placed on new line' }); }); } |
Function canSkip | |
---|---|
✓ Was called | function canSkip(token) {··· var node = token.parentElement; if (node.getNewlineCount() === 0) { return true; } // exception for function params if ( node.params && file.isOnTheSameLine(node.params[0], node.params[node.params.length - 1]) ) { return true; } // See #1841 if (!exceptFunction || !node.properties) { return false; } return node.properties.some(function(property) { return property.value.type === 'FunctionExpression'; }); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.getNewlineCount() === 0) {··· return true; } |
✓ Negative was executed (else) | }··· // exception for function params |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return true; } |
✓ Negative was executed (else) | }··· // See #1841 |
Branch LogicalExpression | |
---|---|
✓ Was returned | file.isOnTheSameLine(node.params[0], node.params[node.params.length - 1]) |
✓ Was returned | node.params && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!exceptFunction || !node.properties) {··· return false; } |
✓ Negative was executed (else) | }··· return node.properties.some(function(property) { |
Branch LogicalExpression | |
✓ Was returned | if (!exceptFunction || !node.properties) { |
✓ Was returned | if (!exceptFunction || !node.properties) { |
Function (anonymous_326) | |
---|---|
✓ Was called | return node.properties.some(function(property) {··· return property.value.type === 'FunctionExpression'; }); |
Function (anonymous_327) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var nextToken = token.getNextCodeToken(); if (canSkip(token) || nextToken.value === ',') { return; } errors.assert.sameLine({ token: token, nextToken: nextToken, message: 'Commas should be placed on the same line as value' }); errors.assert.differentLine({ token: token.getPreviousCodeToken(), nextToken: token, message: 'Commas should be placed on new line' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (canSkip(token) || nextToken.value === ',') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.sameLine({ |
Branch LogicalExpression | |
✓ Was returned | if (canSkip(token) || nextToken.value === ',') { |
✓ Was returned | if (canSkip(token) || nextToken.value === ',') { |
Function (anonymous_328) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_329) | |
---|---|
✓ Was called | configure: function(statementTypes) {··· assert( Array.isArray(statementTypes) || statementTypes === true, this.getOptionName() + ' option requires array or true value' ); if (statementTypes === true) { statementTypes = defaultKeywords; } this._typeIndex = {}; statementTypes.forEach(function(type) { this._typeIndex[type] = true; }.bind(this)); }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(statementTypes) || statementTypes === true, |
✓ Was returned | Array.isArray(statementTypes) || statementTypes === true, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (statementTypes === true) {··· statementTypes = defaultKeywords; } |
✓ Negative was executed (else) | }··· this._typeIndex = {}; |
Function (anonymous_330) | |
---|---|
✓ Was called | statementTypes.forEach(function(type) {··· this._typeIndex[type] = true; }.bind(this)); |
Function (anonymous_331) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowCurlyBraces'; }, |
Function (anonymous_332) | |
---|---|
✓ Was called | check: function(file, errors) {··· function isSingleBlockStatement(node) { return node && node.type === 'BlockStatement' && node.body.length === 1; } function addError(typeString, entity) { errors.add( typeString + ' statement with extra curly braces', entity ); } function checkBody(type, typeString) { file.iterateNodesByType(type, function(node) { if (isSingleBlockStatement(node.body)) { addError(typeString, node); } }); } var typeIndex = this._typeIndex; if (typeIndex.if || typeIndex.else) { file.iterateNodesByType('IfStatement', function(node) { if (typeIndex.if && isSingleBlockStatement(node.consequent)) { addError('If', node); } if (typeIndex.else && isSingleBlockStatement(node.alternate)) { addError('Else', node.alternate.getFirstToken()); } }); } if (typeIndex.while) { checkBody('WhileStatement', 'While'); } if (typeIndex.for) { checkBody('ForStatement', 'For'); checkBody('ForInStatement', 'For in'); checkBody('ForOfStatement', 'For of'); } if (typeIndex.do) { checkBody('DoWhileStatement', 'Do while'); } if (typeIndex.with) { checkBody('WithStatement', 'With'); } } |
Function isSingleBlockStatement | |
---|---|
✓ Was called | function isSingleBlockStatement(node) {··· return node && node.type === 'BlockStatement' && node.body.length === 1; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | node.body.length === 1; |
✓ Was returned | return node && node.type === 'BlockStatement' && |
Branch LogicalExpression | |
✓ Was returned | return node && node.type === 'BlockStatement' && |
✓ Was returned | return node && node.type === 'BlockStatement' && |
Function addError | |
---|---|
✓ Was called | function addError(typeString, entity) {··· errors.add( typeString + ' statement with extra curly braces', entity ); } |
Function checkBody | |
---|---|
✓ Was called | function checkBody(type, typeString) {··· file.iterateNodesByType(type, function(node) { if (isSingleBlockStatement(node.body)) { addError(typeString, node); } }); } |
Function (anonymous_336) | |
---|---|
✓ Was called | file.iterateNodesByType(type, function(node) {··· if (isSingleBlockStatement(node.body)) { addError(typeString, node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isSingleBlockStatement(node.body)) {··· addError(typeString, node); } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.if || typeIndex.else) {··· file.iterateNodesByType('IfStatement', function(node) { if (typeIndex.if && isSingleBlockStatement(node.consequent)) { addError('If', node); } if (typeIndex.else && isSingleBlockStatement(node.alternate)) { addError('Else', node.alternate.getFirstToken()); } }); } |
✓ Negative was executed (else) | }··· if (typeIndex.while) { |
Branch LogicalExpression | |
✓ Was returned | if (typeIndex.if || typeIndex.else) { |
✓ Was returned | if (typeIndex.if || typeIndex.else) { |
Function (anonymous_337) | |
---|---|
✓ Was called | file.iterateNodesByType('IfStatement', function(node) {··· if (typeIndex.if && isSingleBlockStatement(node.consequent)) { addError('If', node); } if (typeIndex.else && isSingleBlockStatement(node.alternate)) { addError('Else', node.alternate.getFirstToken()); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.if && isSingleBlockStatement(node.consequent)) {··· addError('If', node); } |
✓ Negative was executed (else) | }··· if (typeIndex.else && isSingleBlockStatement(node.alternate)) { |
Branch LogicalExpression | |
✓ Was returned | if (typeIndex.if && isSingleBlockStatement(node.consequent)) { |
✓ Was returned | if (typeIndex.if && isSingleBlockStatement(node.consequent)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.else && isSingleBlockStatement(node.alternate)) {··· addError('Else', node.alternate.getFirstToken()); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (typeIndex.else && isSingleBlockStatement(node.alternate)) { |
✓ Was returned | if (typeIndex.else && isSingleBlockStatement(node.alternate)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.while) {··· checkBody('WhileStatement', 'While'); } |
✓ Negative was executed (else) | }··· if (typeIndex.for) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.for) {··· checkBody('ForStatement', 'For'); checkBody('ForInStatement', 'For in'); checkBody('ForOfStatement', 'For of'); } |
✓ Negative was executed (else) | }··· if (typeIndex.do) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.do) {··· checkBody('DoWhileStatement', 'Do while'); } |
✓ Negative was executed (else) | }··· if (typeIndex.with) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.with) {··· checkBody('WithStatement', 'With'); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_338) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_339) | |
---|---|
✓ Was called | configure: function(identifiers) {··· assert( identifiers === true || typeof identifiers === 'object', this.getOptionName() + ' option requires the value `true` ' + 'or an object with String[] `allExcept` property' ); // verify first item in `allExcept` property in object (if it's an object) assert( typeof identifiers !== 'object' || Array.isArray(identifiers.allExcept) && typeof identifiers.allExcept[0] === 'string', 'Property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); var isTrue = identifiers === true; var defaultIdentifiers = [ '__proto__', '_', '__dirname', '__filename', 'super_' ]; if (isTrue) { identifiers = defaultIdentifiers; } else { identifiers = (identifiers.allExcept).concat(defaultIdentifiers); } this._identifierIndex = identifiers; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof identifiers === 'object', |
✓ Was returned | identifiers === true || |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(identifiers.allExcept) &&··· typeof identifiers.allExcept[0] === 'string', |
✓ Was returned | typeof identifiers !== 'object' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof identifiers.allExcept[0] === 'string', |
✓ Was returned | Array.isArray(identifiers.allExcept) && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· identifiers = defaultIdentifiers; } else { |
✓ Negative was executed (else) | } else {··· identifiers = (identifiers.allExcept).concat(defaultIdentifiers); } |
Function (anonymous_340) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowDanglingUnderscores'; }, |
Function (anonymous_341) | |
---|---|
✓ Was called | check: function(file, errors) {··· var allowedIdentifiers = this._identifierIndex; file.iterateTokensByType('Identifier', function(token) { var value = token.value; if ((value[0] === '_' || value.slice(-1) === '_') && allowedIdentifiers.indexOf(value) < 0 ) { errors.add( 'Invalid dangling underscore found', token ); } }); } |
Function (anonymous_342) | |
---|---|
✓ Was called | file.iterateTokensByType('Identifier', function(token) {··· var value = token.value; if ((value[0] === '_' || value.slice(-1) === '_') && allowedIdentifiers.indexOf(value) < 0 ) { errors.add( 'Invalid dangling underscore found', token ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add( 'Invalid dangling underscore found', token ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | allowedIdentifiers.indexOf(value) < 0 |
✓ Was returned | if ((value[0] === '_' || value.slice(-1) === '_') && |
Branch LogicalExpression | |
✓ Was returned | if ((value[0] === '_' || value.slice(-1) === '_') && |
✓ Was returned | if ((value[0] === '_' || value.slice(-1) === '_') && |
Function (anonymous_343) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_344) | |
---|---|
✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); if (typeof options !== 'object') { assert( options === true, optionName + ' option requires a true value or an object like: { allExcept: [\'comments\'] }' ); var _options = { allExcept: [] }; return this.configure(_options); } assert( Array.isArray(options.allExcept), 'Property `allExcept` in ' + optionName + ' should be an array of strings' ); this._exceptComments = options.allExcept.indexOf('comments') > -1; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, optionName + ' option requires a true value or an object like: { allExcept: [\'comments\'] }' ); var _options = { allExcept: [] }; return this.configure(_options); } |
✓ Negative was executed (else) | }··· assert( |
Function (anonymous_345) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowEmptyBlocks'; }, |
Function (anonymous_346) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptComments = this._exceptComments; function canSkip(token) { if (!exceptComments) { return false; } var canSkipToken = false; var tokenLoc = token.getLoc(); file.getComments().forEach(function(comment) { var commentLoc = comment.getLoc(); if (commentLoc.start.line >= tokenLoc.start.line && commentLoc.end.line <= tokenLoc.end.line) { canSkipToken = true; } }); return canSkipToken; } file.iterateNodesByType('BlockStatement', function(node) { if (node.body.length) { return true; } if (canSkip(node)) { return true; } if (node.parentElement.type !== 'CatchClause' && node.parentElement.type !== 'FunctionDeclaration' && node.parentElement.type !== 'FunctionExpression' && node.parentElement.type !== 'ArrowFunctionExpression' && node.parentElement.type !== 'ObjectMethod') { errors.add('Empty block found', node.lastChild); } }); } |
Function canSkip | |
---|---|
✓ Was called | function canSkip(token) {··· if (!exceptComments) { return false; } var canSkipToken = false; var tokenLoc = token.getLoc(); file.getComments().forEach(function(comment) { var commentLoc = comment.getLoc(); if (commentLoc.start.line >= tokenLoc.start.line && commentLoc.end.line <= tokenLoc.end.line) { canSkipToken = true; } }); return canSkipToken; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!exceptComments) {··· return false; } |
✓ Negative was executed (else) | }··· var canSkipToken = false; |
Function (anonymous_348) | |
---|---|
✓ Was called | file.getComments().forEach(function(comment) {··· var commentLoc = comment.getLoc(); if (commentLoc.start.line >= tokenLoc.start.line && commentLoc.end.line <= tokenLoc.end.line) { canSkipToken = true; } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | commentLoc.end.line <= tokenLoc.end.line) {··· canSkipToken = true; } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | commentLoc.end.line <= tokenLoc.end.line) { |
✓ Was returned | if (commentLoc.start.line >= tokenLoc.start.line && |
Function (anonymous_349) | |
---|---|
✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· if (node.body.length) { return true; } if (canSkip(node)) { return true; } if (node.parentElement.type !== 'CatchClause' && node.parentElement.type !== 'FunctionDeclaration' && node.parentElement.type !== 'FunctionExpression' && node.parentElement.type !== 'ArrowFunctionExpression' && node.parentElement.type !== 'ObjectMethod') { errors.add('Empty block found', node.lastChild); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.body.length) {··· return true; } |
✓ Negative was executed (else) | }··· if (canSkip(node)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (canSkip(node)) {··· return true; } |
✓ Negative was executed (else) | }··· if (node.parentElement.type !== 'CatchClause' && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.parentElement.type !== 'ObjectMethod') {··· errors.add('Empty block found', node.lastChild); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type !== 'ObjectMethod') { |
✓ Was returned | if (node.parentElement.type !== 'CatchClause' &&··· node.parentElement.type !== 'FunctionDeclaration' && node.parentElement.type !== 'FunctionExpression' && node.parentElement.type !== 'ArrowFunctionExpression' && |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type !== 'ArrowFunctionExpression' && |
✓ Was returned | if (node.parentElement.type !== 'CatchClause' &&··· node.parentElement.type !== 'FunctionDeclaration' && node.parentElement.type !== 'FunctionExpression' && |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type !== 'FunctionExpression' && |
✓ Was returned | if (node.parentElement.type !== 'CatchClause' &&··· node.parentElement.type !== 'FunctionDeclaration' && |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type !== 'FunctionDeclaration' && |
✓ Was returned | if (node.parentElement.type !== 'CatchClause' && |
Function (anonymous_350) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_351) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_352) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowFunctionDeclarations'; }, |
Function (anonymous_353) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('FunctionDeclaration', function(node) { errors.add('Illegal function declaration', node); }); } |
Function (anonymous_354) | |
---|---|
✓ Was called | file.iterateNodesByType('FunctionDeclaration', function(node) {··· errors.add('Illegal function declaration', node); }); |
Function (anonymous_355) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_356) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_357) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowIdenticalDestructuringNames'; }, |
Function (anonymous_358) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ObjectPattern'], function(node) { var props = node.properties; for (var i = 0; i < props.length; i++) { var prop = props[i]; if (prop.type === 'ObjectProperty' && !prop.shorthand && !prop.computed && prop.key.name === prop.value.name) { errors.add('Use the shorthand form of destructuring instead', prop); } } }); } |
Function (anonymous_359) | |
---|---|
✓ Was called | file.iterateNodesByType(['ObjectPattern'], function(node) {··· var props = node.properties; for (var i = 0; i < props.length; i++) { var prop = props[i]; if (prop.type === 'ObjectProperty' && !prop.shorthand && !prop.computed && prop.key.name === prop.value.name) { errors.add('Use the shorthand form of destructuring instead', prop); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | prop.key.name === prop.value.name) {··· errors.add('Use the shorthand form of destructuring instead', prop); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | prop.key.name === prop.value.name) { |
✓ Was returned | if (prop.type === 'ObjectProperty' && !prop.shorthand && !prop.computed && |
Branch LogicalExpression | |
✓ Was returned | if (prop.type === 'ObjectProperty' && !prop.shorthand && !prop.computed && |
✓ Was returned | if (prop.type === 'ObjectProperty' && !prop.shorthand && !prop.computed && |
Branch LogicalExpression | |
✓ Was returned | if (prop.type === 'ObjectProperty' && !prop.shorthand && !prop.computed && |
✗ Was not returned | if (prop.type === 'ObjectProperty' && !prop.shorthand && !prop.computed && |
Function (anonymous_360) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_361) | |
---|---|
✓ Was called | configure: function(identifiers) {··· assert( Array.isArray(identifiers), 'disallowIdentifierNames option requires an array' ); this._identifierIndex = {}; for (var i = 0, l = identifiers.length; i < l; i++) { this._identifierIndex[identifiers[i]] = true; } }, |
Function (anonymous_362) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowIdentifierNames'; }, |
Function (anonymous_363) | |
---|---|
✓ Was called | check: function(file, errors) {··· var disallowedIdentifiers = this._identifierIndex; file.iterateNodesByType('Identifier', function(node) { if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.name)) { errors.add('Illegal Identifier name: ' + node.name, node); } }); file.iterateNodesByType('MemberExpression', function(node) { if (node.property.type === 'StringLiteral') { if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.property.value)) { errors.add('Illegal Identifier name: ' + node.property.value, node.property); } } }); } |
Function (anonymous_364) | |
---|---|
✓ Was called | file.iterateNodesByType('Identifier', function(node) {··· if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.name)) { errors.add('Illegal Identifier name: ' + node.name, node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.name)) {··· errors.add('Illegal Identifier name: ' + node.name, node); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_365) | |
---|---|
✓ Was called | file.iterateNodesByType('MemberExpression', function(node) {··· if (node.property.type === 'StringLiteral') { if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.property.value)) { errors.add('Illegal Identifier name: ' + node.property.value, node.property); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.property.type === 'StringLiteral') {··· if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.property.value)) { errors.add('Illegal Identifier name: ' + node.property.value, node.property); } } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Object.prototype.hasOwnProperty.call(disallowedIdentifiers, node.property.value)) {··· errors.add('Illegal Identifier name: ' + node.property.value, node.property); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_366) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_367) | |
---|---|
✓ Was called | configure: function(types) {··· assert(Array.isArray(types), this.getOptionName() + ' option requires array value'); this._typeIndex = {}; for (var i = 0, l = types.length; i < l; i++) { this._typeIndex[types[i]] = true; } }, |
Function (anonymous_368) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowImplicitTypeConversion'; }, |
Function (anonymous_369) | |
---|---|
✓ Was called | check: function(file, errors) {··· var types = this._typeIndex; if (types.numeric || types.boolean || types.binary) { file.iterateNodesByType('UnaryExpression', function(node) { if (types.numeric && node.operator === '+') { errors.add('Implicit numeric conversion', node); } if (types.binary && node.operator === '~') { errors.add('Implicit binary conversion', node); } if (types.boolean && node.operator === '!' && node.argument.type === 'UnaryExpression' && node.argument.operator === '!' ) { errors.add('Implicit boolean conversion', node); } }); } if (types.string) { file.iterateNodesByType('BinaryExpression', function(node) { if (node.operator !== '+') { return; } // Do not report concatination for same string literals (#1538) if (node.left.type === node.right.type) { return; } if ( (node.left.type === 'StringLiteral' && node.left.value === '') || (node.right.type === 'StringLiteral' && node.right.value === '') ) { errors.add('Implicit string conversion', node); } }); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (types.numeric || types.boolean || types.binary) {··· file.iterateNodesByType('UnaryExpression', function(node) { if (types.numeric && node.operator === '+') { errors.add('Implicit numeric conversion', node); } if (types.binary && node.operator === '~') { errors.add('Implicit binary conversion', node); } if (types.boolean && node.operator === '!' && node.argument.type === 'UnaryExpression' && node.argument.operator === '!' ) { errors.add('Implicit boolean conversion', node); } }); } |
✓ Negative was executed (else) | }··· if (types.string) { |
Branch LogicalExpression | |
✓ Was returned | if (types.numeric || types.boolean || types.binary) { |
✓ Was returned | if (types.numeric || types.boolean || types.binary) { |
Branch LogicalExpression | |
✓ Was returned | if (types.numeric || types.boolean || types.binary) { |
✓ Was returned | if (types.numeric || types.boolean || types.binary) { |
Function (anonymous_370) | |
---|---|
✓ Was called | file.iterateNodesByType('UnaryExpression', function(node) {··· if (types.numeric && node.operator === '+') { errors.add('Implicit numeric conversion', node); } if (types.binary && node.operator === '~') { errors.add('Implicit binary conversion', node); } if (types.boolean && node.operator === '!' && node.argument.type === 'UnaryExpression' && node.argument.operator === '!' ) { errors.add('Implicit boolean conversion', node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (types.numeric && node.operator === '+') {··· errors.add('Implicit numeric conversion', node); } |
✓ Negative was executed (else) | }··· if (types.binary && node.operator === '~') { |
Branch LogicalExpression | |
✓ Was returned | if (types.numeric && node.operator === '+') { |
✓ Was returned | if (types.numeric && node.operator === '+') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (types.binary && node.operator === '~') {··· errors.add('Implicit binary conversion', node); } |
✓ Negative was executed (else) | }··· if (types.boolean && |
Branch LogicalExpression | |
✓ Was returned | if (types.binary && node.operator === '~') { |
✓ Was returned | if (types.binary && node.operator === '~') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add('Implicit boolean conversion', node); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | node.argument.operator === '!' |
✓ Was returned | if (types.boolean &&··· node.operator === '!' && node.argument.type === 'UnaryExpression' && |
Branch LogicalExpression | |
✓ Was returned | node.argument.type === 'UnaryExpression' && |
✓ Was returned | if (types.boolean &&··· node.operator === '!' && |
Branch LogicalExpression | |
✓ Was returned | node.operator === '!' && |
✓ Was returned | if (types.boolean && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (types.string) {··· file.iterateNodesByType('BinaryExpression', function(node) { if (node.operator !== '+') { return; } // Do not report concatination for same string literals (#1538) if (node.left.type === node.right.type) { return; } if ( (node.left.type === 'StringLiteral' && node.left.value === '') || (node.right.type === 'StringLiteral' && node.right.value === '') ) { errors.add('Implicit string conversion', node); } }); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_371) | |
---|---|
✓ Was called | file.iterateNodesByType('BinaryExpression', function(node) {··· if (node.operator !== '+') { return; } // Do not report concatination for same string literals (#1538) if (node.left.type === node.right.type) { return; } if ( (node.left.type === 'StringLiteral' && node.left.value === '') || (node.right.type === 'StringLiteral' && node.right.value === '') ) { errors.add('Implicit string conversion', node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.operator !== '+') {··· return; } |
✓ Negative was executed (else) | }··· // Do not report concatination for same string literals (#1538) |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.left.type === node.right.type) {··· return; } |
✓ Negative was executed (else) | }··· if ( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add('Implicit string conversion', node); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.right.type === 'StringLiteral' && node.right.value === '') |
✓ Was returned | (node.left.type === 'StringLiteral' && node.left.value === '') || |
Branch LogicalExpression | |
✓ Was returned | (node.left.type === 'StringLiteral' && node.left.value === '') || |
✓ Was returned | (node.left.type === 'StringLiteral' && node.left.value === '') || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.right.type === 'StringLiteral' && node.right.value === '') |
✓ Was returned | (node.right.type === 'StringLiteral' && node.right.value === '') |
Function (anonymous_372) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_373) | |
---|---|
✓ Was called | configure: function(keywords) {··· this._message = 'Comments cannot contain the following keywords: '; this._keywords = ['todo', 'fixme']; switch (true) { case Array.isArray(keywords): // use the array of strings provided to build RegExp pattern this._keywords = keywords; /* falls through */ case keywords: // use default keywords this._message += this._keywords.join(', '); this._keywordRegEx = new RegExp('\\b(' + this._keywords.join('|') + ')\\b', 'gi'); break; case typeof keywords === 'string': // use string passed in as the RegExp pattern this._message = 'Comments cannot contain keywords based on the expression you provided'; this._keywordRegEx = new RegExp(keywords, 'gi'); break; default: assert(false, this.getOptionName() + ' option requires a true value, a string or an array'); } }, |
Branch SwitchStatement | |
---|---|
✓ Was evaluated | case Array.isArray(keywords):··· // use the array of strings provided to build RegExp pattern this._keywords = keywords; |
✓ Was evaluated | case keywords:··· // use default keywords this._message += this._keywords.join(', '); this._keywordRegEx = new RegExp('\\b(' + this._keywords.join('|') + ')\\b', 'gi'); break; |
✓ Was evaluated | case typeof keywords === 'string':··· // use string passed in as the RegExp pattern this._message = 'Comments cannot contain keywords based on the expression you provided'; this._keywordRegEx = new RegExp(keywords, 'gi'); break; |
✓ Was evaluated | default:··· assert(false, this.getOptionName() + ' option requires a true value, a string or an array'); |
Function (anonymous_374) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowKeywordsInComments'; }, |
Function (anonymous_375) | |
---|---|
✓ Was called | check: function(file, errors) {··· var keywordRegEx = this._keywordRegEx; file.iterateTokensByType(['CommentLine', 'CommentBlock'], function(comment) { var match; // Both '//' and '/*' comment starters have offset '2' var commentOffset = 2; keywordRegEx.lastIndex = 0; while ((match = keywordRegEx.exec(comment.value)) !== null) { errors.add( this.mesage, comment, match.index + commentOffset ); } }); } |
Function (anonymous_376) | |
---|---|
✓ Was called | file.iterateTokensByType(['CommentLine', 'CommentBlock'], function(comment) {··· var match; // Both '//' and '/*' comment starters have offset '2' var commentOffset = 2; keywordRegEx.lastIndex = 0; while ((match = keywordRegEx.exec(comment.value)) !== null) { errors.add( this.mesage, comment, match.index + commentOffset ); } }); |
Function isPreviousTokenAComment | |
---|---|
✓ Was called | function isPreviousTokenAComment(token) {··· var prevToken = token.getPreviousNonWhitespaceToken(); return (prevToken.type === 'CommentLine' || prevToken.type === 'CommentBlock'); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | return (prevToken.type === 'CommentLine' || prevToken.type === 'CommentBlock'); |
✓ Was returned | return (prevToken.type === 'CommentLine' || prevToken.type === 'CommentBlock'); |
Function (anonymous_378) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_379) | |
---|---|
✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords), this.getOptionName() + ' option requires array value'); this._keywords = keywords; }, |
Function (anonymous_380) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowKeywordsOnNewLine'; }, |
Function (anonymous_381) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var prevToken = token.getPreviousCodeToken(); if (token.value === 'else') { if (prevToken.value !== '}') { // Special case for #905, even though it contradicts rule meaning, // it makes more sense that way. return; } if (isPreviousTokenAComment(token)) { // Special case for #1421, to handle comments before the else return; } } // Special cases for #885, using while as the keyword contradicts rule meaning // but it is more efficient and reduces complexity of the code in this rule if (token.value === 'while') { var parentElement = token.parentElement; // "while" that is part of a do will not return nodes as it is not a start token if (parentElement.type !== 'DoWhileStatement' || prevToken.value !== '}') { // allow "while" that is part of a "do while" with no braces to succeed return; } if (isPreviousTokenAComment(token)) { // Special case for #1421, to handle comments before the else return; } } errors.assert.sameLine({ token: prevToken, nextToken: token }); }); } |
Function (anonymous_382) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var prevToken = token.getPreviousCodeToken(); if (token.value === 'else') { if (prevToken.value !== '}') { // Special case for #905, even though it contradicts rule meaning, // it makes more sense that way. return; } if (isPreviousTokenAComment(token)) { // Special case for #1421, to handle comments before the else return; } } // Special cases for #885, using while as the keyword contradicts rule meaning // but it is more efficient and reduces complexity of the code in this rule if (token.value === 'while') { var parentElement = token.parentElement; // "while" that is part of a do will not return nodes as it is not a start token if (parentElement.type !== 'DoWhileStatement' || prevToken.value !== '}') { // allow "while" that is part of a "do while" with no braces to succeed return; } if (isPreviousTokenAComment(token)) { // Special case for #1421, to handle comments before the else return; } } errors.assert.sameLine({ token: prevToken, nextToken: token }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (token.value === 'else') {··· if (prevToken.value !== '}') { // Special case for #905, even though it contradicts rule meaning, // it makes more sense that way. return; } if (isPreviousTokenAComment(token)) { // Special case for #1421, to handle comments before the else return; } } |
✓ Negative was executed (else) | }··· // Special cases for #885, using while as the keyword contradicts rule meaning |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.value !== '}') {··· // Special case for #905, even though it contradicts rule meaning, // it makes more sense that way. return; } |
✓ Negative was executed (else) | }··· if (isPreviousTokenAComment(token)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isPreviousTokenAComment(token)) {··· // Special case for #1421, to handle comments before the else return; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (token.value === 'while') {··· var parentElement = token.parentElement; // "while" that is part of a do will not return nodes as it is not a start token if (parentElement.type !== 'DoWhileStatement' || prevToken.value !== '}') { // allow "while" that is part of a "do while" with no braces to succeed return; } if (isPreviousTokenAComment(token)) { // Special case for #1421, to handle comments before the else return; } } |
✓ Negative was executed (else) | }··· errors.assert.sameLine({ |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type !== 'DoWhileStatement' || prevToken.value !== '}') {··· // allow "while" that is part of a "do while" with no braces to succeed return; } |
✓ Negative was executed (else) | }··· if (isPreviousTokenAComment(token)) { |
Branch LogicalExpression | |
✓ Was returned | if (parentElement.type !== 'DoWhileStatement' || prevToken.value !== '}') { |
✓ Was returned | if (parentElement.type !== 'DoWhileStatement' || prevToken.value !== '}') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isPreviousTokenAComment(token)) {··· // Special case for #1421, to handle comments before the else return; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_383) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_384) | |
---|---|
✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords), this.getOptionName() + ' option requires array value'); this._keywords = keywords; }, |
Function (anonymous_385) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowKeywords'; }, |
Function (anonymous_386) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { errors.add('Illegal keyword: ' + token.value, token); }); } |
Function (anonymous_387) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· errors.add('Illegal keyword: ' + token.value, token); }); |
Function (anonymous_388) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_389) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || options === 'smart', this.getOptionName() + ' option requires a true value or "smart"' ); this._options = options; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || options === 'smart', |
✓ Was returned | options === true || options === 'smart', |
Function (anonymous_390) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowMixedSpacesAndTabs'; }, |
Function (anonymous_391) | |
---|---|
✓ Was called | check: function(file, errors) {··· var test = this._options === true ? (/ \t|\t [^\*]|\t $/) : (/ \t/); file.iterateTokensByType('Whitespace', function(token) { var match = test.exec(token.value); if (match) { errors.add('Mixed spaces and tabs found', token, token.index); } }); } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | (/ \t|\t [^\*]|\t $/) : |
✓ Negative was returned (: ...) | (/ \t/); |
Function (anonymous_392) | |
---|---|
✓ Was called | file.iterateTokensByType('Whitespace', function(token) {··· var match = test.exec(token.value); if (match) { errors.add('Mixed spaces and tabs found', token, token.index); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (match) {··· errors.add('Mixed spaces and tabs found', token, token.index); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_393) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_394) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_395) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowMultiLineTernary'; }, |
Function (anonymous_396) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ConditionalExpression', function(node) { errors.assert.sameLine({ token: node.test, nextToken: node.consequent, message: 'Illegal new line after test' }); errors.assert.sameLine({ token: node.consequent, nextToken: node.alternate, message: 'Illegal new line after consequent' }); }); } |
Function (anonymous_397) | |
---|---|
✓ Was called | file.iterateNodesByType('ConditionalExpression', function(node) {··· errors.assert.sameLine({ token: node.test, nextToken: node.consequent, message: 'Illegal new line after test' }); errors.assert.sameLine({ token: node.consequent, nextToken: node.alternate, message: 'Illegal new line after consequent' }); }); |
Function (anonymous_398) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_399) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_400) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowMultipleLineBreaks'; }, |
Function (anonymous_401) | |
---|---|
✓ Was called | check: function(file, errors) {··· // Iterate over all tokens (including comments) file.iterateTokensByType('Whitespace', function(whitespaceToken) { if (whitespaceToken.getNewlineCount() === 0) { return; } var token = whitespaceToken.getPreviousNonWhitespaceToken(); if (!token) { return; } var nextToken = token.getNextNonWhitespaceToken(); errors.assert.linesBetween({ token: token, nextToken: nextToken, atMost: 2 }); }); } |
Function (anonymous_402) | |
---|---|
✓ Was called | file.iterateTokensByType('Whitespace', function(whitespaceToken) {··· if (whitespaceToken.getNewlineCount() === 0) { return; } var token = whitespaceToken.getPreviousNonWhitespaceToken(); if (!token) { return; } var nextToken = token.getNextNonWhitespaceToken(); errors.assert.linesBetween({ token: token, nextToken: nextToken, atMost: 2 }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (whitespaceToken.getNewlineCount() === 0) {··· return; } |
✓ Negative was executed (else) | }··· var token = whitespaceToken.getPreviousNonWhitespaceToken(); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!token) {··· return; } |
✓ Negative was executed (else) | }··· var nextToken = token.getNextNonWhitespaceToken(); |
Function (anonymous_403) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_404) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_405) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowMultipleLineStrings'; }, |
Function (anonymous_406) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByType('String', function(token) { if (token.getNewlineCount() !== 0) { errors.add('Multiline strings are disallowed.', token); } }); } |
Function (anonymous_407) | |
---|---|
✓ Was called | file.iterateTokensByType('String', function(token) {··· if (token.getNewlineCount() !== 0) { errors.add('Multiline strings are disallowed.', token); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (token.getNewlineCount() !== 0) {··· errors.add('Multiline strings are disallowed.', token); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_408) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_409) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || typeof options === 'object' && options.allowEOLComments === true, this.getOptionName() + ' option requires true value ' + 'or an object with `allowEOLComments` property' ); this._allowEOLComments = options.allowEOLComments; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof options === 'object' &&··· options.allowEOLComments === true, |
✓ Was returned | options === true || |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.allowEOLComments === true, |
✓ Was returned | typeof options === 'object' && |
Function (anonymous_410) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowMultipleSpaces'; }, |
Function (anonymous_411) | |
---|---|
✓ Was called | check: function(file, errors) {··· var token = file.getProgram().getFirstToken(); var nextToken; while (token) { nextToken = token.getNextNonWhitespaceToken(); if (!nextToken) { break; } if (!this._allowEOLComments || nextToken.type !== 'CommentLine') { errors.assert.spacesBetween({ token: token, nextToken: nextToken, atMost: 1 }); } token = token.getNextNonWhitespaceToken(); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!nextToken) {··· break; } |
✓ Negative was executed (else) | }··· if (!this._allowEOLComments || nextToken.type !== 'CommentLine') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._allowEOLComments || nextToken.type !== 'CommentLine') {··· errors.assert.spacesBetween({ token: token, nextToken: nextToken, atMost: 1 }); } |
✓ Negative was executed (else) | }··· token = token.getNextNonWhitespaceToken(); |
Branch LogicalExpression | |
✓ Was returned | if (!this._allowEOLComments || nextToken.type !== 'CommentLine') { |
✓ Was returned | if (!this._allowEOLComments || nextToken.type !== 'CommentLine') { |
Function (anonymous_412) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_413) | |
---|---|
✓ Was called | configure: function(options) {··· // support for legacy options if (typeof options !== 'object') { assert( options === true || options === 'strict' || options === 'exceptUndefined', this.getOptionName() + ' option requires a true value, "strict", "exceptUndefined", or an object' ); var _options = { strict: options === 'strict', allExcept: [] }; if (options === 'exceptUndefined') { _options.allExcept.push('undefined'); } return this.configure(_options); } if (Array.isArray(options.allExcept)) { this._exceptUndefined = options.allExcept.indexOf('undefined') > -1; this._exceptRequire = options.allExcept.indexOf('require') > -1; } this._strictMode = options.strict === true; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true || options === 'strict' || options === 'exceptUndefined', this.getOptionName() + ' option requires a true value, "strict", "exceptUndefined", or an object' ); var _options = { strict: options === 'strict', allExcept: [] }; if (options === 'exceptUndefined') { _options.allExcept.push('undefined'); } return this.configure(_options); } |
✓ Negative was executed (else) | }··· if (Array.isArray(options.allExcept)) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === 'exceptUndefined', |
✓ Was returned | options === true ||··· options === 'strict' || |
Branch LogicalExpression | |
✓ Was returned | options === 'strict' || |
✓ Was returned | options === true || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options === 'exceptUndefined') {··· _options.allExcept.push('undefined'); } |
✓ Negative was executed (else) | }··· return this.configure(_options); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptUndefined = options.allExcept.indexOf('undefined') > -1; this._exceptRequire = options.allExcept.indexOf('require') > -1; } |
✓ Negative was executed (else) | }··· this._strictMode = options.strict === true; |
Function (anonymous_414) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowMultipleVarDecl'; }, |
Function (anonymous_415) | |
---|---|
✓ Was called | check: function(file, errors) {··· function isSourcedFromRequire(node) { // If this node is a CallExpression it has a callee, // check if this is the `require` function if (node.callee && node.callee.name === 'require') { return true; } // If this CallExpression is not a `require` we keep looking for // the `require` method up in the tree if (node.callee && node.callee.object) { return isSourcedFromRequire(node.callee.object); } // If there is no `callee` this might be a MemberExpression, keep // look for the `require` method up in the tree. if (node.object) { return isSourcedFromRequire(node.object); } return false; } var inStrictMode = this._strictMode; var exceptUndefined = this._exceptUndefined; var exceptRequire = this._exceptRequire; file.iterateNodesByType('VariableDeclaration', function(node) { var definedVariables = node.declarations.filter(function(declaration) { return !!declaration.init; }); var hasDefinedVariables = definedVariables.length > 0; var requireStatements = node.declarations.filter(function(declaration) { var init = declaration.init; return init && isSourcedFromRequire(init); }); var allRequireStatements = requireStatements.length === node.declarations.length; var isForStatement = node.parentElement.type === 'ForStatement'; // allow single var declarations if (node.declarations.length === 1) { return; } // allow multiple var declarations in for statement unless we're in strict mode // for (var i = 0, j = myArray.length; i < j; i++) {} if (!inStrictMode && isForStatement) { return; } // allow multiple var declarations with all undefined variables in exceptUndefined mode // var a, b, c if (exceptUndefined && !hasDefinedVariables) { return; } // allow multiple var declaration with all require // var a = require("a"), b = require("b") if (exceptRequire && allRequireStatements) { return; } // allow multiple var declarations only with require && undefined // var a = require("a"), b = require("b"), x, y if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { return; } errors.add('Multiple var declaration', node); }); } |
Function isSourcedFromRequire | |
---|---|
✓ Was called | function isSourcedFromRequire(node) {··· // If this node is a CallExpression it has a callee, // check if this is the `require` function if (node.callee && node.callee.name === 'require') { return true; } // If this CallExpression is not a `require` we keep looking for // the `require` method up in the tree if (node.callee && node.callee.object) { return isSourcedFromRequire(node.callee.object); } // If there is no `callee` this might be a MemberExpression, keep // look for the `require` method up in the tree. if (node.object) { return isSourcedFromRequire(node.object); } return false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.callee && node.callee.name === 'require') {··· return true; } |
✓ Negative was executed (else) | }··· // If this CallExpression is not a `require` we keep looking for |
Branch LogicalExpression | |
✓ Was returned | if (node.callee && node.callee.name === 'require') { |
✓ Was returned | if (node.callee && node.callee.name === 'require') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.callee && node.callee.object) {··· return isSourcedFromRequire(node.callee.object); } |
✓ Negative was executed (else) | }··· // If there is no `callee` this might be a MemberExpression, keep |
Branch LogicalExpression | |
✓ Was returned | if (node.callee && node.callee.object) { |
✓ Was returned | if (node.callee && node.callee.object) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.object) {··· return isSourcedFromRequire(node.object); } |
✓ Negative was executed (else) | }··· return false; |
Function (anonymous_417) | |
---|---|
✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· var definedVariables = node.declarations.filter(function(declaration) { return !!declaration.init; }); var hasDefinedVariables = definedVariables.length > 0; var requireStatements = node.declarations.filter(function(declaration) { var init = declaration.init; return init && isSourcedFromRequire(init); }); var allRequireStatements = requireStatements.length === node.declarations.length; var isForStatement = node.parentElement.type === 'ForStatement'; // allow single var declarations if (node.declarations.length === 1) { return; } // allow multiple var declarations in for statement unless we're in strict mode // for (var i = 0, j = myArray.length; i < j; i++) {} if (!inStrictMode && isForStatement) { return; } // allow multiple var declarations with all undefined variables in exceptUndefined mode // var a, b, c if (exceptUndefined && !hasDefinedVariables) { return; } // allow multiple var declaration with all require // var a = require("a"), b = require("b") if (exceptRequire && allRequireStatements) { return; } // allow multiple var declarations only with require && undefined // var a = require("a"), b = require("b"), x, y if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { return; } errors.add('Multiple var declaration', node); }); |
Function (anonymous_418) | |
---|---|
✓ Was called | var definedVariables = node.declarations.filter(function(declaration) {··· return !!declaration.init; }); |
Function (anonymous_419) | |
---|---|
✓ Was called | var requireStatements = node.declarations.filter(function(declaration) {··· var init = declaration.init; return init && isSourcedFromRequire(init); }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | return init && isSourcedFromRequire(init); |
✓ Was returned | return init && isSourcedFromRequire(init); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.declarations.length === 1) {··· return; } |
✓ Negative was executed (else) | }··· // allow multiple var declarations in for statement unless we're in strict mode |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!inStrictMode && isForStatement) {··· return; } |
✓ Negative was executed (else) | }··· // allow multiple var declarations with all undefined variables in exceptUndefined mode |
Branch LogicalExpression | |
✓ Was returned | if (!inStrictMode && isForStatement) { |
✓ Was returned | if (!inStrictMode && isForStatement) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptUndefined && !hasDefinedVariables) {··· return; } |
✓ Negative was executed (else) | }··· // allow multiple var declaration with all require |
Branch LogicalExpression | |
✓ Was returned | if (exceptUndefined && !hasDefinedVariables) { |
✓ Was returned | if (exceptUndefined && !hasDefinedVariables) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptRequire && allRequireStatements) {··· return; } |
✓ Negative was executed (else) | }··· // allow multiple var declarations only with require && undefined |
Branch LogicalExpression | |
✓ Was returned | if (exceptRequire && allRequireStatements) { |
✓ Was returned | if (exceptRequire && allRequireStatements) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) {··· return; } |
✓ Negative was executed (else) | }··· errors.add('Multiple var declaration', node); |
Branch LogicalExpression | |
✓ Was returned | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { |
✓ Was returned | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { |
Branch LogicalExpression | |
✓ Was returned | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { |
✓ Was returned | if (exceptUndefined && exceptRequire && definedVariables.length === requireStatements.length) { |
Function (anonymous_420) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_421) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires true value' ); }, |
Function (anonymous_422) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowNamedUnassignedFunctions'; }, |
Function (anonymous_423) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('FunctionExpression', function(node) { // If the function has been named via left hand assignment, skip it // e.g. `var hello = function() {`, `foo.bar = function() {` if (node.parentElement.type.match(/VariableDeclarator|Property|AssignmentExpression/)) { return; } // If the function has not been named, skip it // e.g. `[].forEach(function() {` if (node.id === null) { return; } // Otherwise, complain that it is being named errors.add('Inline functions cannot be named', node); }); } |
Function (anonymous_424) | |
---|---|
✓ Was called | file.iterateNodesByType('FunctionExpression', function(node) {··· // If the function has been named via left hand assignment, skip it // e.g. `var hello = function() {`, `foo.bar = function() {` if (node.parentElement.type.match(/VariableDeclarator|Property|AssignmentExpression/)) { return; } // If the function has not been named, skip it // e.g. `[].forEach(function() {` if (node.id === null) { return; } // Otherwise, complain that it is being named errors.add('Inline functions cannot be named', node); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.parentElement.type.match(/VariableDeclarator|Property|AssignmentExpression/)) {··· return; } |
✓ Negative was executed (else) | }··· // If the function has not been named, skip it |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.id === null) {··· return; } |
✓ Negative was executed (else) | }··· // Otherwise, complain that it is being named |
Function (anonymous_425) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_426) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), this.getOptionName() + ' option requires a true value or an object with "maxLevel" property' ); this._maxLevel = 0; if (options.maxLevel) { this._maxLevel = options.maxLevel; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), |
✓ Was returned | options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), |
Branch LogicalExpression | |
✓ Was returned | options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), |
✗ Was not returned | options === true || (typeof options.maxLevel === 'number' && options.maxLevel > 0), |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.maxLevel) {··· this._maxLevel = options.maxLevel; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_427) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowNestedTernaries'; }, |
Function (anonymous_428) | |
---|---|
✓ Was called | check: function(file, errors) {··· var maxLevel = this._maxLevel; file.iterateNodesByType('ConditionalExpression', function(node) { var level = 0; var getLevel = function(currentNode) { if (currentNode.parentElement && currentNode.parentElement.type === 'ConditionalExpression') { level += 1; if (level > maxLevel) { errors.add('Illegal nested ternary', node); return; } getLevel(currentNode.parentElement); } }; getLevel(node); }); } |
Function (anonymous_429) | |
---|---|
✓ Was called | file.iterateNodesByType('ConditionalExpression', function(node) {··· var level = 0; var getLevel = function(currentNode) { if (currentNode.parentElement && currentNode.parentElement.type === 'ConditionalExpression') { level += 1; if (level > maxLevel) { errors.add('Illegal nested ternary', node); return; } getLevel(currentNode.parentElement); } }; getLevel(node); }); |
Function (anonymous_430) | |
---|---|
✓ Was called | var getLevel = function(currentNode) {··· if (currentNode.parentElement && currentNode.parentElement.type === 'ConditionalExpression') { level += 1; if (level > maxLevel) { errors.add('Illegal nested ternary', node); return; } getLevel(currentNode.parentElement); } }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentNode.parentElement && currentNode.parentElement.type === 'ConditionalExpression') {··· level += 1; if (level > maxLevel) { errors.add('Illegal nested ternary', node); return; } getLevel(currentNode.parentElement); } |
✓ Negative was executed (else) | }··· }; |
Branch LogicalExpression | |
✓ Was returned | if (currentNode.parentElement && currentNode.parentElement.type === 'ConditionalExpression') { |
✗ Was not returned | if (currentNode.parentElement && currentNode.parentElement.type === 'ConditionalExpression') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (level > maxLevel) {··· errors.add('Illegal nested ternary', node); return; } |
✓ Negative was executed (else) | }··· getLevel(currentNode.parentElement); |
Function (anonymous_431) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_432) | |
---|---|
✓ Was called | configure: function(options) {··· var settingValue; this._hasMultiLineEx = false; if (options.constructor === Object) { settingValue = options.value; if (options.allExcept) { assert( Array.isArray(options.allExcept) && options.allExcept.length === 1 && options.allExcept[0] === 'multiLine', 'allExcept option must be an array whose values can be only `multiLine`' ); this._hasMultiLineEx = true; } } else { settingValue = options; } assert( Array.isArray(settingValue) && settingValue.length || settingValue === true, 'disallowNewlineBeforeBlockStatements option requires non-empty array value or true value' ); this._setting = settingValue; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.constructor === Object) {··· settingValue = options.value; if (options.allExcept) { assert( Array.isArray(options.allExcept) && options.allExcept.length === 1 && options.allExcept[0] === 'multiLine', 'allExcept option must be an array whose values can be only `multiLine`' ); this._hasMultiLineEx = true; } } else { |
✓ Negative was executed (else) | } else {··· settingValue = options; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.allExcept) {··· assert( Array.isArray(options.allExcept) && options.allExcept.length === 1 && options.allExcept[0] === 'multiLine', 'allExcept option must be an array whose values can be only `multiLine`' ); this._hasMultiLineEx = true; } |
✗ Negative was not executed (else) | }··· } else { |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.allExcept[0] === 'multiLine', |
✗ Was not returned | Array.isArray(options.allExcept) && options.allExcept.length === 1 && |
Branch LogicalExpression | |
✓ Was returned | Array.isArray(options.allExcept) && options.allExcept.length === 1 && |
✗ Was not returned | Array.isArray(options.allExcept) && options.allExcept.length === 1 && |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
Branch LogicalExpression | |
✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
Function (anonymous_433) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowNewlineBeforeBlockStatements'; }, |
Function (anonymous_434) | |
---|---|
✓ Was called | check: function(file, errors) {··· var setting = this._setting; var hasMultiLineEx = this._hasMultiLineEx; function assertSameLine(token, nextToken) { errors.assert.sameLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is disallowed' }); } function assertDifferentLine(token, nextToken) { errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is required' }); } file.iterateNodesByType(['BlockStatement', 'ClassBody'], function(node) { if (isBareBlock(node)) { return; } if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { var openingBrace = node.getFirstToken(); var prevToken = openingBrace.getPreviousCodeToken(); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } // Check if the 'conditions' span on multiple lines. // The simplest way is to check if the round braces are on different lines. // // For example: // // same line // for (var i = 0; i < length; i++) { // } // // // different lines: // for (var i = 0; // i < length; // i++) // { // } var parentElement = node.parentElement; var parentNextToken = file.getFirstNodeToken(parentElement); var openingRoundBrace = file.findNextToken(parentNextToken, 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); // Not always the conditions are there: to check look for the presence of round braces. // For example: // try { // } ... if (openingRoundBrace && closingRoundBrace && !file.isOnTheSameLine(openingRoundBrace, closingRoundBrace)) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } } }); if (setting === true || setting.indexOf('switch') !== -1) { file.iterateNodesByType(['SwitchStatement'], function(node) { var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } var openingRoundBrace = file.findNextToken(file.getFirstNodeToken(node), 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); if (!file.isOnTheSameLine(openingRoundBrace, closingRoundBrace)) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } }); } } |
Function assertSameLine | |
---|---|
✓ Was called | function assertSameLine(token, nextToken) {··· errors.assert.sameLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is disallowed' }); } |
Function assertDifferentLine | |
---|---|
✓ Was called | function assertDifferentLine(token, nextToken) {··· errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is required' }); } |
Function (anonymous_437) | |
---|---|
✓ Was called | file.iterateNodesByType(['BlockStatement', 'ClassBody'], function(node) {··· if (isBareBlock(node)) { return; } if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { var openingBrace = node.getFirstToken(); var prevToken = openingBrace.getPreviousCodeToken(); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } // Check if the 'conditions' span on multiple lines. // The simplest way is to check if the round braces are on different lines. // // For example: // // same line // for (var i = 0; i < length; i++) { // } // // // different lines: // for (var i = 0; // i < length; // i++) // { // } var parentElement = node.parentElement; var parentNextToken = file.getFirstNodeToken(parentElement); var openingRoundBrace = file.findNextToken(parentNextToken, 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); // Not always the conditions are there: to check look for the presence of round braces. // For example: // try { // } ... if (openingRoundBrace && closingRoundBrace && !file.isOnTheSameLine(openingRoundBrace, closingRoundBrace)) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isBareBlock(node)) {··· return; } |
✓ Negative was executed (else) | }··· if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) {··· var openingBrace = node.getFirstToken(); var prevToken = openingBrace.getPreviousCodeToken(); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } // Check if the 'conditions' span on multiple lines. // The simplest way is to check if the round braces are on different lines. // // For example: // // same line // for (var i = 0; i < length; i++) { // } // // // different lines: // for (var i = 0; // i < length; // i++) // { // } var parentElement = node.parentElement; var parentNextToken = file.getFirstNodeToken(parentElement); var openingRoundBrace = file.findNextToken(parentNextToken, 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); // Not always the conditions are there: to check look for the presence of round braces. // For example: // try { // } ... if (openingRoundBrace && closingRoundBrace && !file.isOnTheSameLine(openingRoundBrace, closingRoundBrace)) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
✓ Was returned | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (hasMultiLineEx !== true) {··· assertSameLine(prevToken, openingBrace); return; } |
✓ Negative was executed (else) | }··· // Check if the 'conditions' span on multiple lines. |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | !file.isOnTheSameLine(openingRoundBrace, closingRoundBrace)) {··· assertDifferentLine(prevToken, openingBrace); } else { |
✓ Negative was executed (else) | } else {··· assertSameLine(prevToken, openingBrace); } |
Branch LogicalExpression | |
✓ Was returned | !file.isOnTheSameLine(openingRoundBrace, closingRoundBrace)) { |
✓ Was returned | if (openingRoundBrace && closingRoundBrace && |
Branch LogicalExpression | |
✓ Was returned | if (openingRoundBrace && closingRoundBrace && |
✗ Was not returned | if (openingRoundBrace && closingRoundBrace && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (setting === true || setting.indexOf('switch') !== -1) {··· file.iterateNodesByType(['SwitchStatement'], function(node) { var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } var openingRoundBrace = file.findNextToken(file.getFirstNodeToken(node), 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); if (!file.isOnTheSameLine(openingRoundBrace, closingRoundBrace)) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } }); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (setting === true || setting.indexOf('switch') !== -1) { |
✓ Was returned | if (setting === true || setting.indexOf('switch') !== -1) { |
Function (anonymous_438) | |
---|---|
✓ Was called | file.iterateNodesByType(['SwitchStatement'], function(node) {··· var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); if (hasMultiLineEx !== true) { assertSameLine(prevToken, openingBrace); return; } var openingRoundBrace = file.findNextToken(file.getFirstNodeToken(node), 'Punctuator', '('); var closingRoundBrace = file.findPrevToken(openingBrace, 'Punctuator', ')'); if (!file.isOnTheSameLine(openingRoundBrace, closingRoundBrace)) { assertDifferentLine(prevToken, openingBrace); } else { assertSameLine(prevToken, openingBrace); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (hasMultiLineEx !== true) {··· assertSameLine(prevToken, openingBrace); return; } |
✓ Negative was executed (else) | }··· var openingRoundBrace = file.findNextToken(file.getFirstNodeToken(node), 'Punctuator', '('); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!file.isOnTheSameLine(openingRoundBrace, closingRoundBrace)) {··· assertDifferentLine(prevToken, openingBrace); } else { |
✓ Negative was executed (else) | } else {··· assertSameLine(prevToken, openingBrace); } |
Function isBareBlock | |
---|---|
✓ Was called | function isBareBlock(node) {··· var parentElement = node.parentElement; return parentElement && parentElement.type === 'BlockStatement' || parentElement.type === 'Program' || parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
✓ Was returned | return parentElement &&··· parentElement.type === 'BlockStatement' || parentElement.type === 'Program' || |
Branch LogicalExpression | |
✓ Was returned | parentElement.type === 'Program' || |
✓ Was returned | return parentElement &&··· parentElement.type === 'BlockStatement' || |
Branch LogicalExpression | |
✓ Was returned | parentElement.type === 'BlockStatement' || |
✗ Was not returned | return parentElement && |
Branch LogicalExpression | |
---|---|
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
Branch LogicalExpression | |
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
Function getBlockType | |
---|---|
✓ Was called | function getBlockType(node) {··· var parentElement = node.parentElement; switch (parentElement.type) { case 'IfStatement': return (parentElement.alternate === node) ? 'else' : 'if'; case 'FunctionDeclaration': case 'FunctionExpression': case 'ArrowFunctionExpression': return 'function'; case 'ForStatement': case 'ForInStatement': case 'ForOfStatement': return 'for'; case 'WhileStatement': return 'while'; case 'DoWhileStatement': return 'do'; case 'TryStatement': return (parentElement.finalizer === node) ? 'finally' : 'try'; case 'CatchClause': return 'catch'; case 'ClassDeclaration': return 'class'; } } |
Branch SwitchStatement | |
---|---|
✓ Was evaluated | case 'IfStatement':··· return (parentElement.alternate === node) ? 'else' : 'if'; |
✓ Was evaluated | case 'FunctionDeclaration': |
✓ Was evaluated | case 'FunctionExpression': |
✓ Was evaluated | case 'ArrowFunctionExpression':··· return 'function'; |
✓ Was evaluated | case 'ForStatement': |
✓ Was evaluated | case 'ForInStatement': |
✓ Was evaluated | case 'ForOfStatement':··· return 'for'; |
✓ Was evaluated | case 'WhileStatement':··· return 'while'; |
✓ Was evaluated | case 'DoWhileStatement':··· return 'do'; |
✓ Was evaluated | case 'TryStatement':··· return (parentElement.finalizer === node) ? 'finally' : 'try'; |
✓ Was evaluated | case 'CatchClause':··· return 'catch'; |
✓ Was evaluated | case 'ClassDeclaration':··· return 'class'; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return (parentElement.alternate === node) ? 'else' : 'if'; |
✓ Negative was returned (: ...) | return (parentElement.alternate === node) ? 'else' : 'if'; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return (parentElement.finalizer === node) ? 'finally' : 'try'; |
✓ Negative was returned (: ...) | return (parentElement.finalizer === node) ? 'finally' : 'try'; |
Function (anonymous_441) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_442) | |
---|---|
✓ Was called | configure: function(nodeTypes) {··· assert( Array.isArray(nodeTypes), 'disallowNodeTypes option requires an array' ); this._nodeTypes = nodeTypes; }, |
Function (anonymous_443) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowNodeTypes'; }, |
Function (anonymous_444) | |
---|---|
✓ Was called | check: function(file, errors) {··· var disallowedNodeTypes = this._nodeTypes; file.iterateNodesByType(disallowedNodeTypes, function(node) { errors.add('Illegal use of disallowed node type: ' + node.type, node); }); } |
Function (anonymous_445) | |
---|---|
✓ Was called | file.iterateNodesByType(disallowedNodeTypes, function(node) {··· errors.add('Illegal use of disallowed node type: ' + node.type, node); }); |
Function (anonymous_446) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_447) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_448) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowNotOperatorsInConditionals'; }, |
Function (anonymous_449) | |
---|---|
✓ Was called | check: function(file, errors) {··· function hasNotOperator(test) { return test.type === 'UnaryExpression' && test.operator === '!'; } function hasNotEqualOperator(test) { return test.type === 'BinaryExpression' && test.operator === '!='; } function hasStrictNotEqualOperator(test) { return test.type === 'BinaryExpression' && test.operator === '!=='; } file.iterateNodesByType(['IfStatement', 'ConditionalExpression'], function(node) { var alternate = node.alternate; // check if the if statement has an else block if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { return; } var test = node.test; if (hasNotOperator(test)) { errors.add('Illegal use of not operator in if statement', test); } if (hasNotEqualOperator(test)) { errors.add('Illegal use of not equal operator in if statement', test); } if (hasStrictNotEqualOperator(test)) { errors.add('Illegal use of strict not equal operator in if statement', test); } }); } |
Function hasNotOperator | |
---|---|
✓ Was called | function hasNotOperator(test) {··· return test.type === 'UnaryExpression' && test.operator === '!'; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | return test.type === 'UnaryExpression' && test.operator === '!'; |
✓ Was returned | return test.type === 'UnaryExpression' && test.operator === '!'; |
Function hasNotEqualOperator | |
---|---|
✓ Was called | function hasNotEqualOperator(test) {··· return test.type === 'BinaryExpression' && test.operator === '!='; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | return test.type === 'BinaryExpression' && test.operator === '!='; |
✓ Was returned | return test.type === 'BinaryExpression' && test.operator === '!='; |
Function hasStrictNotEqualOperator | |
---|---|
✓ Was called | function hasStrictNotEqualOperator(test) {··· return test.type === 'BinaryExpression' && test.operator === '!=='; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | return test.type === 'BinaryExpression' && test.operator === '!=='; |
✓ Was returned | return test.type === 'BinaryExpression' && test.operator === '!=='; |
Function (anonymous_453) | |
---|---|
✓ Was called | file.iterateNodesByType(['IfStatement', 'ConditionalExpression'], function(node) {··· var alternate = node.alternate; // check if the if statement has an else block if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { return; } var test = node.test; if (hasNotOperator(test)) { errors.add('Illegal use of not operator in if statement', test); } if (hasNotEqualOperator(test)) { errors.add('Illegal use of not equal operator in if statement', test); } if (hasStrictNotEqualOperator(test)) { errors.add('Illegal use of strict not equal operator in if statement', test); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) {··· return; } |
✓ Negative was executed (else) | }··· var test = node.test; |
Branch LogicalExpression | |
✓ Was returned | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { |
✓ Was returned | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { |
Branch LogicalExpression | |
✓ Was returned | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { |
✓ Was returned | if (node.type === 'IfStatement' && (!alternate || alternate.type !== 'BlockStatement')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (hasNotOperator(test)) {··· errors.add('Illegal use of not operator in if statement', test); } |
✓ Negative was executed (else) | }··· if (hasNotEqualOperator(test)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (hasNotEqualOperator(test)) {··· errors.add('Illegal use of not equal operator in if statement', test); } |
✓ Negative was executed (else) | }··· if (hasStrictNotEqualOperator(test)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (hasStrictNotEqualOperator(test)) {··· errors.add('Illegal use of strict not equal operator in if statement', test); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_454) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_455) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_456) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowObjectKeysOnNewLine'; }, |
Function (anonymous_457) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { var properties = node.properties; for (var i = 1; i < properties.length; i++) { var propertyNode = properties[i]; errors.assert.sameLine({ token: propertyNode.getPreviousCodeToken(), nextToken: propertyNode.getFirstToken(), message: 'Object keys should be on the same line' }); } }); } |
Function (anonymous_458) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var properties = node.properties; for (var i = 1; i < properties.length; i++) { var propertyNode = properties[i]; errors.assert.sameLine({ token: propertyNode.getPreviousCodeToken(), nextToken: propertyNode.getFirstToken(), message: 'Object keys should be on the same line' }); } }); |
Function (anonymous_459) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_460) | |
---|---|
✓ Was called | configure: function(operators) {··· assert(Array.isArray(operators) || operators === true, this.getOptionName() + ' option requires array or true value'); if (operators === true) { operators = defaultOperators; } this._operators = operators; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | assert(Array.isArray(operators) || operators === true, |
✓ Was returned | assert(Array.isArray(operators) || operators === true, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators === true) {··· operators = defaultOperators; } |
✓ Negative was executed (else) | }··· this._operators = operators; |
Function (anonymous_461) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowOperatorBeforeLineBreak'; }, |
Function (anonymous_462) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Punctuator', this._operators, function(token) { errors.assert.sameLine({ token: token, nextToken: file.getNextToken(token), message: 'Operator needs to either be on the same line or after a line break.' }); }); } |
Function (anonymous_463) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', this._operators, function(token) {··· errors.assert.sameLine({ token: token, nextToken: file.getNextToken(token), message: 'Operator needs to either be on the same line or after a line break.' }); }); |
Function (anonymous_464) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_465) | |
---|---|
✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_466) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesAfterBlocks'; }, |
Function (anonymous_467) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('BlockStatement', function(node) { var endToken = file.getLastNodeToken(node); var nextToken = file.getNextToken(endToken); while (nextToken.type !== 'EOF') { if (file.isOnTheSameLine(endToken, nextToken)) { endToken = nextToken; nextToken = file.getNextToken(nextToken); continue; } errors.assert.linesBetween({ token: endToken, nextToken: nextToken, atMost: 1, message: 'Extra newline after closing curly brace' }); return; } }); } |
Function (anonymous_468) | |
---|---|
✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var endToken = file.getLastNodeToken(node); var nextToken = file.getNextToken(endToken); while (nextToken.type !== 'EOF') { if (file.isOnTheSameLine(endToken, nextToken)) { endToken = nextToken; nextToken = file.getNextToken(nextToken); continue; } errors.assert.linesBetween({ token: endToken, nextToken: nextToken, atMost: 1, message: 'Extra newline after closing curly brace' }); return; } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (file.isOnTheSameLine(endToken, nextToken)) {··· endToken = nextToken; nextToken = file.getNextToken(nextToken); continue; } |
✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
Function (anonymous_469) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_470) | |
---|---|
✓ Was called | configure: function(disallowPaddingNewLinesAfterUseStrict) {··· assert( disallowPaddingNewLinesAfterUseStrict === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_471) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesAfterUseStrict'; }, |
Function (anonymous_472) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('Directive', function(node) { var literal = node.value; if (literal.value !== 'use strict') { return; } var endOfNode = file.getLastNodeToken(node); var nextToken = file.getNextToken(endOfNode, { includeComments: true }); errors.assert.linesBetween({ atMost: 1, token: endOfNode, nextToken: nextToken }); }); } |
Function (anonymous_473) | |
---|---|
✓ Was called | file.iterateNodesByType('Directive', function(node) {··· var literal = node.value; if (literal.value !== 'use strict') { return; } var endOfNode = file.getLastNodeToken(node); var nextToken = file.getNextToken(endOfNode, { includeComments: true }); errors.assert.linesBetween({ atMost: 1, token: endOfNode, nextToken: nextToken }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (literal.value !== 'use strict') {··· return; } |
✓ Negative was executed (else) | }··· var endOfNode = file.getLastNodeToken(node); |
Function (anonymous_474) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_475) | |
---|---|
✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_476) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesBeforeExport'; }, |
Function (anonymous_477) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('AssignmentExpression', function(node) { var left = node.left; if (!( left.object && left.object.name === 'module' && left.property && left.property.name === 'exports')) { return; } var firstToken = node.getFirstToken(); var prevToken = file.getPrevToken(firstToken, {includeComments: true}); errors.assert.linesBetween({ atMost: 1, token: prevToken, nextToken: firstToken, message: 'Unexpected extra newline before export' }); }); } |
Function (anonymous_478) | |
---|---|
✓ Was called | file.iterateNodesByType('AssignmentExpression', function(node) {··· var left = node.left; if (!( left.object && left.object.name === 'module' && left.property && left.property.name === 'exports')) { return; } var firstToken = node.getFirstToken(); var prevToken = file.getPrevToken(firstToken, {includeComments: true}); errors.assert.linesBetween({ atMost: 1, token: prevToken, nextToken: firstToken, message: 'Unexpected extra newline before export' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | left.property.name === 'exports')) {··· return; } |
✓ Negative was executed (else) | }··· var firstToken = node.getFirstToken(); |
Branch LogicalExpression | |
---|---|
✓ Was returned | left.property.name === 'exports')) { |
✓ Was returned | left.object &&··· left.object.name === 'module' && left.property && |
Branch LogicalExpression | |
✓ Was returned | left.property && |
✓ Was returned | left.object &&··· left.object.name === 'module' && |
Branch LogicalExpression | |
✓ Was returned | left.object.name === 'module' && |
✓ Was returned | left.object && |
Function (anonymous_479) | |
---|---|
✓ Was called | module.exports = function() { }; |
Function (anonymous_480) | |
---|---|
✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value'); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | assert(Array.isArray(keywords) || keywords === true, |
✓ Was returned | assert(Array.isArray(keywords) || keywords === true, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
✓ Negative was executed (else) | }··· this._keywords = keywords; |
Function (anonymous_481) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewlinesBeforeKeywords'; }, |
Function (anonymous_482) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { errors.assert.linesBetween({ token: file.getPrevToken(token, { includeComments: true }), nextToken: token, atMost: 1, message: 'Keyword `' + token.value + '` should not have an empty line above it' }); }); } |
Function (anonymous_483) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· errors.assert.linesBetween({ token: file.getPrevToken(token, { includeComments: true }), nextToken: token, atMost: 1, message: 'Keyword `' + token.value + '` should not have an empty line above it' }); }); |
Function (anonymous_484) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_485) | |
---|---|
✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_486) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesBeforeLineComments'; }, |
Function (anonymous_487) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByType('CommentLine', function(comment) { if (comment.getLoc().start.line === 1) { return; } errors.assert.linesBetween({ token: file.getPrevToken(comment, {includeComments: true}), nextToken: comment, atMost: 1, message: 'Line comments must not be preceded with a blank line' }); }); } |
Function (anonymous_488) | |
---|---|
✓ Was called | file.iterateTokensByType('CommentLine', function(comment) {··· if (comment.getLoc().start.line === 1) { return; } errors.assert.linesBetween({ token: file.getPrevToken(comment, {includeComments: true}), nextToken: comment, atMost: 1, message: 'Line comments must not be preceded with a blank line' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (comment.getLoc().start.line === 1) {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
Function (anonymous_489) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_490) | |
---|---|
✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); this._checkOpen = true; this._checkClose = true; if (typeof options === 'object') { assert(options.allExcept || options.open || options.close, optionName + 'option requires either "open", "close", "allExcept"'); if (options.allExcept) { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } if (options.open || options.close) { assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } } else { assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'object') {··· assert(options.allExcept || options.open || options.close, optionName + 'option requires either "open", "close", "allExcept"'); if (options.allExcept) { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } if (options.open || options.close) { assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } } else { |
✓ Negative was executed (else) | } else {··· assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | assert(options.allExcept || options.open || options.close, |
✓ Was returned | assert(options.allExcept || options.open || options.close, |
Branch LogicalExpression | |
✓ Was returned | assert(options.allExcept || options.open || options.close, |
✓ Was returned | assert(options.allExcept || options.open || options.close, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.allExcept) {··· assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } |
✓ Negative was executed (else) | }··· if (options.open || options.close) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.open || options.close) {··· assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } |
✓ Negative was executed (else) | }··· } else { |
Branch LogicalExpression | |
✓ Was returned | if (options.open || options.close) { |
✓ Was returned | if (options.open || options.close) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', |
✗ Was not returned | assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', |
Function (anonymous_491) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewlinesInBlocks'; }, |
Function (anonymous_492) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptConditionals = this._exceptConditionals; var exceptFunctions = this._exceptFunctions; var checkOpen = this._checkOpen; var checkClose = this._checkClose; file.iterateNodesByType('BlockStatement', function(node) { var openingBracket; var closingBracket; if (exceptConditionals && node.parentElement.type === 'IfStatement' || exceptFunctions && (node.parentElement.type === 'FunctionExpression' || node.parentElement.type === 'FunctionDeclaration')) { return; } if (checkOpen === true) { openingBracket = node.getFirstToken(); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atMost: 1, message: 'Expected no padding newline after opening curly brace' }); } if (checkClose === true) { closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atMost: 1, message: 'Expected no padding newline before closing curly brace' }); } }); } |
Function (anonymous_493) | |
---|---|
✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var openingBracket; var closingBracket; if (exceptConditionals && node.parentElement.type === 'IfStatement' || exceptFunctions && (node.parentElement.type === 'FunctionExpression' || node.parentElement.type === 'FunctionDeclaration')) { return; } if (checkOpen === true) { openingBracket = node.getFirstToken(); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atMost: 1, message: 'Expected no padding newline after opening curly brace' }); } if (checkClose === true) { closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atMost: 1, message: 'Expected no padding newline before closing curly brace' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.parentElement.type === 'FunctionDeclaration')) {··· return; } |
✓ Negative was executed (else) | }··· if (checkOpen === true) { |
Branch LogicalExpression | |
✓ Was returned | exceptFunctions && (node.parentElement.type === 'FunctionExpression' ||··· node.parentElement.type === 'FunctionDeclaration')) { |
✓ Was returned | if (exceptConditionals && node.parentElement.type === 'IfStatement' || |
Branch LogicalExpression | |
✓ Was returned | if (exceptConditionals && node.parentElement.type === 'IfStatement' || |
✓ Was returned | if (exceptConditionals && node.parentElement.type === 'IfStatement' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | exceptFunctions && (node.parentElement.type === 'FunctionExpression' ||··· node.parentElement.type === 'FunctionDeclaration')) { |
✓ Was returned | exceptFunctions && (node.parentElement.type === 'FunctionExpression' || |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type === 'FunctionDeclaration')) { |
✓ Was returned | exceptFunctions && (node.parentElement.type === 'FunctionExpression' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (checkOpen === true) {··· openingBracket = node.getFirstToken(); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atMost: 1, message: 'Expected no padding newline after opening curly brace' }); } |
✓ Negative was executed (else) | }··· if (checkClose === true) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (checkClose === true) {··· closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atMost: 1, message: 'Expected no padding newline before closing curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_494) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_495) | |
---|---|
✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_496) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowPaddingNewLinesInObjects'; }, |
Function (anonymous_497) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket); if (nextToken.type === 'Punctuator' && nextToken.value === '}') { return; } errors.assert.sameLine({ token: openingBracket, nextToken: nextToken, message: 'Illegal newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); errors.assert.sameLine({ token: file.getPrevToken(closingBracket), nextToken: closingBracket, message: 'Illegal newline before closing curly brace' }); }); } |
Function (anonymous_498) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket); if (nextToken.type === 'Punctuator' && nextToken.value === '}') { return; } errors.assert.sameLine({ token: openingBracket, nextToken: nextToken, message: 'Illegal newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); errors.assert.sameLine({ token: file.getPrevToken(closingBracket), nextToken: closingBracket, message: 'Illegal newline before closing curly brace' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.type === 'Punctuator' && nextToken.value === '}') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.sameLine({ |
Branch LogicalExpression | |
✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === '}') { |
✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === '}') { |
Function (anonymous_499) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_500) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_501) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowParenthesesAroundArrowParam'; }, |
Function (anonymous_502) | |
---|---|
✓ Was called | check: function(file, errors) {··· function isWrapped(node) { var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } file.iterateNodesByType('ArrowFunctionExpression', function(node) { if (node.params.length !== 1) { return; } var firstParam = node.params[0]; var hasDefaultParameter = firstParam.type === 'AssignmentPattern'; var hasDestructuring = firstParam.type === 'ObjectPattern' || firstParam.type === 'ArrayPattern'; var hasRestElement = firstParam.type === 'RestElement'; if (hasDefaultParameter || hasDestructuring || hasRestElement) { return; } if (isWrapped(firstParam)) { errors.add('Illegal wrap of arrow function expressions in parentheses', firstParam); } }); } |
Function isWrapped | |
---|---|
✓ Was called | function isWrapped(node) {··· var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
✗ Negative was not returned (: ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
Function (anonymous_504) | |
---|---|
✓ Was called | file.iterateNodesByType('ArrowFunctionExpression', function(node) {··· if (node.params.length !== 1) { return; } var firstParam = node.params[0]; var hasDefaultParameter = firstParam.type === 'AssignmentPattern'; var hasDestructuring = firstParam.type === 'ObjectPattern' || firstParam.type === 'ArrayPattern'; var hasRestElement = firstParam.type === 'RestElement'; if (hasDefaultParameter || hasDestructuring || hasRestElement) { return; } if (isWrapped(firstParam)) { errors.add('Illegal wrap of arrow function expressions in parentheses', firstParam); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.params.length !== 1) {··· return; } |
✓ Negative was executed (else) | }··· var firstParam = node.params[0]; |
Branch LogicalExpression | |
---|---|
✓ Was returned | var hasDestructuring = firstParam.type === 'ObjectPattern' || firstParam.type === 'ArrayPattern'; |
✓ Was returned | var hasDestructuring = firstParam.type === 'ObjectPattern' || firstParam.type === 'ArrayPattern'; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | hasRestElement) {··· return; } |
✓ Negative was executed (else) | }··· if (isWrapped(firstParam)) { |
Branch LogicalExpression | |
✓ Was returned | hasRestElement) { |
✓ Was returned | if (hasDefaultParameter ||··· hasDestructuring || |
Branch LogicalExpression | |
✓ Was returned | hasDestructuring || |
✓ Was returned | if (hasDefaultParameter || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isWrapped(firstParam)) {··· errors.add('Illegal wrap of arrow function expressions in parentheses', firstParam); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_505) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_506) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || options === 'allButReserved' || typeof options === 'object', this.getOptionName() + ' option requires a true value or an object' ); this._exceptReserved = options === 'allButReserved'; if (Array.isArray(options.allExcept)) { this._exceptReserved = options.allExcept.indexOf('reserved') !== -1; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || options === 'allButReserved' || typeof options === 'object', |
✓ Was returned | options === true || options === 'allButReserved' || typeof options === 'object', |
Branch LogicalExpression | |
✓ Was returned | options === true || options === 'allButReserved' || typeof options === 'object', |
✓ Was returned | options === true || options === 'allButReserved' || typeof options === 'object', |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptReserved = options.allExcept.indexOf('reserved') !== -1; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_507) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowQuotedKeysInObjects'; }, |
Function (anonymous_508) | |
---|---|
✓ Was called | check: function(file, errors) {··· var KEY_NAME_RE = /^(0|[1-9][0-9]*|[a-zA-Z_$]+[\w$]*)$/; // number or identifier var exceptReserved = this._exceptReserved; file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(prop) { var key = prop.key; // Spread properties if (!key) { return; } if (key.type !== 'StringLiteral') { return; } if (typeof key.value !== 'string') { return; } if (!KEY_NAME_RE.test(key.value)) { return; } if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { return; } errors.cast({ message: 'Extra quotes for key', element: prop }); }); }); }, |
Function (anonymous_509) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(prop) { var key = prop.key; // Spread properties if (!key) { return; } if (key.type !== 'StringLiteral') { return; } if (typeof key.value !== 'string') { return; } if (!KEY_NAME_RE.test(key.value)) { return; } if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { return; } errors.cast({ message: 'Extra quotes for key', element: prop }); }); }); |
Function (anonymous_510) | |
---|---|
✓ Was called | node.properties.forEach(function(prop) {··· var key = prop.key; // Spread properties if (!key) { return; } if (key.type !== 'StringLiteral') { return; } if (typeof key.value !== 'string') { return; } if (!KEY_NAME_RE.test(key.value)) { return; } if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { return; } errors.cast({ message: 'Extra quotes for key', element: prop }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!key) {··· return; } |
✓ Negative was executed (else) | }··· if (key.type !== 'StringLiteral') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (key.type !== 'StringLiteral') {··· return; } |
✓ Negative was executed (else) | }··· if (typeof key.value !== 'string') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (typeof key.value !== 'string') {··· return; } |
✓ Negative was executed (else) | }··· if (!KEY_NAME_RE.test(key.value)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!KEY_NAME_RE.test(key.value)) {··· return; } |
✓ Negative was executed (else) | }··· if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) {··· return; } |
✓ Negative was executed (else) | }··· errors.cast({ |
Branch LogicalExpression | |
✓ Was returned | if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { |
✓ Was returned | if (exceptReserved && reservedWords.check(key.value, file.getDialect(), true)) { |
Function (anonymous_511) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var node = error.element; var key = node.key.childElements[0]; var newKey = new cst.Token(key.type, key.getSourceCode().slice(1, -1)); node.key.replaceChild(newKey, key); } |
Function (anonymous_512) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_513) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_514) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSemicolons'; }, |
Function (anonymous_515) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Punctuator', ';', function(token) { var nextToken = file.getNextToken(token); var node = token.parentElement; // Ignore node exceptions if (node.type in nodeExceptions) { return; } // Ignore next token exceptions if (nextToken.value in tokenExceptions) { return; } if (nextToken.type === 'EOF' || !file.isOnTheSameLine(token, nextToken)) { errors.cast({ message: 'semicolons are disallowed at the end of a line.', element: token }); } }); }, |
Function (anonymous_516) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ';', function(token) {··· var nextToken = file.getNextToken(token); var node = token.parentElement; // Ignore node exceptions if (node.type in nodeExceptions) { return; } // Ignore next token exceptions if (nextToken.value in tokenExceptions) { return; } if (nextToken.type === 'EOF' || !file.isOnTheSameLine(token, nextToken)) { errors.cast({ message: 'semicolons are disallowed at the end of a line.', element: token }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type in nodeExceptions) {··· return; } |
✓ Negative was executed (else) | }··· // Ignore next token exceptions |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.value in tokenExceptions) {··· return; } |
✓ Negative was executed (else) | }··· if (nextToken.type === 'EOF' || !file.isOnTheSameLine(token, nextToken)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.type === 'EOF' || !file.isOnTheSameLine(token, nextToken)) {··· errors.cast({ message: 'semicolons are disallowed at the end of a line.', element: token }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (nextToken.type === 'EOF' || !file.isOnTheSameLine(token, nextToken)) { |
✓ Was returned | if (nextToken.type === 'EOF' || !file.isOnTheSameLine(token, nextToken)) { |
Function (anonymous_517) | |
---|---|
✓ Was called | _fix: function(file, error) {··· error.element.remove(); } |
Function (anonymous_518) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_519) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_520) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowShorthandArrowFunctions'; }, |
Function (anonymous_521) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ArrowFunctionExpression', function(node) { if (node.expression) { errors.add('Use arrow function with explicit block and explicit return', node.body); } }); } |
Function (anonymous_522) | |
---|---|
✓ Was called | file.iterateNodesByType('ArrowFunctionExpression', function(node) {··· if (node.expression) { errors.add('Use arrow function with explicit block and explicit return', node.body); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.expression) {··· errors.add('Use arrow function with explicit block and explicit return', node.body); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_523) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_524) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = allOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = allOperators; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_525) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterBinaryOperators'; }, |
Function (anonymous_526) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; // Comma if (operators[',']) { file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (file.getNextToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should stick to following expression' }); }); } // For everything else file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'VariableDeclarator', 'LogicalExpression'], function(node) { var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var nextToken = file.getNextToken(operatorToken); if (operators[operator]) { errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should stick to following expression' }); } } ); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[',']) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (file.getNextToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should stick to following expression' }); }); } |
✓ Negative was executed (else) | }··· // For everything else |
Function (anonymous_527) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· if (file.getNextToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should stick to following expression' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (file.getNextToken(token).value === ',') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Function (anonymous_528) | |
---|---|
✓ Was called | function(node) {··· var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var nextToken = file.getNextToken(operatorToken); if (operators[operator]) { errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should stick to following expression' }); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'VariableDeclarator') {··· expression = node.init; operator = '='; } else { |
✓ Negative was executed (else) | } else {··· operator = node.operator; expression = node.right; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (expression === null) {··· return; } |
✓ Negative was executed (else) | }··· var operatorToken = file.findPrevOperatorToken( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[operator]) {··· errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should stick to following expression' }); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_529) | |
---|---|
✓ Was called | module.exports = function() {··· }; |
Function (anonymous_530) | |
---|---|
✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } assert( Array.isArray(options.allExcept), ' property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); this._exceptSparseArrays = options.allExcept.indexOf('sparseArrays') >= 0; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
✓ Negative was executed (else) | }··· assert( |
Function (anonymous_531) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterComma'; }, |
Function (anonymous_532) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptSparseArrays = this._exceptSparseArrays; file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var nextToken = file.getNextToken(token); if (exceptSparseArrays && nextToken.value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after comma' }); }); } |
Function (anonymous_533) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var nextToken = file.getNextToken(token); if (exceptSparseArrays && nextToken.value === ',') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after comma' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptSparseArrays && nextToken.value === ',') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Branch LogicalExpression | |
✓ Was returned | if (exceptSparseArrays && nextToken.value === ',') { |
✓ Was returned | if (exceptSparseArrays && nextToken.value === ',') { |
Function (anonymous_534) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_535) | |
---|---|
✓ Was called | configure: function(keywords) {··· assert( Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value' ); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(keywords) || keywords === true, |
✓ Was returned | Array.isArray(keywords) || keywords === true, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
✓ Negative was executed (else) | }··· this._keywords = keywords; |
Function (anonymous_536) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterKeywords'; }, |
Function (anonymous_537) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var nextToken = file.getNextToken(token); // Make an exception if the next token is not a Punctuator such as a Keyword or Identifier if (nextToken.type !== 'Punctuator') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken }); }); } |
Function (anonymous_538) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var nextToken = file.getNextToken(token); // Make an exception if the next token is not a Punctuator such as a Keyword or Identifier if (nextToken.type !== 'Punctuator') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.type !== 'Punctuator') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Function (anonymous_539) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_540) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_541) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterLineComment'; }, |
Function (anonymous_542) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByType('CommentLine', function(comment) { var value = comment.value; if (value.length > 0 && value[0] === ' ') { errors.add('Illegal space after line comment', comment); } }); } |
Function (anonymous_543) | |
---|---|
✓ Was called | file.iterateTokensByType('CommentLine', function(comment) {··· var value = comment.value; if (value.length > 0 && value[0] === ' ') { errors.add('Illegal space after line comment', comment); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value.length > 0 && value[0] === ' ') {··· errors.add('Illegal space after line comment', comment); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (value.length > 0 && value[0] === ' ') { |
✓ Was returned | if (value.length > 0 && value[0] === ' ') { |
Function (anonymous_544) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_545) | |
---|---|
✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true || options === 'ignoreSingleLine' || options === 'ignoreMultiLine', this.getOptionName() + ' option requires a true value, "ignoreSingleLine", "ignoreMultiLine", or an object' ); var _options = { allExcept: [] }; if (options === 'ignoreSingleLine') { _options.allExcept.push('singleline'); } if (options === 'ignoreMultiLine') { _options.allExcept.push('multiline'); } return this.configure(_options); } else { assert( Array.isArray(options.allExcept), this.getOptionName() + ' option object requires allExcept array property' ); } this._exceptSingleline = options.allExcept.indexOf('singleline') > -1; this._exceptMultiline = options.allExcept.indexOf('multiline') > -1; this._exceptAligned = options.allExcept.indexOf('aligned') > -1; this._exceptMethod = options.allExcept.indexOf('method') > -1; assert( !this._exceptMultiline || !this._exceptAligned, this.getOptionName() + ' option allExcept property cannot contain `aligned` and `multiline` at the same time' ); assert( !this._exceptMultiline || !this._exceptSingleline, this.getOptionName() + ' option allExcept property cannot contain `singleline` and `multiline` at the same time' ); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true || options === 'ignoreSingleLine' || options === 'ignoreMultiLine', this.getOptionName() + ' option requires a true value, "ignoreSingleLine", "ignoreMultiLine", or an object' ); var _options = { allExcept: [] }; if (options === 'ignoreSingleLine') { _options.allExcept.push('singleline'); } if (options === 'ignoreMultiLine') { _options.allExcept.push('multiline'); } return this.configure(_options); } else { |
✓ Negative was executed (else) | } else {··· assert( Array.isArray(options.allExcept), this.getOptionName() + ' option object requires allExcept array property' ); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === 'ignoreMultiLine', |
✓ Was returned | options === true ||··· options === 'ignoreSingleLine' || |
Branch LogicalExpression | |
✓ Was returned | options === 'ignoreSingleLine' || |
✓ Was returned | options === true || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options === 'ignoreSingleLine') {··· _options.allExcept.push('singleline'); } |
✓ Negative was executed (else) | }··· if (options === 'ignoreMultiLine') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options === 'ignoreMultiLine') {··· _options.allExcept.push('multiline'); } |
✓ Negative was executed (else) | }··· return this.configure(_options); |
Branch LogicalExpression | |
---|---|
✓ Was returned | !this._exceptMultiline || !this._exceptAligned, |
✓ Was returned | !this._exceptMultiline || !this._exceptAligned, |
Branch LogicalExpression | |
---|---|
✓ Was returned | !this._exceptMultiline || !this._exceptSingleline, |
✓ Was returned | !this._exceptMultiline || !this._exceptSingleline, |
Function (anonymous_546) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterObjectKeys'; }, |
Function (anonymous_547) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptSingleline = this._exceptSingleline; var exceptMultiline = this._exceptMultiline; var exceptAligned = this._exceptAligned; var exceptMethod = this._exceptMethod; file.iterateNodesByType('ObjectExpression', function(node) { var multiline = node.getNewlineCount() > 0; if (exceptSingleline && !multiline) { return; } if (exceptMultiline && multiline) { return; } var maxKeyEndPos = 0; var tokens = []; node.properties.forEach(function(property) { if (property.shorthand || (exceptMethod && property.method) || property.type === 'SpreadProperty') { return; } var keyToken = file.getLastNodeToken(property.key); if (property.computed === true) { keyToken = file.getNextToken(keyToken); } if (exceptAligned) { maxKeyEndPos = Math.max(maxKeyEndPos, keyToken.getLoc().end.column); } tokens.push(keyToken); }); var noSpace = true; if (exceptAligned) { var withoutSpace = 0; var alignedOnColon = 0; tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = file.getDistanceBetween(key, colon); if (spaces === 0) { withoutSpace++; } else if (spaces === maxKeyEndPos - key.getLoc().end.column) { alignedOnColon++; } }); noSpace = withoutSpace > alignedOnColon; } tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.getLoc().end.column : 0; errors.assert.spacesBetween({ token: key, nextToken: colon, exactly: spaces, message: 'Illegal space after key', disallowNewLine: true }); }); }); } |
Function (anonymous_548) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var multiline = node.getNewlineCount() > 0; if (exceptSingleline && !multiline) { return; } if (exceptMultiline && multiline) { return; } var maxKeyEndPos = 0; var tokens = []; node.properties.forEach(function(property) { if (property.shorthand || (exceptMethod && property.method) || property.type === 'SpreadProperty') { return; } var keyToken = file.getLastNodeToken(property.key); if (property.computed === true) { keyToken = file.getNextToken(keyToken); } if (exceptAligned) { maxKeyEndPos = Math.max(maxKeyEndPos, keyToken.getLoc().end.column); } tokens.push(keyToken); }); var noSpace = true; if (exceptAligned) { var withoutSpace = 0; var alignedOnColon = 0; tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = file.getDistanceBetween(key, colon); if (spaces === 0) { withoutSpace++; } else if (spaces === maxKeyEndPos - key.getLoc().end.column) { alignedOnColon++; } }); noSpace = withoutSpace > alignedOnColon; } tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.getLoc().end.column : 0; errors.assert.spacesBetween({ token: key, nextToken: colon, exactly: spaces, message: 'Illegal space after key', disallowNewLine: true }); }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptSingleline && !multiline) {··· return; } |
✓ Negative was executed (else) | }··· if (exceptMultiline && multiline) { |
Branch LogicalExpression | |
✓ Was returned | if (exceptSingleline && !multiline) { |
✓ Was returned | if (exceptSingleline && !multiline) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptMultiline && multiline) {··· return; } |
✓ Negative was executed (else) | }··· var maxKeyEndPos = 0; |
Branch LogicalExpression | |
✓ Was returned | if (exceptMultiline && multiline) { |
✓ Was returned | if (exceptMultiline && multiline) { |
Function (anonymous_549) | |
---|---|
✓ Was called | node.properties.forEach(function(property) {··· if (property.shorthand || (exceptMethod && property.method) || property.type === 'SpreadProperty') { return; } var keyToken = file.getLastNodeToken(property.key); if (property.computed === true) { keyToken = file.getNextToken(keyToken); } if (exceptAligned) { maxKeyEndPos = Math.max(maxKeyEndPos, keyToken.getLoc().end.column); } tokens.push(keyToken); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | property.type === 'SpreadProperty') {··· return; } |
✓ Negative was executed (else) | }··· var keyToken = file.getLastNodeToken(property.key); |
Branch LogicalExpression | |
✓ Was returned | property.type === 'SpreadProperty') { |
✓ Was returned | if (property.shorthand ||··· (exceptMethod && property.method) || |
Branch LogicalExpression | |
✓ Was returned | (exceptMethod && property.method) || |
✓ Was returned | if (property.shorthand || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (exceptMethod && property.method) || |
✓ Was returned | (exceptMethod && property.method) || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (property.computed === true) {··· keyToken = file.getNextToken(keyToken); } |
✓ Negative was executed (else) | }··· if (exceptAligned) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptAligned) {··· maxKeyEndPos = Math.max(maxKeyEndPos, keyToken.getLoc().end.column); } |
✓ Negative was executed (else) | }··· tokens.push(keyToken); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptAligned) {··· var withoutSpace = 0; var alignedOnColon = 0; tokens.forEach(function(key) { var colon = file.getNextToken(key); var spaces = file.getDistanceBetween(key, colon); if (spaces === 0) { withoutSpace++; } else if (spaces === maxKeyEndPos - key.getLoc().end.column) { alignedOnColon++; } }); noSpace = withoutSpace > alignedOnColon; } |
✓ Negative was executed (else) | }··· tokens.forEach(function(key) { |
Function (anonymous_550) | |
---|---|
✓ Was called | tokens.forEach(function(key) {··· var colon = file.getNextToken(key); var spaces = file.getDistanceBetween(key, colon); if (spaces === 0) { withoutSpace++; } else if (spaces === maxKeyEndPos - key.getLoc().end.column) { alignedOnColon++; } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (spaces === 0) {··· withoutSpace++; } else if (spaces === maxKeyEndPos - key.getLoc().end.column) { |
✓ Negative was executed (else) | } else if (spaces === maxKeyEndPos - key.getLoc().end.column) {··· alignedOnColon++; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (spaces === maxKeyEndPos - key.getLoc().end.column) {··· alignedOnColon++; } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_551) | |
---|---|
✓ Was called | tokens.forEach(function(key) {··· var colon = file.getNextToken(key); var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.getLoc().end.column : 0; errors.assert.spacesBetween({ token: key, nextToken: colon, exactly: spaces, message: 'Illegal space after key', disallowNewLine: true }); }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.getLoc().end.column : 0; |
✓ Negative was returned (: ...) | var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.getLoc().end.column : 0; |
Branch LogicalExpression | |
✓ Was returned | var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.getLoc().end.column : 0; |
✓ Was returned | var spaces = (exceptAligned && !noSpace) ? maxKeyEndPos - key.getLoc().end.column : 0; |
Function (anonymous_552) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_553) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_554) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceAfterPrefixUnaryOperators'; }, |
Function (anonymous_555) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operatorIndex = this._operatorIndex; file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) { // Check "node.prefix" for prefix type of (inc|dec)rement if (node.prefix && operatorIndex[node.operator]) { var operatorToken = node.getFirstToken(); errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: file.getNextToken(operatorToken), message: 'Operator ' + node.operator + ' should stick to operand' }); } }); } |
Function (anonymous_556) | |
---|---|
✓ Was called | file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) {··· // Check "node.prefix" for prefix type of (inc|dec)rement if (node.prefix && operatorIndex[node.operator]) { var operatorToken = node.getFirstToken(); errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: file.getNextToken(operatorToken), message: 'Operator ' + node.operator + ' should stick to operand' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.prefix && operatorIndex[node.operator]) {··· var operatorToken = node.getFirstToken(); errors.assert.noWhitespaceBetween({ token: operatorToken, nextToken: file.getNextToken(operatorToken), message: 'Operator ' + node.operator + ' should stick to operand' }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (node.prefix && operatorIndex[node.operator]) { |
✓ Was returned | if (node.prefix && operatorIndex[node.operator]) { |
Function (anonymous_557) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_558) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = allOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = allOperators; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_559) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeBinaryOperators'; }, |
Function (anonymous_560) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; // Comma if (operators[',']) { file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (file.getPrevToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token, {includeComments: true}), nextToken: token, message: 'Operator , should stick to previous expression' }); }); } // For everything else file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'VariableDeclarator', 'LogicalExpression'], function(node) { var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var prevToken = file.getPrevToken(operatorToken, {includeComments: true}); if (operators[operator]) { errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to previous expression' }); } } ); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[',']) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (file.getPrevToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token, {includeComments: true}), nextToken: token, message: 'Operator , should stick to previous expression' }); }); } |
✓ Negative was executed (else) | }··· // For everything else |
Function (anonymous_561) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· if (file.getPrevToken(token).value === ',') { return; } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(token, {includeComments: true}), nextToken: token, message: 'Operator , should stick to previous expression' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (file.getPrevToken(token).value === ',') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Function (anonymous_562) | |
---|---|
✓ Was called | function(node) {··· var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var prevToken = file.getPrevToken(operatorToken, {includeComments: true}); if (operators[operator]) { errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to previous expression' }); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'VariableDeclarator') {··· expression = node.init; operator = '='; } else { |
✓ Negative was executed (else) | } else {··· operator = node.operator; expression = node.right; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (expression === null) {··· return; } |
✓ Negative was executed (else) | }··· var operatorToken = file.findPrevOperatorToken( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[operator]) {··· errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to previous expression' }); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_563) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_564) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_565) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeBlockStatements'; }, |
Function (anonymous_566) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('BlockStatement', function(node) { if (isBareBlock(node)) { return; } var first = node.getFirstToken(); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(first), nextToken: first, disallowNewLine: true, message: 'Extra space before opening curly brace for block expressions' }); }); } |
Function (anonymous_567) | |
---|---|
✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· if (isBareBlock(node)) { return; } var first = node.getFirstToken(); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(first), nextToken: first, disallowNewLine: true, message: 'Extra space before opening curly brace for block expressions' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isBareBlock(node)) {··· return; } |
✓ Negative was executed (else) | }··· var first = node.getFirstToken(); |
Function isBareBlock | |
---|---|
✓ Was called | function isBareBlock(node) {··· var parentElement = node.parentElement; return parentElement && parentElement.type === 'BlockStatement' || parentElement.type === 'Program' || parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
✓ Was returned | return parentElement &&··· parentElement.type === 'BlockStatement' || parentElement.type === 'Program' || |
Branch LogicalExpression | |
✓ Was returned | parentElement.type === 'Program' || |
✓ Was returned | return parentElement &&··· parentElement.type === 'BlockStatement' || |
Branch LogicalExpression | |
✓ Was returned | parentElement.type === 'BlockStatement' || |
✗ Was not returned | return parentElement && |
Branch LogicalExpression | |
---|---|
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
Branch LogicalExpression | |
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
✓ Was returned | parentElement.body && parentElement.body.type === 'BlockStatement' && Array.isArray(parentElement.body); |
Function (anonymous_569) | |
---|---|
✓ Was called | module.exports = function() {··· }; |
Function (anonymous_570) | |
---|---|
✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } assert( Array.isArray(options.allExcept), ' property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); this._exceptSparseArrays = options.allExcept.indexOf('sparseArrays') >= 0; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
✓ Negative was executed (else) | }··· assert( |
Function (anonymous_571) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeComma'; }, |
Function (anonymous_572) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptSparseArrays = this._exceptSparseArrays; file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var prevToken = token.getPreviousCodeToken(); if (exceptSparseArrays && prevToken.value === ',') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before comma' }); }); } |
Function (anonymous_573) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var prevToken = token.getPreviousCodeToken(); if (exceptSparseArrays && prevToken.value === ',') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before comma' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptSparseArrays && prevToken.value === ',') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Branch LogicalExpression | |
✓ Was returned | if (exceptSparseArrays && prevToken.value === ',') { |
✓ Was returned | if (exceptSparseArrays && prevToken.value === ',') { |
Function (anonymous_574) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_575) | |
---|---|
✓ Was called | configure: function(keywords) {··· assert( Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value'); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(keywords) || keywords === true, |
✓ Was returned | Array.isArray(keywords) || keywords === true, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
✓ Negative was executed (else) | }··· this._keywords = keywords; |
Function (anonymous_576) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeKeywords'; }, |
Function (anonymous_577) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); if (!prevToken || prevToken.isComment) { return; } if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before "' + token.value + '" keyword' }); } }); } |
Function (anonymous_578) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); if (!prevToken || prevToken.isComment) { return; } if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before "' + token.value + '" keyword' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!prevToken || prevToken.isComment) {··· return; } |
✓ Negative was executed (else) | }··· if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { |
Branch LogicalExpression | |
✓ Was returned | if (!prevToken || prevToken.isComment) { |
✓ Was returned | if (!prevToken || prevToken.isComment) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.type !== 'Keyword' && prevToken.value !== ';') {··· errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before "' + token.value + '" keyword' }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { |
✓ Was returned | if (prevToken.type !== 'Keyword' && prevToken.value !== ';') { |
Function (anonymous_579) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_580) | |
---|---|
✓ Was called | configure: function(disallow) {··· assert( disallow === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_581) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeObjectValues'; }, |
Function (anonymous_582) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(property) { if (property.shorthand || property.type === 'ObjectMethod' || property.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.noWhitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Illegal space after key colon' }); }); }); } |
Function (anonymous_583) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(property) { if (property.shorthand || property.type === 'ObjectMethod' || property.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.noWhitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Illegal space after key colon' }); }); }); |
Function (anonymous_584) | |
---|---|
✓ Was called | node.properties.forEach(function(property) {··· if (property.shorthand || property.type === 'ObjectMethod' || property.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.noWhitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Illegal space after key colon' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | property.type === 'SpreadProperty') {··· return; } |
✓ Negative was executed (else) | }··· var keyToken = file.getFirstNodeToken(property.key); |
Branch LogicalExpression | |
✓ Was returned | property.type === 'SpreadProperty') { |
✓ Was returned | if (property.shorthand ||··· property.type === 'ObjectMethod' || |
Branch LogicalExpression | |
✓ Was returned | property.type === 'ObjectMethod' || |
✓ Was returned | if (property.shorthand || |
Function (anonymous_585) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_586) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_587) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforePostfixUnaryOperators'; }, |
Function (anonymous_588) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operatorIndex = this._operatorIndex; // 'UpdateExpression' involve only ++ and -- operators file.iterateNodesByType('UpdateExpression', function(node) { // "!node.prefix" means postfix type of (inc|dec)rement if (!node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getLastNodeToken(node); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to operand' }); } }); } |
Function (anonymous_589) | |
---|---|
✓ Was called | file.iterateNodesByType('UpdateExpression', function(node) {··· // "!node.prefix" means postfix type of (inc|dec)rement if (!node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getLastNodeToken(node); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to operand' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!node.prefix && operatorIndex[node.operator]) {··· var operatorToken = file.getLastNodeToken(node); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should stick to operand' }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (!node.prefix && operatorIndex[node.operator]) { |
✓ Was returned | if (!node.prefix && operatorIndex[node.operator]) { |
Function (anonymous_590) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_591) | |
---|---|
✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_592) | |
---|---|
✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
Function (anonymous_593) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceBeforeSemicolon'; }, |
Function (anonymous_594) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokensByTypeAndValue('Punctuator', ';', function(token) { var prevToken = token.getPreviousCodeToken(); if (!prevToken || prevToken.value in exceptions) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before semicolon' }); }); } |
Function (anonymous_595) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ';', function(token) {··· var prevToken = token.getPreviousCodeToken(); if (!prevToken || prevToken.value in exceptions) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before semicolon' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!prevToken || prevToken.value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Branch LogicalExpression | |
✓ Was returned | if (!prevToken || prevToken.value in exceptions) { |
✓ Was returned | if (!prevToken || prevToken.value in exceptions) { |
Function (anonymous_596) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_597) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_598) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpaceBetweenArguments'; }, |
Function (anonymous_599) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['CallExpression'], function(node) { node.arguments.forEach(function(param) { var token = file.getFirstNodeToken(param); var punctuatorToken = file.getPrevToken(token); if (punctuatorToken.value === ',') { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken), message: 'Illegal space between arguments' }); } }); }); } |
Function (anonymous_600) | |
---|---|
✓ Was called | file.iterateNodesByType(['CallExpression'], function(node) {··· node.arguments.forEach(function(param) { var token = file.getFirstNodeToken(param); var punctuatorToken = file.getPrevToken(token); if (punctuatorToken.value === ',') { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken), message: 'Illegal space between arguments' }); } }); }); |
Function (anonymous_601) | |
---|---|
✓ Was called | node.arguments.forEach(function(param) {··· var token = file.getFirstNodeToken(param); var punctuatorToken = file.getPrevToken(token); if (punctuatorToken.value === ',') { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken), message: 'Illegal space between arguments' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (punctuatorToken.value === ',') {··· errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken), message: 'Illegal space between arguments' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_602) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_603) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace ' + ' or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_604) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInAnonymousFunctionExpression'; }, |
Function (anonymous_605) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionExpression'], function(node) { var functionNode = node; // anonymous function expressions only if (node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); } |
Function (anonymous_606) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· var functionNode = node; // anonymous function expressions only if (node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.id) {··· return; } |
✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
Branch LogicalExpression | |
✗ Was not returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Branch LogicalExpression | |
✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
✓ Was returned | if (node.generator && functionToken.value === 'function') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_607) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_608) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_609) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInCallExpression'; }, |
Function (anonymous_610) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['CallExpression', 'NewExpression'], function(node) { var lastCalleeToken = file.getLastNodeToken(node.callee); var roundBraceToken = file.findNextToken(lastCalleeToken, 'Punctuator', '('); // CallExpressions can't have missing parens, otherwise they're identifiers if (node.type === 'NewExpression') { if (roundBraceToken === null || roundBraceToken.parentElement !== node) { return; } } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(roundBraceToken), nextToken: roundBraceToken, message: 'Illegal space before opening round brace' }); }); } |
Function (anonymous_611) | |
---|---|
✓ Was called | file.iterateNodesByType(['CallExpression', 'NewExpression'], function(node) {··· var lastCalleeToken = file.getLastNodeToken(node.callee); var roundBraceToken = file.findNextToken(lastCalleeToken, 'Punctuator', '('); // CallExpressions can't have missing parens, otherwise they're identifiers if (node.type === 'NewExpression') { if (roundBraceToken === null || roundBraceToken.parentElement !== node) { return; } } errors.assert.noWhitespaceBetween({ token: file.getPrevToken(roundBraceToken), nextToken: roundBraceToken, message: 'Illegal space before opening round brace' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'NewExpression') {··· if (roundBraceToken === null || roundBraceToken.parentElement !== node) { return; } } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (roundBraceToken === null || roundBraceToken.parentElement !== node) {··· return; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (roundBraceToken === null || roundBraceToken.parentElement !== node) { |
✓ Was returned | if (roundBraceToken === null || roundBraceToken.parentElement !== node) { |
Function (anonymous_612) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_613) | |
---|---|
✓ Was called | configure: function(options) {··· var validProperties = [ 'afterTest', 'beforeConsequent', 'afterConsequent', 'beforeAlternate' ]; var optionName = this.getOptionName(); if (options === true) { options = { 'afterTest': true, 'beforeConsequent': true, 'afterConsequent': true, 'beforeAlternate': true }; } assert( typeof options === 'object', optionName + ' option requires a true value or an object' ); var isProperlyConfigured = validProperties.some(function(key) { var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } return isPresent; }); assert( isProperlyConfigured, optionName + ' must have at least 1 of the following properties: ' + validProperties.join(', ') ); validProperties.forEach(function(property) { this['_' + property] = Boolean(options[property]); }.bind(this)); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options === true) {··· options = { 'afterTest': true, 'beforeConsequent': true, 'afterConsequent': true, 'beforeAlternate': true }; } |
✓ Negative was executed (else) | }··· assert( |
Function (anonymous_614) | |
---|---|
✓ Was called | var isProperlyConfigured = validProperties.some(function(key) {··· var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } return isPresent; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isPresent) {··· assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· return isPresent; |
Function (anonymous_615) | |
---|---|
✓ Was called | validProperties.forEach(function(property) {··· this['_' + property] = Boolean(options[property]); }.bind(this)); |
Function (anonymous_616) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInConditionalExpression'; }, |
Function (anonymous_617) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ConditionalExpression'], function(node) { var test = node.test; var consequent = node.consequent; var consequentToken = file.getFirstNodeToken(consequent); var alternate = node.alternate; var alternateToken = file.getFirstNodeToken(alternate); var questionMarkToken = file.findPrevOperatorToken(consequentToken, '?'); var colonToken = file.findPrevOperatorToken(alternateToken, ':'); var token; if (this._afterTest && file.isOnTheSameLine(test, questionMarkToken)) { token = file.getPrevToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Illegal space after test' }); } if (this._beforeConsequent && file.isOnTheSameLine(questionMarkToken, consequent)) { token = file.getNextToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Illegal space before consequent' }); } if (this._afterConsequent && file.isOnTheSameLine(consequent, colonToken)) { token = file.getPrevToken(colonToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: colonToken, message: 'Illegal space after consequent' }); } if (this._beforeAlternate && file.isOnTheSameLine(colonToken, alternate)) { token = file.getNextToken(colonToken); errors.assert.noWhitespaceBetween({ token: colonToken, nextToken: token, message: 'Illegal space before alternate' }); } }.bind(this)); } |
Function (anonymous_618) | |
---|---|
✓ Was called | file.iterateNodesByType(['ConditionalExpression'], function(node) {··· var test = node.test; var consequent = node.consequent; var consequentToken = file.getFirstNodeToken(consequent); var alternate = node.alternate; var alternateToken = file.getFirstNodeToken(alternate); var questionMarkToken = file.findPrevOperatorToken(consequentToken, '?'); var colonToken = file.findPrevOperatorToken(alternateToken, ':'); var token; if (this._afterTest && file.isOnTheSameLine(test, questionMarkToken)) { token = file.getPrevToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Illegal space after test' }); } if (this._beforeConsequent && file.isOnTheSameLine(questionMarkToken, consequent)) { token = file.getNextToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Illegal space before consequent' }); } if (this._afterConsequent && file.isOnTheSameLine(consequent, colonToken)) { token = file.getPrevToken(colonToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: colonToken, message: 'Illegal space after consequent' }); } if (this._beforeAlternate && file.isOnTheSameLine(colonToken, alternate)) { token = file.getNextToken(colonToken); errors.assert.noWhitespaceBetween({ token: colonToken, nextToken: token, message: 'Illegal space before alternate' }); } }.bind(this)); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._afterTest && file.isOnTheSameLine(test, questionMarkToken)) {··· token = file.getPrevToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Illegal space after test' }); } |
✓ Negative was executed (else) | }··· if (this._beforeConsequent && file.isOnTheSameLine(questionMarkToken, consequent)) { |
Branch LogicalExpression | |
✓ Was returned | if (this._afterTest && file.isOnTheSameLine(test, questionMarkToken)) { |
✓ Was returned | if (this._afterTest && file.isOnTheSameLine(test, questionMarkToken)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._beforeConsequent && file.isOnTheSameLine(questionMarkToken, consequent)) {··· token = file.getNextToken(questionMarkToken); errors.assert.noWhitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Illegal space before consequent' }); } |
✓ Negative was executed (else) | }··· if (this._afterConsequent && file.isOnTheSameLine(consequent, colonToken)) { |
Branch LogicalExpression | |
✓ Was returned | if (this._beforeConsequent && file.isOnTheSameLine(questionMarkToken, consequent)) { |
✓ Was returned | if (this._beforeConsequent && file.isOnTheSameLine(questionMarkToken, consequent)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._afterConsequent && file.isOnTheSameLine(consequent, colonToken)) {··· token = file.getPrevToken(colonToken); errors.assert.noWhitespaceBetween({ token: token, nextToken: colonToken, message: 'Illegal space after consequent' }); } |
✓ Negative was executed (else) | }··· if (this._beforeAlternate && file.isOnTheSameLine(colonToken, alternate)) { |
Branch LogicalExpression | |
✓ Was returned | if (this._afterConsequent && file.isOnTheSameLine(consequent, colonToken)) { |
✓ Was returned | if (this._afterConsequent && file.isOnTheSameLine(consequent, colonToken)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._beforeAlternate && file.isOnTheSameLine(colonToken, alternate)) {··· token = file.getNextToken(colonToken); errors.assert.noWhitespaceBetween({ token: colonToken, nextToken: token, message: 'Illegal space before alternate' }); } |
✓ Negative was executed (else) | }··· }.bind(this)); |
Branch LogicalExpression | |
✓ Was returned | if (this._beforeAlternate && file.isOnTheSameLine(colonToken, alternate)) { |
✓ Was returned | if (this._beforeAlternate && file.isOnTheSameLine(colonToken, alternate)) { |
Function (anonymous_619) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_620) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_621) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInForStatement'; }, |
Function (anonymous_622) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ForStatement', function(node) { if (node.test) { var testToken = file.getFirstNodeToken(node.test); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(testToken), nextToken: testToken, message: 'Space found after semicolon' }); } if (node.update) { var updateToken = file.getFirstNodeToken(node.update); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, message: 'Space found after semicolon' }); } }); } |
Function (anonymous_623) | |
---|---|
✓ Was called | file.iterateNodesByType('ForStatement', function(node) {··· if (node.test) { var testToken = file.getFirstNodeToken(node.test); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(testToken), nextToken: testToken, message: 'Space found after semicolon' }); } if (node.update) { var updateToken = file.getFirstNodeToken(node.update); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, message: 'Space found after semicolon' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.test) {··· var testToken = file.getFirstNodeToken(node.test); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(testToken), nextToken: testToken, message: 'Space found after semicolon' }); } |
✓ Negative was executed (else) | }··· if (node.update) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.update) {··· var updateToken = file.getFirstNodeToken(node.update); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, message: 'Space found after semicolon' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_624) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_625) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_626) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInFunctionDeclaration'; }, |
Function (anonymous_627) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionDeclaration'], function(node) { // Exception for `export default function` #1376 if (!node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(node.id); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); } |
Function (anonymous_628) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionDeclaration'], function(node) {··· // Exception for `export default function` #1376 if (!node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(node.id); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!node.id) {··· return; } |
✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(node.id); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
Branch LogicalExpression | |
✗ Was not returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Branch LogicalExpression | |
✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
✓ Was returned | if (node.generator && functionToken.value === 'function') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_629) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_630) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_631) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInFunctionExpression'; }, |
Function (anonymous_632) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType('FunctionExpression', function(node) { // for a named function, use node.id var functionNode = node.id || node; if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); } |
Function (anonymous_633) | |
---|---|
✓ Was called | file.iterateNodesByType('FunctionExpression', function(node) {··· // for a named function, use node.id var functionNode = node.id || node; if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | var functionNode = node.id || node; |
✓ Was returned | var functionNode = node.id || node; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
Branch LogicalExpression | |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Branch LogicalExpression | |
✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
✓ Was returned | if (node.generator && functionToken.value === 'function') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_634) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_635) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_636) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInFunction'; }, |
Function (anonymous_637) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); } |
Function (anonymous_638) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | var functionNode = node.id || node; |
✓ Was returned | var functionNode = node.id || node; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
✓ Negative was executed (else) | }··· // shorthand or constructor methods |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
Branch LogicalExpression | |
✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
✗ Was not returned | if (parent.method || parent.type === 'MethodDefinition') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
Branch LogicalExpression | |
✗ Was not returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Branch LogicalExpression | |
✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
✓ Was returned | if (node.generator && functionToken.value === 'function') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_639) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_640) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be an object' ); if ('beforeStar' in options) { assert( options.beforeStar === true, this.getOptionName() + '.beforeStar ' + 'property requires true value or should be removed' ); } if ('afterStar' in options) { assert( options.afterStar === true, this.getOptionName() + '.afterStar ' + 'property requires true value or should be removed' ); } assert( options.beforeStar || options.afterStar, this.getOptionName() + ' must have beforeStar or afterStar property' ); this._beforeStar = options.beforeStar; this._afterStar = options.afterStar; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeStar' in options) {··· assert( options.beforeStar === true, this.getOptionName() + '.beforeStar ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('afterStar' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('afterStar' in options) {··· assert( options.afterStar === true, this.getOptionName() + '.afterStar ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeStar || options.afterStar, |
✓ Was returned | options.beforeStar || options.afterStar, |
Function (anonymous_641) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInGenerator'; }, |
Function (anonymous_642) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeStar = this._beforeStar; var afterStar = this._afterStar; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { if (!node.generator) { return; } var parent = node.parentElement; var shorthand = node.shorthand; // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { node = parent.key; } var currentToken = file.getFirstNodeToken(node); if (node.async && currentToken.value === 'async') { currentToken = file.getNextToken(currentToken); } if (beforeStar && !shorthand) { // currentToken assigned outside of function errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space before star' }); } if (afterStar) { if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space after star' }); } }); } |
Function (anonymous_643) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· if (!node.generator) { return; } var parent = node.parentElement; var shorthand = node.shorthand; // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { node = parent.key; } var currentToken = file.getFirstNodeToken(node); if (node.async && currentToken.value === 'async') { currentToken = file.getNextToken(currentToken); } if (beforeStar && !shorthand) { // currentToken assigned outside of function errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space before star' }); } if (afterStar) { if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space after star' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!node.generator) {··· return; } |
✓ Negative was executed (else) | }··· var parent = node.parentElement; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· node = parent.key; } |
✓ Negative was executed (else) | }··· var currentToken = file.getFirstNodeToken(node); |
Branch LogicalExpression | |
✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
✗ Was not returned | if (parent.method || parent.type === 'MethodDefinition') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.async && currentToken.value === 'async') {··· currentToken = file.getNextToken(currentToken); } |
✓ Negative was executed (else) | }··· if (beforeStar && !shorthand) { |
Branch LogicalExpression | |
✓ Was returned | if (node.async && currentToken.value === 'async') { |
✓ Was returned | if (node.async && currentToken.value === 'async') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeStar && !shorthand) {··· // currentToken assigned outside of function errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space before star' }); } |
✓ Negative was executed (else) | }··· if (afterStar) { |
Branch LogicalExpression | |
✓ Was returned | if (beforeStar && !shorthand) { |
✓ Was returned | if (beforeStar && !shorthand) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (afterStar) {··· if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.noWhitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Illegal space after star' }); } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (shorthand) {··· currentToken = file.getPrevToken(currentToken); } else { |
✓ Negative was executed (else) | } else {··· // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } |
Function (anonymous_644) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_645) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace ' + 'or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_646) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInNamedFunctionExpression'; }, |
Function (anonymous_647) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionExpression'], function(node) { var functionNode = node.id; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // named function expressions only if (node.id) { if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } } }); } |
Function (anonymous_648) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· var functionNode = node.id; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // named function expressions only if (node.id) { if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } } }); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
✓ Negative was executed (else) | }··· // shorthand or constructor methods |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
✓ Negative was executed (else) | }··· // named function expressions only |
Branch LogicalExpression | |
✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
✗ Was not returned | if (parent.method || parent.type === 'MethodDefinition') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.id) {··· if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } } |
✗ Negative was not executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.noWhitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Illegal space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Branch LogicalExpression | |
✗ Was not returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.noWhitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Illegal space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_649) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_650) | |
---|---|
✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'nested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string value "all" or "nested" or object'; if (typeof value === 'string' || value === true) { assert(modes[value === true ? 'all' : value], error); } else if (isObject) { assert('allExcept' in value, error); } else { assert(false, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { mode = value; } if (mode === 'nested') { this._exceptions['['] = this._exceptions[']'] = true; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof value === 'string' || value === true) {··· assert(modes[value === true ? 'all' : value], error); } else if (isObject) { |
✓ Negative was executed (else) | } else if (isObject) {··· assert('allExcept' in value, error); } else { assert(false, error); } |
Branch LogicalExpression | |
✓ Was returned | if (typeof value === 'string' || value === true) { |
✓ Was returned | if (typeof value === 'string' || value === true) { |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | assert(modes[value === true ? 'all' : value], error); |
✓ Negative was returned (: ...) | assert(modes[value === true ? 'all' : value], error); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (isObject) {··· assert('allExcept' in value, error); } else { |
✓ Negative was executed (else) | } else {··· assert(false, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { |
✓ Negative was executed (else) | } else {··· mode = value; } |
Function (anonymous_651) | |
---|---|
✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (mode === 'nested') {··· this._exceptions['['] = this._exceptions[']'] = true; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_652) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideArrayBrackets'; }, |
Function (anonymous_653) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateNodesByType('ArrayExpression', function(node) { var openBracket = node.getFirstToken(); var afterOpen = file.getNextToken(openBracket, {includeComments: true}); var closeBracket = file.getLastNodeToken(node); var beforeClose = file.getPrevToken(closeBracket, {includeComments: true}); // Skip for empty array brackets if (afterOpen.value === ']') { return; } if (!(afterOpen.value in exceptions)) { errors.assert.noWhitespaceBetween({ token: openBracket, nextToken: afterOpen, message: 'Illegal space after opening bracket' }); } if (!(beforeClose.value in exceptions)) { errors.assert.noWhitespaceBetween({ token: beforeClose, nextToken: closeBracket, message: 'Illegal space before closing bracket' }); } }); } |
Function (anonymous_654) | |
---|---|
✓ Was called | file.iterateNodesByType('ArrayExpression', function(node) {··· var openBracket = node.getFirstToken(); var afterOpen = file.getNextToken(openBracket, {includeComments: true}); var closeBracket = file.getLastNodeToken(node); var beforeClose = file.getPrevToken(closeBracket, {includeComments: true}); // Skip for empty array brackets if (afterOpen.value === ']') { return; } if (!(afterOpen.value in exceptions)) { errors.assert.noWhitespaceBetween({ token: openBracket, nextToken: afterOpen, message: 'Illegal space after opening bracket' }); } if (!(beforeClose.value in exceptions)) { errors.assert.noWhitespaceBetween({ token: beforeClose, nextToken: closeBracket, message: 'Illegal space before closing bracket' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (afterOpen.value === ']') {··· return; } |
✓ Negative was executed (else) | }··· if (!(afterOpen.value in exceptions)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!(afterOpen.value in exceptions)) {··· errors.assert.noWhitespaceBetween({ token: openBracket, nextToken: afterOpen, message: 'Illegal space after opening bracket' }); } |
✓ Negative was executed (else) | }··· if (!(beforeClose.value in exceptions)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!(beforeClose.value in exceptions)) {··· errors.assert.noWhitespaceBetween({ token: beforeClose, nextToken: closeBracket, message: 'Illegal space before closing bracket' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_655) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_656) | |
---|---|
✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_657) | |
---|---|
✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
Function (anonymous_658) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideBrackets'; }, |
Function (anonymous_659) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokensByTypeAndValue('Punctuator', '[', function(token) { var nextToken = file.getNextToken(token, { includeComments: true }); var value = nextToken.getSourceCode(); if (value in exceptions) { return; } // Skip for empty array brackets if (value === ']') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening bracket' }); }); file.iterateTokensByTypeAndValue('Punctuator', ']', function(token) { var prevToken = file.getPrevToken(token, { includeComments: true }); var value = prevToken.getSourceCode(); if (value in exceptions) { return; } // Skip for empty array brackets if (value === '[') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing bracket' }); }); } |
Function (anonymous_660) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', '[', function(token) {··· var nextToken = file.getNextToken(token, { includeComments: true }); var value = nextToken.getSourceCode(); if (value in exceptions) { return; } // Skip for empty array brackets if (value === ']') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening bracket' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· // Skip for empty array brackets |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === ']') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Function (anonymous_661) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ']', function(token) {··· var prevToken = file.getPrevToken(token, { includeComments: true }); var value = prevToken.getSourceCode(); if (value in exceptions) { return; } // Skip for empty array brackets if (value === '[') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing bracket' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· // Skip for empty array brackets |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === '[') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Function (anonymous_662) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_663) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_664) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideImportedObjectBraces'; }, |
Function (anonymous_665) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ImportDeclaration'], function(node) { if (!node.specifiers) { return; } node.specifiers.forEach(function(specifier) { if (specifier.type !== 'ImportSpecifier') { return; } var maybeOpeningBrace = file.getPrevToken(specifier.getFirstToken()); var maybeClosingBrace = file.getNextToken(specifier.getLastToken()); if (maybeOpeningBrace.value === '{') { errors.assert.noWhitespaceBetween({ token: maybeOpeningBrace, nextToken: specifier.getFirstToken(), message: 'Illegal space after opening curly brace' }); } if (maybeClosingBrace.value === '}') { errors.assert.noWhitespaceBetween({ token: specifier.getLastToken(), nextToken: maybeClosingBrace, message: 'Illegal space before closing curly brace' }); } }); }); } |
Function (anonymous_666) | |
---|---|
✓ Was called | file.iterateNodesByType(['ImportDeclaration'], function(node) {··· if (!node.specifiers) { return; } node.specifiers.forEach(function(specifier) { if (specifier.type !== 'ImportSpecifier') { return; } var maybeOpeningBrace = file.getPrevToken(specifier.getFirstToken()); var maybeClosingBrace = file.getNextToken(specifier.getLastToken()); if (maybeOpeningBrace.value === '{') { errors.assert.noWhitespaceBetween({ token: maybeOpeningBrace, nextToken: specifier.getFirstToken(), message: 'Illegal space after opening curly brace' }); } if (maybeClosingBrace.value === '}') { errors.assert.noWhitespaceBetween({ token: specifier.getLastToken(), nextToken: maybeClosingBrace, message: 'Illegal space before closing curly brace' }); } }); }); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!node.specifiers) {··· return; } |
✓ Negative was executed (else) | }··· node.specifiers.forEach(function(specifier) { |
Function (anonymous_667) | |
---|---|
✓ Was called | node.specifiers.forEach(function(specifier) {··· if (specifier.type !== 'ImportSpecifier') { return; } var maybeOpeningBrace = file.getPrevToken(specifier.getFirstToken()); var maybeClosingBrace = file.getNextToken(specifier.getLastToken()); if (maybeOpeningBrace.value === '{') { errors.assert.noWhitespaceBetween({ token: maybeOpeningBrace, nextToken: specifier.getFirstToken(), message: 'Illegal space after opening curly brace' }); } if (maybeClosingBrace.value === '}') { errors.assert.noWhitespaceBetween({ token: specifier.getLastToken(), nextToken: maybeClosingBrace, message: 'Illegal space before closing curly brace' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (specifier.type !== 'ImportSpecifier') {··· return; } |
✓ Negative was executed (else) | }··· var maybeOpeningBrace = file.getPrevToken(specifier.getFirstToken()); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (maybeOpeningBrace.value === '{') {··· errors.assert.noWhitespaceBetween({ token: maybeOpeningBrace, nextToken: specifier.getFirstToken(), message: 'Illegal space after opening curly brace' }); } |
✓ Negative was executed (else) | }··· if (maybeClosingBrace.value === '}') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (maybeClosingBrace.value === '}') {··· errors.assert.noWhitespaceBetween({ token: specifier.getLastToken(), nextToken: maybeClosingBrace, message: 'Illegal space before closing curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_668) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_669) | |
---|---|
✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'nested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string "all" or "nested", true value or object'; if (typeof value === 'string' || value === true) { assert(modes[value === true ? 'all' : value], error); } else if (isObject) { assert('allExcept' in value, error); } else { assert(false, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { mode = value; } if (mode === 'nested') { this._exceptions['}'] = true; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof value === 'string' || value === true) {··· assert(modes[value === true ? 'all' : value], error); } else if (isObject) { |
✓ Negative was executed (else) | } else if (isObject) {··· assert('allExcept' in value, error); } else { assert(false, error); } |
Branch LogicalExpression | |
✓ Was returned | if (typeof value === 'string' || value === true) { |
✓ Was returned | if (typeof value === 'string' || value === true) { |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | assert(modes[value === true ? 'all' : value], error); |
✓ Negative was returned (: ...) | assert(modes[value === true ? 'all' : value], error); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (isObject) {··· assert('allExcept' in value, error); } else { |
✓ Negative was executed (else) | } else {··· assert(false, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { |
✓ Negative was executed (else) | } else {··· mode = value; } |
Function (anonymous_670) | |
---|---|
✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (mode === 'nested') {··· this._exceptions['}'] = true; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_671) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideObjectBrackets'; }, |
Function (anonymous_672) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateNodesByType(['ObjectExpression', 'ObjectPattern'], function(node) { var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket); errors.assert.noWhitespaceBetween({ token: openingBracket, nextToken: nextToken, message: 'Illegal space after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket); if (prevToken.value in exceptions) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: closingBracket, message: 'Illegal space before closing curly brace' }); }); } |
Function (anonymous_673) | |
---|---|
✓ Was called | file.iterateNodesByType(['ObjectExpression', 'ObjectPattern'], function(node) {··· var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket); errors.assert.noWhitespaceBetween({ token: openingBracket, nextToken: nextToken, message: 'Illegal space after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket); if (prevToken.value in exceptions) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: closingBracket, message: 'Illegal space before closing curly brace' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Function (anonymous_674) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_675) | |
---|---|
✓ Was called | configure: function(option) {··· var isObject = typeof option === 'object'; var error = this.getOptionName() + ' option requires' + ' true or object value with "only" properties '; // backcompat for 1.10: {all: true} #1027 if (isObject && option.all === true) { option = true; } if (typeof option === 'boolean') { assert(option === true, error); } else if (isObject) { assert('only' in option, error); } else { assert(false, error); } this._onlySingleQuote = false; this._onlyDoubleQuote = false; this._only = null; if (option.only) { this._only = {}; (option.only).forEach(function(value) { if (value === '\'') { this._onlySingleQuote = true; } if (value === '"') { this._onlyDoubleQuote = true; } this._only[value] = true; }, this); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject && option.all === true) {··· option = true; } |
✓ Negative was executed (else) | }··· if (typeof option === 'boolean') { |
Branch LogicalExpression | |
✓ Was returned | if (isObject && option.all === true) { |
✓ Was returned | if (isObject && option.all === true) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof option === 'boolean') {··· assert(option === true, error); } else if (isObject) { |
✓ Negative was executed (else) | } else if (isObject) {··· assert('only' in option, error); } else { assert(false, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (isObject) {··· assert('only' in option, error); } else { |
✓ Negative was executed (else) | } else {··· assert(false, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (option.only) {··· this._only = {}; (option.only).forEach(function(value) { if (value === '\'') { this._onlySingleQuote = true; } if (value === '"') { this._onlyDoubleQuote = true; } this._only[value] = true; }, this); } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_676) | |
---|---|
✓ Was called | (option.only).forEach(function(value) {··· if (value === '\'') { this._onlySingleQuote = true; } if (value === '"') { this._onlyDoubleQuote = true; } this._only[value] = true; }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === '\'') {··· this._onlySingleQuote = true; } |
✓ Negative was executed (else) | }··· if (value === '"') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === '"') {··· this._onlyDoubleQuote = true; } |
✓ Negative was executed (else) | }··· this._only[value] = true; |
Function (anonymous_677) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideParentheses'; }, |
Function (anonymous_678) | |
---|---|
✓ Was called | check: function(file, errors) {··· var only = this._only; var singleQuote = this._onlySingleQuote; var doubleQuote = this._onlyDoubleQuote; var alreadyAdded = []; file.iterateTokensByTypeAndValue('Punctuator', '(', function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.getSourceCode(); var shouldReturn = true; if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { shouldReturn = false; } if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { shouldReturn = false; } if (only && value in only) { shouldReturn = false; } if (!only) { shouldReturn = false; } if (shouldReturn) { return; } var isAdded = errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening round bracket' }); if (isAdded) { alreadyAdded.push(token); } }); file.iterateTokensByTypeAndValue('Punctuator', ')', function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.getSourceCode(); var shouldReturn = true; // Do not check already found errors, like "function ( ) { ..." if (alreadyAdded.indexOf(prevToken) > -1) { return; } if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { shouldReturn = false; } if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { shouldReturn = false; } if (only) { if (value in only) { shouldReturn = false; } if ( value === ']' && prevToken.parentElement.type === 'MemberExpression' ) { shouldReturn = true; } } else { shouldReturn = false; } if (shouldReturn) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing round bracket' }); }); } |
Function (anonymous_679) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', '(', function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.getSourceCode(); var shouldReturn = true; if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { shouldReturn = false; } if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { shouldReturn = false; } if (only && value in only) { shouldReturn = false; } if (!only) { shouldReturn = false; } if (shouldReturn) { return; } var isAdded = errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening round bracket' }); if (isAdded) { alreadyAdded.push(token); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') {··· shouldReturn = false; } |
✓ Negative was executed (else) | }··· if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
Branch LogicalExpression | |
✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
Branch LogicalExpression | |
✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') {··· shouldReturn = false; } |
✓ Negative was executed (else) | }··· if (only && value in only) { |
Branch LogicalExpression | |
✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
Branch LogicalExpression | |
✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (only && value in only) {··· shouldReturn = false; } |
✓ Negative was executed (else) | }··· if (!only) { |
Branch LogicalExpression | |
✓ Was returned | if (only && value in only) { |
✓ Was returned | if (only && value in only) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!only) {··· shouldReturn = false; } |
✓ Negative was executed (else) | }··· if (shouldReturn) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (shouldReturn) {··· return; } |
✓ Negative was executed (else) | }··· var isAdded = errors.assert.noWhitespaceBetween({ |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isAdded) {··· alreadyAdded.push(token); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_680) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ')', function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.getSourceCode(); var shouldReturn = true; // Do not check already found errors, like "function ( ) { ..." if (alreadyAdded.indexOf(prevToken) > -1) { return; } if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { shouldReturn = false; } if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { shouldReturn = false; } if (only) { if (value in only) { shouldReturn = false; } if ( value === ']' && prevToken.parentElement.type === 'MemberExpression' ) { shouldReturn = true; } } else { shouldReturn = false; } if (shouldReturn) { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing round bracket' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (alreadyAdded.indexOf(prevToken) > -1) {··· return; } |
✓ Negative was executed (else) | }··· if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') {··· shouldReturn = false; } |
✓ Negative was executed (else) | }··· if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
Branch LogicalExpression | |
✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
Branch LogicalExpression | |
✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') {··· shouldReturn = false; } |
✓ Negative was executed (else) | }··· if (only) { |
Branch LogicalExpression | |
✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
Branch LogicalExpression | |
✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (only) {··· if (value in only) { shouldReturn = false; } if ( value === ']' && prevToken.parentElement.type === 'MemberExpression' ) { shouldReturn = true; } } else { |
✓ Negative was executed (else) | } else {··· shouldReturn = false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value in only) {··· shouldReturn = false; } |
✓ Negative was executed (else) | }··· if ( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· shouldReturn = true; } |
✓ Negative was executed (else) | }··· } else { |
Branch LogicalExpression | |
---|---|
✓ Was returned | prevToken.parentElement.type === 'MemberExpression' |
✓ Was returned | value === ']' && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (shouldReturn) {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Function (anonymous_681) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_682) | |
---|---|
✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_683) | |
---|---|
✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
Function (anonymous_684) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideParenthesizedExpression'; }, |
Function (anonymous_685) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokensByTypeAndValue('Punctuator', '(', function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.isComment ? nextToken.type === 'CommentBlock' ? '/*' : '//' : nextToken.value; // Skip empty parentheses and explicit exceptions if (value === ')' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeOpenParen(token); if (type !== 'ParenthesizedExpression') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening grouping parenthesis' }); }); file.iterateTokensByTypeAndValue('Punctuator', ')', function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.isComment ? prevToken.type === 'CommentBlock' ? '*/' : '' : prevToken.value; // Skip empty parentheses and explicit exceptions if (value === '(' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeCloseParen(token); if (type !== 'ParenthesizedExpression') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing grouping parenthesis' }); }); } |
Function (anonymous_686) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', '(', function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.isComment ? nextToken.type === 'CommentBlock' ? '/*' : '//' : nextToken.value; // Skip empty parentheses and explicit exceptions if (value === ')' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeOpenParen(token); if (type !== 'ParenthesizedExpression') { return; } errors.assert.noWhitespaceBetween({ token: token, nextToken: nextToken, message: 'Illegal space after opening grouping parenthesis' }); }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | nextToken.type === 'CommentBlock' ? '/*' : '//' : |
✓ Negative was returned (: ...) | nextToken.value; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | nextToken.type === 'CommentBlock' ? '/*' : '//' : |
✓ Negative was returned (: ...) | nextToken.type === 'CommentBlock' ? '/*' : '//' : |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === ')' || value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· // Skip non-expression parentheses |
Branch LogicalExpression | |
✓ Was returned | if (value === ')' || value in exceptions) { |
✓ Was returned | if (value === ')' || value in exceptions) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (type !== 'ParenthesizedExpression') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Function (anonymous_687) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ')', function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.isComment ? prevToken.type === 'CommentBlock' ? '*/' : '' : prevToken.value; // Skip empty parentheses and explicit exceptions if (value === '(' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeCloseParen(token); if (type !== 'ParenthesizedExpression') { return; } errors.assert.noWhitespaceBetween({ token: prevToken, nextToken: token, message: 'Illegal space before closing grouping parenthesis' }); }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | prevToken.type === 'CommentBlock' ? '*/' : '' : |
✓ Negative was returned (: ...) | prevToken.value; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | prevToken.type === 'CommentBlock' ? '*/' : '' : |
✓ Negative was returned (: ...) | prevToken.type === 'CommentBlock' ? '*/' : '' : |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === '(' || value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· // Skip non-expression parentheses |
Branch LogicalExpression | |
✓ Was returned | if (value === '(' || value in exceptions) { |
✓ Was returned | if (value === '(' || value in exceptions) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (type !== 'ParenthesizedExpression') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.noWhitespaceBetween({ |
Function nodeContains | |
---|---|
✓ Was called | function nodeContains(node, token) {··· var currentNode = token.parentElement; while (currentNode) { if (currentNode === node) { return true; } currentNode = currentNode.parentElement; } return false; } |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (currentNode === node) {··· return true; } |
✓ Negative was executed (else) | }··· currentNode = currentNode.parentElement; |
Function (anonymous_689) | |
---|---|
✓ Was called | exports.categorizeOpenParen = function(token) {··· assert(token.value === '(', 'Input token must be a parenthesis'); var node = token.parentElement; var nodeType = node.type; var prevToken = token.getPreviousCodeToken(); // Outermost grouping parenthesis if (!prevToken) { return 'ParenthesizedExpression'; } // Part of a parentheses-bearing statement (if, with, while, switch, etc.) if (prevToken.type === 'Keyword' && PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { return 'Statement'; } // Part of a function definition (declaration, expression, method, etc.) if (FUNCTION_TYPE_RE.test(nodeType) && // Name is optional for function expressions (prevToken.type === 'Identifier' || prevToken.value === 'function')) { return 'Function'; } // Part of a call expression var prevNode = prevToken.parentElement; if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && // Must not be inside an arguments list or other grouping parentheses prevToken.value !== ',' && prevToken.value !== '(' && // If the callee is parenthesized (e.g., `(foo.bar)()`), prevNode will match node // Otherwise (e.g., `foo.bar()`), prevToken must be the last token of the callee node (prevNode === node || prevToken === node.callee.getLastToken())) { return 'CallExpression'; } // All remaining cases are grouping parentheses return 'ParenthesizedExpression'; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!prevToken) {··· return 'ParenthesizedExpression'; } |
✓ Negative was executed (else) | }··· // Part of a parentheses-bearing statement (if, with, while, switch, etc.) |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) {··· return 'Statement'; } |
✓ Negative was executed (else) | }··· // Part of a function definition (declaration, expression, method, etc.) |
Branch LogicalExpression | |
✓ Was returned | !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { |
✓ Was returned | if (prevToken.type === 'Keyword' && PAREN_KEYWORD_TYPE_RE.test(nodeType) && |
Branch LogicalExpression | |
✓ Was returned | if (prevToken.type === 'Keyword' && PAREN_KEYWORD_TYPE_RE.test(nodeType) && |
✓ Was returned | if (prevToken.type === 'Keyword' && PAREN_KEYWORD_TYPE_RE.test(nodeType) && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | (prevToken.type === 'Identifier' || prevToken.value === 'function')) {··· return 'Function'; } |
✓ Negative was executed (else) | }··· // Part of a call expression |
Branch LogicalExpression | |
✓ Was returned | (prevToken.type === 'Identifier' || prevToken.value === 'function')) { |
✓ Was returned | if (FUNCTION_TYPE_RE.test(nodeType) && |
Branch LogicalExpression | |
---|---|
✓ Was returned | (prevToken.type === 'Identifier' || prevToken.value === 'function')) { |
✓ Was returned | (prevToken.type === 'Identifier' || prevToken.value === 'function')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | (prevNode === node || prevToken === node.callee.getLastToken())) {··· return 'CallExpression'; } |
✓ Negative was executed (else) | }··· // All remaining cases are grouping parentheses |
Branch LogicalExpression | |
✓ Was returned | (prevNode === node || prevToken === node.callee.getLastToken())) { |
✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') &&··· // Must not be inside an arguments list or other grouping parentheses prevToken.value !== ',' && prevToken.value !== '(' && |
Branch LogicalExpression | |
✓ Was returned | prevToken.value !== ',' && prevToken.value !== '(' && |
✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') &&··· // Must not be inside an arguments list or other grouping parentheses prevToken.value !== ',' && prevToken.value !== '(' && |
Branch LogicalExpression | |
✓ Was returned | prevToken.value !== ',' && prevToken.value !== '(' && |
✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && |
Branch LogicalExpression | |
✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && |
✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression') && |
Branch LogicalExpression | |
---|---|
✓ Was returned | (prevNode === node || prevToken === node.callee.getLastToken())) { |
✓ Was returned | (prevNode === node || prevToken === node.callee.getLastToken())) { |
Function (anonymous_690) | |
---|---|
✓ Was called | exports.categorizeCloseParen = function(token) {··· assert(token.value === ')', 'Input token must be a parenthesis'); var node = token.parentElement; var nodeType = node.type; var nextToken = token.getNextCodeToken(); // Terminal statement if (nextToken.type === 'EOF') { switch (nodeType) { case 'DoWhileStatement': return 'Statement'; case 'CallExpression': case 'NewExpression': return 'CallExpression'; default: return 'ParenthesizedExpression'; } } // Part of a parentheses-bearing statement (if, with, while, switch, etc.) if (PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { // Closing parentheses for `switch` and `catch` must be followed by "{" // Closing parentheses for `do..while` may be the last punctuation inside a block if (nextToken.value === '{' || nextToken.value === '}') { return 'Statement'; } // Closing parentheses for other statements must be followed by a statement or declaration var nextNode = nextToken.parentElement; while (!nodeContains(nextNode, token)) { if (QUASI_STATEMENT_TYPE_RE.test(nextNode.type)) { return 'Statement'; } nextNode = nextNode.parentElement; } } // Part of a function definition (declaration, expression, method, etc.) if (nextToken.value === '{' && FUNCTION_TYPE_RE.test(nodeType)) { return 'Function'; } // Part of a call expression if ((nodeType === 'CallExpression' || nodeType === 'NewExpression')) { var openParen = node.callee.getNextToken(); if (openParen.parentElement === node && node.lastChild === token) { return 'CallExpression'; } } // All remaining cases are grouping parentheses return 'ParenthesizedExpression'; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.type === 'EOF') {··· switch (nodeType) { case 'DoWhileStatement': return 'Statement'; case 'CallExpression': case 'NewExpression': return 'CallExpression'; default: return 'ParenthesizedExpression'; } } |
✓ Negative was executed (else) | }··· // Part of a parentheses-bearing statement (if, with, while, switch, etc.) |
Branch SwitchStatement | |
---|---|
✓ Was evaluated | case 'DoWhileStatement':··· return 'Statement'; |
✓ Was evaluated | case 'CallExpression': |
✓ Was evaluated | case 'NewExpression':··· return 'CallExpression'; |
✓ Was evaluated | default:··· return 'ParenthesizedExpression'; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) {··· // Closing parentheses for `switch` and `catch` must be followed by "{" // Closing parentheses for `do..while` may be the last punctuation inside a block if (nextToken.value === '{' || nextToken.value === '}') { return 'Statement'; } // Closing parentheses for other statements must be followed by a statement or declaration var nextNode = nextToken.parentElement; while (!nodeContains(nextNode, token)) { if (QUASI_STATEMENT_TYPE_RE.test(nextNode.type)) { return 'Statement'; } nextNode = nextNode.parentElement; } } |
✓ Negative was executed (else) | }··· // Part of a function definition (declaration, expression, method, etc.) |
Branch LogicalExpression | |
✓ Was returned | if (PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { |
✓ Was returned | if (PAREN_KEYWORD_TYPE_RE.test(nodeType) && !NO_PAREN_KEYWORD_TYPE_RE.test(nodeType)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.value === '{' || nextToken.value === '}') {··· return 'Statement'; } |
✓ Negative was executed (else) | }··· // Closing parentheses for other statements must be followed by a statement or declaration |
Branch LogicalExpression | |
✓ Was returned | if (nextToken.value === '{' || nextToken.value === '}') { |
✓ Was returned | if (nextToken.value === '{' || nextToken.value === '}') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (QUASI_STATEMENT_TYPE_RE.test(nextNode.type)) {··· return 'Statement'; } |
✗ Negative was not executed (else) | }··· nextNode = nextNode.parentElement; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.value === '{' && FUNCTION_TYPE_RE.test(nodeType)) {··· return 'Function'; } |
✓ Negative was executed (else) | }··· // Part of a call expression |
Branch LogicalExpression | |
✓ Was returned | if (nextToken.value === '{' && FUNCTION_TYPE_RE.test(nodeType)) { |
✓ Was returned | if (nextToken.value === '{' && FUNCTION_TYPE_RE.test(nodeType)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression')) {··· var openParen = node.callee.getNextToken(); if (openParen.parentElement === node && node.lastChild === token) { return 'CallExpression'; } } |
✓ Negative was executed (else) | }··· // All remaining cases are grouping parentheses |
Branch LogicalExpression | |
✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression')) { |
✓ Was returned | if ((nodeType === 'CallExpression' || nodeType === 'NewExpression')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (openParen.parentElement === node && node.lastChild === token) {··· return 'CallExpression'; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (openParen.parentElement === node && node.lastChild === token) { |
✗ Was not returned | if (openParen.parentElement === node && node.lastChild === token) { |
Function (anonymous_691) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_692) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_693) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowSpacesInsideTemplateStringPlaceholders'; }, |
Function (anonymous_694) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('TemplateLiteral', function(node) { node.childElements .filter(function(element) { return element.isToken && element.type === 'Punctuator'; }) .forEach(function(element) { if (element.value === '${' && element.nextSibling.isWhitespace) { errors.assert.noWhitespaceBetween({ token: element, nextToken: element.getNextCodeToken(), message: 'Illegal space after "${"' }); } if (element.value === '}' && element.previousSibling.isWhitespace) { errors.assert.noWhitespaceBetween({ token: element.getPreviousCodeToken(), nextToken: element, message: 'Illegal space before "}"' }); } }); }); } |
Function (anonymous_695) | |
---|---|
✓ Was called | file.iterateNodesByType('TemplateLiteral', function(node) {··· node.childElements .filter(function(element) { return element.isToken && element.type === 'Punctuator'; }) .forEach(function(element) { if (element.value === '${' && element.nextSibling.isWhitespace) { errors.assert.noWhitespaceBetween({ token: element, nextToken: element.getNextCodeToken(), message: 'Illegal space after "${"' }); } if (element.value === '}' && element.previousSibling.isWhitespace) { errors.assert.noWhitespaceBetween({ token: element.getPreviousCodeToken(), nextToken: element, message: 'Illegal space before "}"' }); } }); }); |
Function (anonymous_696) | |
---|---|
✓ Was called | .filter(function(element) {··· return element.isToken && element.type === 'Punctuator'; }) |
Branch LogicalExpression | |
---|---|
✓ Was returned | return element.isToken && element.type === 'Punctuator'; |
✓ Was returned | return element.isToken && element.type === 'Punctuator'; |
Function (anonymous_697) | |
---|---|
✓ Was called | .forEach(function(element) {··· if (element.value === '${' && element.nextSibling.isWhitespace) { errors.assert.noWhitespaceBetween({ token: element, nextToken: element.getNextCodeToken(), message: 'Illegal space after "${"' }); } if (element.value === '}' && element.previousSibling.isWhitespace) { errors.assert.noWhitespaceBetween({ token: element.getPreviousCodeToken(), nextToken: element, message: 'Illegal space before "}"' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (element.value === '${' && element.nextSibling.isWhitespace) {··· errors.assert.noWhitespaceBetween({ token: element, nextToken: element.getNextCodeToken(), message: 'Illegal space after "${"' }); } |
✓ Negative was executed (else) | }··· if (element.value === '}' && element.previousSibling.isWhitespace) { |
Branch LogicalExpression | |
✓ Was returned | if (element.value === '${' && element.nextSibling.isWhitespace) { |
✓ Was returned | if (element.value === '${' && element.nextSibling.isWhitespace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (element.value === '}' && element.previousSibling.isWhitespace) {··· errors.assert.noWhitespaceBetween({ token: element.getPreviousCodeToken(), nextToken: element, message: 'Illegal space before "}"' }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (element.value === '}' && element.previousSibling.isWhitespace) { |
✓ Was returned | if (element.value === '}' && element.previousSibling.isWhitespace) { |
Function (anonymous_698) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_699) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_700) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowTabs'; }, |
Function (anonymous_701) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByType('Whitespace', function(whitespace) { var match = whitespace.value.match(/\t/); if (match) { errors.add('Tab found', whitespace, match.index); } }); } |
Function (anonymous_702) | |
---|---|
✓ Was called | file.iterateTokensByType('Whitespace', function(whitespace) {··· var match = whitespace.value.match(/\t/); if (match) { errors.add('Tab found', whitespace, match.index); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (match) {··· errors.add('Tab found', whitespace, match.index); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_703) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_704) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_705) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowTrailingComma'; }, |
Function (anonymous_706) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType([ 'ObjectExpression', 'ArrayExpression', 'ObjectPattern', 'ArrayPattern' ], function(node) { var closingToken = file.getLastNodeToken(node); var comma = closingToken.getPreviousCodeToken(); if (comma.type === 'Punctuator' && comma.value === ',') { errors.add( 'Extra comma following the final element of an array or object literal', comma ); } }); }, |
Function (anonymous_707) | |
---|---|
✓ Was called | ], function(node) {··· var closingToken = file.getLastNodeToken(node); var comma = closingToken.getPreviousCodeToken(); if (comma.type === 'Punctuator' && comma.value === ',') { errors.add( 'Extra comma following the final element of an array or object literal', comma ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (comma.type === 'Punctuator' && comma.value === ',') {··· errors.add( 'Extra comma following the final element of an array or object literal', comma ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (comma.type === 'Punctuator' && comma.value === ',') { |
✓ Was returned | if (comma.type === 'Punctuator' && comma.value === ',') { |
Function (anonymous_708) | |
---|---|
✓ Was called | _fix: function(file, error) {··· error.element.remove(); } |
Function (anonymous_709) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_710) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || options === 'ignoreEmptyLines', this.getOptionName() + ' option requires a true value or "ignoreEmptyLines"' ); this._ignoreEmptyLines = options === 'ignoreEmptyLines'; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || options === 'ignoreEmptyLines', |
✓ Was returned | options === true || options === 'ignoreEmptyLines', |
Function (anonymous_711) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowTrailingWhitespace'; }, |
Function (anonymous_712) | |
---|---|
✓ Was called | check: function(file, errors) {··· var program = file.getProgram(); if (!program) { return; } var lastToken = program.getLastToken(); if (lastToken && lastToken.type === 'EOF') { lastToken = lastToken.getPreviousToken(); } program.selectTokensByType('Whitespace').forEach(function(whitespace) { whitespace.getValueLineInfo().some(function(line, i) { if (this._ignoreEmptyLines && i > 0) { return true; } if (line.text && (line.lineBreak || whitespace === lastToken)) { errors.cast({ message: 'Illegal trailing whitespace', element: whitespace, offset: line.offset, additional: { lineNumber: i } }); } }, this); }, this); program.selectTokensByType('CommentBlock').concat(program.selectTokensByType('CommentLine')) .forEach(function(comment) { var lines = comment.getValueLineInfo(); lines.forEach(function(line, i) { if (i > 0 && this._ignoreEmptyLines && line.text.trim() === '') { return; } if (comment.type === 'CommentBlock' && i === lines.length - 1) { return; } if (line.text.match(/\s$/)) { errors.cast({ message: 'Illegal trailing comment', element: comment, offset: line.offset, additional: { lineNumber: i } }); } }, this); }, this); }, |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!program) {··· return; } |
✓ Negative was executed (else) | }··· var lastToken = program.getLastToken(); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lastToken && lastToken.type === 'EOF') {··· lastToken = lastToken.getPreviousToken(); } |
✗ Negative was not executed (else) | }··· program.selectTokensByType('Whitespace').forEach(function(whitespace) { |
Branch LogicalExpression | |
✓ Was returned | if (lastToken && lastToken.type === 'EOF') { |
✗ Was not returned | if (lastToken && lastToken.type === 'EOF') { |
Function (anonymous_713) | |
---|---|
✓ Was called | program.selectTokensByType('Whitespace').forEach(function(whitespace) {··· whitespace.getValueLineInfo().some(function(line, i) { if (this._ignoreEmptyLines && i > 0) { return true; } if (line.text && (line.lineBreak || whitespace === lastToken)) { errors.cast({ message: 'Illegal trailing whitespace', element: whitespace, offset: line.offset, additional: { lineNumber: i } }); } }, this); }, this); |
Function (anonymous_714) | |
---|---|
✓ Was called | whitespace.getValueLineInfo().some(function(line, i) {··· if (this._ignoreEmptyLines && i > 0) { return true; } if (line.text && (line.lineBreak || whitespace === lastToken)) { errors.cast({ message: 'Illegal trailing whitespace', element: whitespace, offset: line.offset, additional: { lineNumber: i } }); } }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._ignoreEmptyLines && i > 0) {··· return true; } |
✓ Negative was executed (else) | }··· if (line.text && (line.lineBreak || whitespace === lastToken)) { |
Branch LogicalExpression | |
✓ Was returned | if (this._ignoreEmptyLines && i > 0) { |
✓ Was returned | if (this._ignoreEmptyLines && i > 0) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (line.text && (line.lineBreak || whitespace === lastToken)) {··· errors.cast({ message: 'Illegal trailing whitespace', element: whitespace, offset: line.offset, additional: { lineNumber: i } }); } |
✓ Negative was executed (else) | }··· }, this); |
Branch LogicalExpression | |
✓ Was returned | if (line.text && (line.lineBreak || whitespace === lastToken)) { |
✓ Was returned | if (line.text && (line.lineBreak || whitespace === lastToken)) { |
Branch LogicalExpression | |
✓ Was returned | if (line.text && (line.lineBreak || whitespace === lastToken)) { |
✓ Was returned | if (line.text && (line.lineBreak || whitespace === lastToken)) { |
Function (anonymous_715) | |
---|---|
✓ Was called | .forEach(function(comment) {··· var lines = comment.getValueLineInfo(); lines.forEach(function(line, i) { if (i > 0 && this._ignoreEmptyLines && line.text.trim() === '') { return; } if (comment.type === 'CommentBlock' && i === lines.length - 1) { return; } if (line.text.match(/\s$/)) { errors.cast({ message: 'Illegal trailing comment', element: comment, offset: line.offset, additional: { lineNumber: i } }); } }, this); }, this); |
Function (anonymous_716) | |
---|---|
✓ Was called | lines.forEach(function(line, i) {··· if (i > 0 && this._ignoreEmptyLines && line.text.trim() === '') { return; } if (comment.type === 'CommentBlock' && i === lines.length - 1) { return; } if (line.text.match(/\s$/)) { errors.cast({ message: 'Illegal trailing comment', element: comment, offset: line.offset, additional: { lineNumber: i } }); } }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (i > 0 && this._ignoreEmptyLines && line.text.trim() === '') {··· return; } |
✓ Negative was executed (else) | }··· if (comment.type === 'CommentBlock' && i === lines.length - 1) { |
Branch LogicalExpression | |
✓ Was returned | if (i > 0 && this._ignoreEmptyLines && line.text.trim() === '') { |
✓ Was returned | if (i > 0 && this._ignoreEmptyLines && line.text.trim() === '') { |
Branch LogicalExpression | |
✓ Was returned | if (i > 0 && this._ignoreEmptyLines && line.text.trim() === '') { |
✓ Was returned | if (i > 0 && this._ignoreEmptyLines && line.text.trim() === '') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (comment.type === 'CommentBlock' && i === lines.length - 1) {··· return; } |
✓ Negative was executed (else) | }··· if (line.text.match(/\s$/)) { |
Branch LogicalExpression | |
✓ Was returned | if (comment.type === 'CommentBlock' && i === lines.length - 1) { |
✓ Was returned | if (comment.type === 'CommentBlock' && i === lines.length - 1) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (line.text.match(/\s$/)) {··· errors.cast({ message: 'Illegal trailing comment', element: comment, offset: line.offset, additional: { lineNumber: i } }); } |
✓ Negative was executed (else) | }··· }, this); |
Function (anonymous_717) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var element = error.element; var newValue; var lines = element.getValueLineInfo(); var line = lines[error.additional.lineNumber]; if (element.isWhitespace) { line.text = ''; } if (element.isComment) { line.text = line.text.replace(/\s+$/, ''); } newValue = lines.map(function(line) { return line.text + (line.lineBreak || ''); }).join(''); var newElement = new Token(element.type, newValue); element.parentElement.replaceChild(newElement, element); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (element.isWhitespace) {··· line.text = ''; } |
✓ Negative was executed (else) | }··· if (element.isComment) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (element.isComment) {··· line.text = line.text.replace(/\s+$/, ''); } |
✓ Negative was executed (else) | }··· newValue = lines.map(function(line) { |
Function (anonymous_718) | |
---|---|
✓ Was called | newValue = lines.map(function(line) {··· return line.text + (line.lineBreak || ''); }).join(''); |
Branch LogicalExpression | |
---|---|
✓ Was returned | return line.text + (line.lineBreak || ''); |
✓ Was returned | return line.text + (line.lineBreak || ''); |
Function getUnusedNodes | |
---|---|
✓ Was called | function getUnusedNodes(node, variableMap, groupIfPossible) {··· if (node.type === 'AssignmentPattern') { return getUnusedNodes(node.left, variableMap, groupIfPossible); } if (node.type === 'Identifier') { var variable = variableMap[node.name]; var hasUsages = variable.getReferences().some(function(reference) { return !variable.getDefinitions().some(function(definition) { return reference.node === definition.node; }); }); if (hasUsages) { return []; } return [node]; } if (node.type === 'RestElement') { var restUnusedNodes = getUnusedNodes(node.argument, variableMap, groupIfPossible); if (groupIfPossible && restUnusedNodes.length === 1 && node.argument === restUnusedNodes[0]) { return [node]; } return restUnusedNodes; } if (node.type === 'ArrayPattern') { var unusedArrayNodes = []; node.elements.forEach(function(element) { if (element) { unusedArrayNodes = unusedArrayNodes.concat(getUnusedNodes(element, variableMap, groupIfPossible)); return; } unusedArrayNodes.push(null); }); if (groupIfPossible && unusedArrayNodes.length === node.elements.length) { if (node.elements.every(function(element, index) { return unusedArrayNodes[index] === element; })) { return [node]; } } return unusedArrayNodes.filter(function(node) { return node; }); } if (node.type === 'ObjectPattern') { var unusedObjectNodes = []; node.properties.forEach(function(property) { unusedObjectNodes = unusedObjectNodes.concat(getUnusedNodes(property.value, variableMap, groupIfPossible)); }); if (groupIfPossible && unusedObjectNodes.length === node.properties.length) { if (node.properties.every(function(property, index) { return unusedObjectNodes[index] === property.value; })) { return [node]; } } return unusedObjectNodes; } return []; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'AssignmentPattern') {··· return getUnusedNodes(node.left, variableMap, groupIfPossible); } |
✓ Negative was executed (else) | }··· if (node.type === 'Identifier') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'Identifier') {··· var variable = variableMap[node.name]; var hasUsages = variable.getReferences().some(function(reference) { return !variable.getDefinitions().some(function(definition) { return reference.node === definition.node; }); }); if (hasUsages) { return []; } return [node]; } |
✓ Negative was executed (else) | }··· if (node.type === 'RestElement') { |
Function (anonymous_720) | |
---|---|
✓ Was called | var hasUsages = variable.getReferences().some(function(reference) {··· return !variable.getDefinitions().some(function(definition) { return reference.node === definition.node; }); }); |
Function (anonymous_721) | |
---|---|
✓ Was called | return !variable.getDefinitions().some(function(definition) {··· return reference.node === definition.node; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (hasUsages) {··· return []; } |
✓ Negative was executed (else) | }··· return [node]; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'RestElement') {··· var restUnusedNodes = getUnusedNodes(node.argument, variableMap, groupIfPossible); if (groupIfPossible && restUnusedNodes.length === 1 && node.argument === restUnusedNodes[0]) { return [node]; } return restUnusedNodes; } |
✓ Negative was executed (else) | }··· if (node.type === 'ArrayPattern') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (groupIfPossible && restUnusedNodes.length === 1 && node.argument === restUnusedNodes[0]) {··· return [node]; } |
✗ Negative was not executed (else) | }··· return restUnusedNodes; |
Branch LogicalExpression | |
✓ Was returned | if (groupIfPossible && restUnusedNodes.length === 1 && node.argument === restUnusedNodes[0]) { |
✗ Was not returned | if (groupIfPossible && restUnusedNodes.length === 1 && node.argument === restUnusedNodes[0]) { |
Branch LogicalExpression | |
✓ Was returned | if (groupIfPossible && restUnusedNodes.length === 1 && node.argument === restUnusedNodes[0]) { |
✗ Was not returned | if (groupIfPossible && restUnusedNodes.length === 1 && node.argument === restUnusedNodes[0]) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'ArrayPattern') {··· var unusedArrayNodes = []; node.elements.forEach(function(element) { if (element) { unusedArrayNodes = unusedArrayNodes.concat(getUnusedNodes(element, variableMap, groupIfPossible)); return; } unusedArrayNodes.push(null); }); if (groupIfPossible && unusedArrayNodes.length === node.elements.length) { if (node.elements.every(function(element, index) { return unusedArrayNodes[index] === element; })) { return [node]; } } return unusedArrayNodes.filter(function(node) { return node; }); } |
✓ Negative was executed (else) | }··· if (node.type === 'ObjectPattern') { |
Function (anonymous_722) | |
---|---|
✓ Was called | node.elements.forEach(function(element) {··· if (element) { unusedArrayNodes = unusedArrayNodes.concat(getUnusedNodes(element, variableMap, groupIfPossible)); return; } unusedArrayNodes.push(null); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (element) {··· unusedArrayNodes = unusedArrayNodes.concat(getUnusedNodes(element, variableMap, groupIfPossible)); return; } |
✓ Negative was executed (else) | }··· unusedArrayNodes.push(null); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (groupIfPossible && unusedArrayNodes.length === node.elements.length) {··· if (node.elements.every(function(element, index) { return unusedArrayNodes[index] === element; })) { return [node]; } } |
✓ Negative was executed (else) | }··· return unusedArrayNodes.filter(function(node) { return node; }); |
Branch LogicalExpression | |
✓ Was returned | if (groupIfPossible && unusedArrayNodes.length === node.elements.length) { |
✓ Was returned | if (groupIfPossible && unusedArrayNodes.length === node.elements.length) { |
Function (anonymous_723) | |
---|---|
✓ Was called | if (node.elements.every(function(element, index) {··· return unusedArrayNodes[index] === element; })) { |
Branch IfStatement | |
✓ Positive was executed (if) | })) {··· return [node]; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_724) | |
---|---|
✓ Was called | return unusedArrayNodes.filter(function(node) { return node; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'ObjectPattern') {··· var unusedObjectNodes = []; node.properties.forEach(function(property) { unusedObjectNodes = unusedObjectNodes.concat(getUnusedNodes(property.value, variableMap, groupIfPossible)); }); if (groupIfPossible && unusedObjectNodes.length === node.properties.length) { if (node.properties.every(function(property, index) { return unusedObjectNodes[index] === property.value; })) { return [node]; } } return unusedObjectNodes; } |
✗ Negative was not executed (else) | }··· return []; |
Function (anonymous_725) | |
---|---|
✓ Was called | node.properties.forEach(function(property) {··· unusedObjectNodes = unusedObjectNodes.concat(getUnusedNodes(property.value, variableMap, groupIfPossible)); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (groupIfPossible && unusedObjectNodes.length === node.properties.length) {··· if (node.properties.every(function(property, index) { return unusedObjectNodes[index] === property.value; })) { return [node]; } } |
✓ Negative was executed (else) | }··· return unusedObjectNodes; |
Branch LogicalExpression | |
✓ Was returned | if (groupIfPossible && unusedObjectNodes.length === node.properties.length) { |
✓ Was returned | if (groupIfPossible && unusedObjectNodes.length === node.properties.length) { |
Function (anonymous_726) | |
---|---|
✓ Was called | if (node.properties.every(function(property, index) {··· return unusedObjectNodes[index] === property.value; })) { |
Branch IfStatement | |
✓ Positive was executed (if) | })) {··· return [node]; } |
✗ Negative was not executed (else) | }··· } |
Function isComma | |
---|---|
✓ Was called | function isComma(token) {··· return token.type === 'Punctuator' && token.value === ','; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | return token.type === 'Punctuator' && token.value === ','; |
✗ Was not returned | return token.type === 'Punctuator' && token.value === ','; |
Function removeWithCommaIfNecessary | |
---|---|
✓ Was called | function removeWithCommaIfNecessary(node, removeForwards) {··· var previousCodeToken = node.getPreviousCodeToken(); if (isComma(previousCodeToken)) { node.parentElement.removeChildren(previousCodeToken, node); return; } var nextCodeToken = node.getNextCodeToken(); if (removeForwards && isComma(nextCodeToken)) { node.parentElement.removeChildren(node, nextCodeToken); return; } var previousNode = node; while (previousNode.previousSibling.isToken && !previousNode.previousSibling.isCode) { previousNode = previousNode.previousSibling; } var nextNode = node; while (nextNode.nextSibling.isToken && !nextNode.nextSibling.isCode) { nextNode = nextNode.nextSibling; } node.parentElement.removeChild(previousNode, nextNode); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isComma(previousCodeToken)) {··· node.parentElement.removeChildren(previousCodeToken, node); return; } |
✓ Negative was executed (else) | }··· var nextCodeToken = node.getNextCodeToken(); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (removeForwards && isComma(nextCodeToken)) {··· node.parentElement.removeChildren(node, nextCodeToken); return; } |
✓ Negative was executed (else) | }··· var previousNode = node; |
Branch LogicalExpression | |
✓ Was returned | if (removeForwards && isComma(nextCodeToken)) { |
✓ Was returned | if (removeForwards && isComma(nextCodeToken)) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | while (previousNode.previousSibling.isToken && !previousNode.previousSibling.isCode) { |
✗ Was not returned | while (previousNode.previousSibling.isToken && !previousNode.previousSibling.isCode) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | while (nextNode.nextSibling.isToken && !nextNode.nextSibling.isCode) { |
✗ Was not returned | while (nextNode.nextSibling.isToken && !nextNode.nextSibling.isCode) { |
Function (anonymous_729) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_730) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_731) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowUnusedParams'; }, |
Function (anonymous_732) | |
---|---|
✓ Was called | check: function(file, errors) {··· function reportError(node) { if (node.type === 'Identifier') { errors.add('Param `' + node.name + '` is not used', node); } else { errors.add('Pattern is not used', node); } } file.iterateNodesByType( ['FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression'], function(node) { var variableMap = file.getScopes().acquire(node).getVariables() .filter(function(variable) { return variable.type === 'Parameter'; }) .reduce(function(obj, variable) { obj[variable.name] = variable; return obj; }, {}); var params = node.params; var reportUnusedDirectParams = true; for (var i = params.length - 1; i >= 0; i--) { var param = params[i]; if (!reportUnusedDirectParams && param.type === 'Identifier') { continue; } var unusedNodes = getUnusedNodes(param, variableMap, reportUnusedDirectParams); unusedNodes.forEach(reportError); if (unusedNodes.length !== 1 || unusedNodes[0] !== param) { reportUnusedDirectParams = false; } } } ); }, |
Function reportError | |
---|---|
✓ Was called | function reportError(node) {··· if (node.type === 'Identifier') { errors.add('Param `' + node.name + '` is not used', node); } else { errors.add('Pattern is not used', node); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'Identifier') {··· errors.add('Param `' + node.name + '` is not used', node); } else { |
✓ Negative was executed (else) | } else {··· errors.add('Pattern is not used', node); } |
Function (anonymous_734) | |
---|---|
✓ Was called | function(node) {··· var variableMap = file.getScopes().acquire(node).getVariables() .filter(function(variable) { return variable.type === 'Parameter'; }) .reduce(function(obj, variable) { obj[variable.name] = variable; return obj; }, {}); var params = node.params; var reportUnusedDirectParams = true; for (var i = params.length - 1; i >= 0; i--) { var param = params[i]; if (!reportUnusedDirectParams && param.type === 'Identifier') { continue; } var unusedNodes = getUnusedNodes(param, variableMap, reportUnusedDirectParams); unusedNodes.forEach(reportError); if (unusedNodes.length !== 1 || unusedNodes[0] !== param) { reportUnusedDirectParams = false; } } } |
Function (anonymous_735) | |
---|---|
✓ Was called | .filter(function(variable) {··· return variable.type === 'Parameter'; }) |
Function (anonymous_736) | |
---|---|
✓ Was called | .reduce(function(obj, variable) {··· obj[variable.name] = variable; return obj; }, {}); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!reportUnusedDirectParams && param.type === 'Identifier') {··· continue; } |
✓ Negative was executed (else) | }··· var unusedNodes = getUnusedNodes(param, variableMap, reportUnusedDirectParams); |
Branch LogicalExpression | |
✓ Was returned | if (!reportUnusedDirectParams && param.type === 'Identifier') { |
✓ Was returned | if (!reportUnusedDirectParams && param.type === 'Identifier') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (unusedNodes.length !== 1 || unusedNodes[0] !== param) {··· reportUnusedDirectParams = false; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (unusedNodes.length !== 1 || unusedNodes[0] !== param) { |
✓ Was returned | if (unusedNodes.length !== 1 || unusedNodes[0] !== param) { |
Function (anonymous_737) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var node = error.element; var parentElement = node.parentElement; if (!parentElement) { return; } if ( parentElement.type === 'FunctionExpression' || parentElement.type === 'FunctionDeclaration' || parentElement.type === 'ArrowFunctionExpression' ) { removeWithCommaIfNecessary(node, false); return; } if (parentElement.type === 'ObjectProperty') { removeWithCommaIfNecessary(parentElement, true); return; } if (parentElement.type === 'ArrayPattern') { removeWithCommaIfNecessary(node, false); if ( parentElement.elements.length > 0 && parentElement.elements.every(function(element) { return !element; }) ) { parentElement.removeChildren( parentElement.firstChild.nextSibling, parentElement.lastChild.previousSibling ); } } } |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!parentElement) {··· return; } |
✓ Negative was executed (else) | }··· if ( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· removeWithCommaIfNecessary(node, false); return; } |
✓ Negative was executed (else) | }··· if (parentElement.type === 'ObjectProperty') { |
Branch LogicalExpression | |
---|---|
✓ Was returned | parentElement.type === 'ArrowFunctionExpression' |
✓ Was returned | parentElement.type === 'FunctionExpression' ||··· parentElement.type === 'FunctionDeclaration' || |
Branch LogicalExpression | |
✓ Was returned | parentElement.type === 'FunctionDeclaration' || |
✓ Was returned | parentElement.type === 'FunctionExpression' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type === 'ObjectProperty') {··· removeWithCommaIfNecessary(parentElement, true); return; } |
✓ Negative was executed (else) | }··· if (parentElement.type === 'ArrayPattern') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type === 'ArrayPattern') {··· removeWithCommaIfNecessary(node, false); if ( parentElement.elements.length > 0 && parentElement.elements.every(function(element) { return !element; }) ) { parentElement.removeChildren( parentElement.firstChild.nextSibling, parentElement.lastChild.previousSibling ); } } |
✗ Negative was not executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· parentElement.removeChildren( parentElement.firstChild.nextSibling, parentElement.lastChild.previousSibling ); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
---|---|
✓ Was returned | parentElement.elements.every(function(element) {··· return !element; }) |
✓ Was returned | parentElement.elements.length > 0 && |
Function (anonymous_738) | |
---|---|
✓ Was called | parentElement.elements.every(function(element) {··· return !element; }) |
Function (anonymous_739) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_740) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_741) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowUnusedVariables'; }, |
Function (anonymous_742) | |
---|---|
✓ Was called | check: function(file, errors) {··· var program = file.getProgram(); var variableList = []; var nodesToCheck = []; var unusedNodes = []; function reportError(node) { errors.add('Variable `' + node.name + '` is not used', node); } function isVariableGood(variable) { var parentCheck = function(node) { if (node.parentElement) { if (node.parentElement.type === 'VariableDeclaration') { var grandparentElement = node.parentElement.parentElement; return grandparentElement.type !== 'ExportNamedDeclaration'; } else if ( node.parentElement.type === 'VariableDeclarator' || node.parentElement.type === 'ObjectProperty' || node.parentElement.isPattern ) { return parentCheck(node.parentElement); } } else { return false; } }; var useVariable = variable.getDefinitions().some(function checkVariableDefinition(definition) { return parentCheck(definition.node); }); return useVariable; } function getVariablesInAllScopes(scope) { var variableList = []; var iterateChildScopes = function(scope) { scope.getVariables().forEach(function(variable) { variableList.push(variable); }); scope.childScopes.forEach(function(childScope) { return iterateChildScopes(childScope); }); }; iterateChildScopes(scope); return variableList; } // Get all variables in all scopes. variableList = getVariablesInAllScopes(file.getScopes().acquire(program)); // Check if variables are what we want to check.. variableList.reduce(function(acc, variable) { if (isVariableGood(variable)) { acc.push(variable); } return acc; }, nodesToCheck); // Check if variables are used. nodesToCheck.reduce(function checkVariableReferences(acc, variable) { if (variable.getReferences().length === 1) { variable.getDefinitions().forEach(function addUnusedVariable(definition) { acc.push(definition.node); }); } return acc; }, unusedNodes); unusedNodes.forEach(reportError); }, |
Function reportError | |
---|---|
✓ Was called | function reportError(node) {··· errors.add('Variable `' + node.name + '` is not used', node); } |
Function isVariableGood | |
---|---|
✓ Was called | function isVariableGood(variable) {··· var parentCheck = function(node) { if (node.parentElement) { if (node.parentElement.type === 'VariableDeclaration') { var grandparentElement = node.parentElement.parentElement; return grandparentElement.type !== 'ExportNamedDeclaration'; } else if ( node.parentElement.type === 'VariableDeclarator' || node.parentElement.type === 'ObjectProperty' || node.parentElement.isPattern ) { return parentCheck(node.parentElement); } } else { return false; } }; var useVariable = variable.getDefinitions().some(function checkVariableDefinition(definition) { return parentCheck(definition.node); }); return useVariable; } |
Function (anonymous_745) | |
---|---|
✓ Was called | var parentCheck = function(node) {··· if (node.parentElement) { if (node.parentElement.type === 'VariableDeclaration') { var grandparentElement = node.parentElement.parentElement; return grandparentElement.type !== 'ExportNamedDeclaration'; } else if ( node.parentElement.type === 'VariableDeclarator' || node.parentElement.type === 'ObjectProperty' || node.parentElement.isPattern ) { return parentCheck(node.parentElement); } } else { return false; } }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.parentElement) {··· if (node.parentElement.type === 'VariableDeclaration') { var grandparentElement = node.parentElement.parentElement; return grandparentElement.type !== 'ExportNamedDeclaration'; } else if ( node.parentElement.type === 'VariableDeclarator' || node.parentElement.type === 'ObjectProperty' || node.parentElement.isPattern ) { return parentCheck(node.parentElement); } } else { |
✗ Negative was not executed (else) | } else {··· return false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.parentElement.type === 'VariableDeclaration') {··· var grandparentElement = node.parentElement.parentElement; return grandparentElement.type !== 'ExportNamedDeclaration'; } else if ( |
✓ Negative was executed (else) | } else if (··· node.parentElement.type === 'VariableDeclarator' || node.parentElement.type === 'ObjectProperty' || node.parentElement.isPattern ) { return parentCheck(node.parentElement); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return parentCheck(node.parentElement); } |
✓ Negative was executed (else) | }··· } else { |
Branch LogicalExpression | |
---|---|
✓ Was returned | node.parentElement.isPattern |
✓ Was returned | node.parentElement.type === 'VariableDeclarator' ||··· node.parentElement.type === 'ObjectProperty' || |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type === 'ObjectProperty' || |
✓ Was returned | node.parentElement.type === 'VariableDeclarator' || |
Function checkVariableDefinition | |
---|---|
✓ Was called | var useVariable = variable.getDefinitions().some(function checkVariableDefinition(definition) {··· return parentCheck(definition.node); }); |
Function getVariablesInAllScopes | |
---|---|
✓ Was called | function getVariablesInAllScopes(scope) {··· var variableList = []; var iterateChildScopes = function(scope) { scope.getVariables().forEach(function(variable) { variableList.push(variable); }); scope.childScopes.forEach(function(childScope) { return iterateChildScopes(childScope); }); }; iterateChildScopes(scope); return variableList; } |
Function (anonymous_748) | |
---|---|
✓ Was called | var iterateChildScopes = function(scope) {··· scope.getVariables().forEach(function(variable) { variableList.push(variable); }); scope.childScopes.forEach(function(childScope) { return iterateChildScopes(childScope); }); }; |
Function (anonymous_749) | |
---|---|
✓ Was called | scope.getVariables().forEach(function(variable) {··· variableList.push(variable); }); |
Function (anonymous_750) | |
---|---|
✓ Was called | scope.childScopes.forEach(function(childScope) {··· return iterateChildScopes(childScope); }); |
Function (anonymous_751) | |
---|---|
✓ Was called | variableList.reduce(function(acc, variable) {··· if (isVariableGood(variable)) { acc.push(variable); } return acc; }, nodesToCheck); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isVariableGood(variable)) {··· acc.push(variable); } |
✓ Negative was executed (else) | }··· return acc; |
Function checkVariableReferences | |
---|---|
✓ Was called | nodesToCheck.reduce(function checkVariableReferences(acc, variable) {··· if (variable.getReferences().length === 1) { variable.getDefinitions().forEach(function addUnusedVariable(definition) { acc.push(definition.node); }); } return acc; }, unusedNodes); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (variable.getReferences().length === 1) {··· variable.getDefinitions().forEach(function addUnusedVariable(definition) { acc.push(definition.node); }); } |
✓ Negative was executed (else) | }··· return acc; |
Function addUnusedVariable | |
---|---|
✓ Was called | variable.getDefinitions().forEach(function addUnusedVariable(definition) {··· acc.push(definition.node); }); |
Function (anonymous_754) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var node = error.element; while (node.type !== 'VariableDeclaration') { node = node.parentElement; } node.parentElement.removeChild(node); error.fixed = true; } |
Function (anonymous_755) | |
---|---|
✓ Was called | module.exports = function() { }; |
Function (anonymous_756) | |
---|---|
✓ Was called | configure: function(option) {··· assert(option === true, this.getOptionName() + ' requires a true value'); }, |
Function (anonymous_757) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowVar'; }, |
Function (anonymous_758) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('VariableDeclaration', function(node) { for (var i = 0; i < node.declarations.length; i++) { var thisDeclaration = node.declarations[i]; if (thisDeclaration.parentElement.kind === 'var') { errors.add('Variable declarations should use `let` or `const` not `var`', node); } } }); } |
Function (anonymous_759) | |
---|---|
✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· for (var i = 0; i < node.declarations.length; i++) { var thisDeclaration = node.declarations[i]; if (thisDeclaration.parentElement.kind === 'var') { errors.add('Variable declarations should use `let` or `const` not `var`', node); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (thisDeclaration.parentElement.kind === 'var') {··· errors.add('Variable declarations should use `let` or `const` not `var`', node); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_760) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_761) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = ['==', '===', '!=', '!==']; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = ['==', '===', '!=', '!==']; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_762) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'disallowYodaConditions'; }, |
Function (anonymous_763) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; file.iterateNodesByType('BinaryExpression', function(node) { if (operators[node.operator]) { if ( node.left.type.indexOf('Literal') > -1 || (node.left.type === 'Identifier' && node.left.name === 'undefined') ) { errors.add('Yoda condition', node.left); } } }); } |
Function (anonymous_764) | |
---|---|
✓ Was called | file.iterateNodesByType('BinaryExpression', function(node) {··· if (operators[node.operator]) { if ( node.left.type.indexOf('Literal') > -1 || (node.left.type === 'Identifier' && node.left.name === 'undefined') ) { errors.add('Yoda condition', node.left); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[node.operator]) {··· if ( node.left.type.indexOf('Literal') > -1 || (node.left.type === 'Identifier' && node.left.name === 'undefined') ) { errors.add('Yoda condition', node.left); } } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add('Yoda condition', node.left); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.left.type === 'Identifier' && node.left.name === 'undefined') |
✓ Was returned | node.left.type.indexOf('Literal') > -1 || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.left.type === 'Identifier' && node.left.name === 'undefined') |
✓ Was returned | (node.left.type === 'Identifier' && node.left.name === 'undefined') |
Function (anonymous_765) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_766) | |
---|---|
✓ Was called | configure: function(maximumLineLength) {··· this._tabSize = ''; this._allowRegex = false; this._allowComments = false; this._allowUrlComments = false; this._allowRequire = false; if (typeof maximumLineLength === 'object') { assert( typeof maximumLineLength.value === 'number', this.getOptionName() + ' option requires the "value" property to be defined' ); this._maximumLineLength = maximumLineLength.value; var tabSize = maximumLineLength.tabSize || 0; while (tabSize--) { this._tabSize += ' '; } var exceptions = maximumLineLength.allExcept || []; this._allowRegex = (exceptions.indexOf('regex') !== -1); this._allowComments = (exceptions.indexOf('comments') !== -1); this._allowUrlComments = (exceptions.indexOf('urlComments') !== -1); this._allowFunctionSignature = (exceptions.indexOf('functionSignature') !== -1); this._allowRequire = (exceptions.indexOf('require') !== -1); if (maximumLineLength.hasOwnProperty('allowRegex')) { this._allowRegex = (maximumLineLength.allowRegex === true); } if (maximumLineLength.hasOwnProperty('allowComments')) { this._allowComments = (maximumLineLength.allowComments === true); } if (maximumLineLength.hasOwnProperty('allowUrlComments')) { this._allowUrlComments = (maximumLineLength.allowUrlComments === true); } } else { assert( typeof maximumLineLength === 'number', this.getOptionName() + ' option requires number value or options object' ); this._maximumLineLength = maximumLineLength; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof maximumLineLength === 'object') {··· assert( typeof maximumLineLength.value === 'number', this.getOptionName() + ' option requires the "value" property to be defined' ); this._maximumLineLength = maximumLineLength.value; var tabSize = maximumLineLength.tabSize || 0; while (tabSize--) { this._tabSize += ' '; } var exceptions = maximumLineLength.allExcept || []; this._allowRegex = (exceptions.indexOf('regex') !== -1); this._allowComments = (exceptions.indexOf('comments') !== -1); this._allowUrlComments = (exceptions.indexOf('urlComments') !== -1); this._allowFunctionSignature = (exceptions.indexOf('functionSignature') !== -1); this._allowRequire = (exceptions.indexOf('require') !== -1); if (maximumLineLength.hasOwnProperty('allowRegex')) { this._allowRegex = (maximumLineLength.allowRegex === true); } if (maximumLineLength.hasOwnProperty('allowComments')) { this._allowComments = (maximumLineLength.allowComments === true); } if (maximumLineLength.hasOwnProperty('allowUrlComments')) { this._allowUrlComments = (maximumLineLength.allowUrlComments === true); } } else { |
✓ Negative was executed (else) | } else {··· assert( typeof maximumLineLength === 'number', this.getOptionName() + ' option requires number value or options object' ); this._maximumLineLength = maximumLineLength; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | var tabSize = maximumLineLength.tabSize || 0; |
✓ Was returned | var tabSize = maximumLineLength.tabSize || 0; |
Branch LogicalExpression | |
---|---|
✓ Was returned | var exceptions = maximumLineLength.allExcept || []; |
✓ Was returned | var exceptions = maximumLineLength.allExcept || []; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (maximumLineLength.hasOwnProperty('allowRegex')) {··· this._allowRegex = (maximumLineLength.allowRegex === true); } |
✓ Negative was executed (else) | }··· if (maximumLineLength.hasOwnProperty('allowComments')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (maximumLineLength.hasOwnProperty('allowComments')) {··· this._allowComments = (maximumLineLength.allowComments === true); } |
✓ Negative was executed (else) | }··· if (maximumLineLength.hasOwnProperty('allowUrlComments')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (maximumLineLength.hasOwnProperty('allowUrlComments')) {··· this._allowUrlComments = (maximumLineLength.allowUrlComments === true); } |
✓ Negative was executed (else) | }··· } else { |
Function (anonymous_767) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'maximumLineLength'; }, |
Function (anonymous_768) | |
---|---|
✓ Was called | check: function(file, errors) {··· var maximumLineLength = this._maximumLineLength; var line; var lines = this._allowComments ? file.getLinesWithCommentsRemoved() : file.getLines(); // This check should not be destructive lines = lines.slice(); var removeLoc = function(tokenOrNode) { // Just in case (See #2107 for example) if (!tokenOrNode) { return; } for (var i = tokenOrNode.getLoc().start.line; i <= tokenOrNode.getLoc().end.line; i++) { lines[i - 1] = ''; } }; if (this._allowRegex) { file.iterateTokensByType('RegularExpression', function(token) { removeLoc(token); }); } if (this._allowUrlComments) { file.iterateTokensByType(['CommentLine', 'CommentBlock'], function(comment) { for (var i = comment.getLoc().start.line; i <= comment.getLoc().end.line; i++) { lines[i - 1] = lines[i - 1].replace(/(http|https|ftp):\/\/[^\s$]+/, ''); } }); } if (this._allowFunctionSignature) { file.iterateNodesByType('FunctionDeclaration', function(node) { // Need to remove the first line, because we can't be sure there's any id or params lines[node.getLoc().start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); file.iterateNodesByType('ClassMethod', function(node) { removeLoc(node.key); }); file.iterateNodesByType(['ArrowFunctionExpression', 'FunctionExpression'], function(node) { // Need to remove the first line, because we can't be sure there's any id or params lines[node.getLoc().start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); } if (this._allowRequire) { file.iterateNodesByType('CallExpression', function(node) { if (node.callee.name === 'require') { removeLoc(node); } }); } for (var i = 0, l = lines.length; i < l; i++) { line = this._tabSize ? lines[i].replace(/\t/g, this._tabSize) : lines[i]; if (line.length > maximumLineLength) { errors.add( 'Line must be at most ' + maximumLineLength + ' characters', file.getLastTokenOnLine(i + 1, { includeComments: true }) ); } } } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | file.getLinesWithCommentsRemoved() : file.getLines(); |
✓ Negative was returned (: ...) | file.getLinesWithCommentsRemoved() : file.getLines(); |
Function (anonymous_769) | |
---|---|
✓ Was called | var removeLoc = function(tokenOrNode) {··· // Just in case (See #2107 for example) if (!tokenOrNode) { return; } for (var i = tokenOrNode.getLoc().start.line; i <= tokenOrNode.getLoc().end.line; i++) { lines[i - 1] = ''; } }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!tokenOrNode) {··· return; } |
✓ Negative was executed (else) | }··· for (var i = tokenOrNode.getLoc().start.line; i <= tokenOrNode.getLoc().end.line; i++) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._allowRegex) {··· file.iterateTokensByType('RegularExpression', function(token) { removeLoc(token); }); } |
✓ Negative was executed (else) | }··· if (this._allowUrlComments) { |
Function (anonymous_770) | |
---|---|
✓ Was called | file.iterateTokensByType('RegularExpression', function(token) {··· removeLoc(token); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._allowUrlComments) {··· file.iterateTokensByType(['CommentLine', 'CommentBlock'], function(comment) { for (var i = comment.getLoc().start.line; i <= comment.getLoc().end.line; i++) { lines[i - 1] = lines[i - 1].replace(/(http|https|ftp):\/\/[^\s$]+/, ''); } }); } |
✓ Negative was executed (else) | }··· if (this._allowFunctionSignature) { |
Function (anonymous_771) | |
---|---|
✓ Was called | file.iterateTokensByType(['CommentLine', 'CommentBlock'], function(comment) {··· for (var i = comment.getLoc().start.line; i <= comment.getLoc().end.line; i++) { lines[i - 1] = lines[i - 1].replace(/(http|https|ftp):\/\/[^\s$]+/, ''); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._allowFunctionSignature) {··· file.iterateNodesByType('FunctionDeclaration', function(node) { // Need to remove the first line, because we can't be sure there's any id or params lines[node.getLoc().start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); file.iterateNodesByType('ClassMethod', function(node) { removeLoc(node.key); }); file.iterateNodesByType(['ArrowFunctionExpression', 'FunctionExpression'], function(node) { // Need to remove the first line, because we can't be sure there's any id or params lines[node.getLoc().start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); } |
✓ Negative was executed (else) | }··· if (this._allowRequire) { |
Function (anonymous_772) | |
---|---|
✓ Was called | file.iterateNodesByType('FunctionDeclaration', function(node) {··· // Need to remove the first line, because we can't be sure there's any id or params lines[node.getLoc().start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); |
Function (anonymous_773) | |
---|---|
✓ Was called | file.iterateNodesByType('ClassMethod', function(node) {··· removeLoc(node.key); }); |
Function (anonymous_774) | |
---|---|
✓ Was called | file.iterateNodesByType(['ArrowFunctionExpression', 'FunctionExpression'], function(node) {··· // Need to remove the first line, because we can't be sure there's any id or params lines[node.getLoc().start.line - 1] = ''; removeLoc(node.id); node.params.forEach(removeLoc); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._allowRequire) {··· file.iterateNodesByType('CallExpression', function(node) { if (node.callee.name === 'require') { removeLoc(node); } }); } |
✓ Negative was executed (else) | }··· for (var i = 0, l = lines.length; i < l; i++) { |
Function (anonymous_775) | |
---|---|
✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· if (node.callee.name === 'require') { removeLoc(node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.callee.name === 'require') {··· removeLoc(node); } |
✗ Negative was not executed (else) | }··· }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | line = this._tabSize ? lines[i].replace(/\t/g, this._tabSize) : lines[i]; |
✓ Negative was returned (: ...) | line = this._tabSize ? lines[i].replace(/\t/g, this._tabSize) : lines[i]; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (line.length > maximumLineLength) {··· errors.add( 'Line must be at most ' + maximumLineLength + ' characters', file.getLastTokenOnLine(i + 1, { includeComments: true }) ); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_776) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_777) | |
---|---|
✓ Was called | configure: function(options) {··· this._allowComments = true; if (typeof options === 'number') { assert( typeof options === 'number', this.getOptionName() + ' option requires number value or options object' ); this._maximumNumberOfLines = options; } else { assert( typeof options.value === 'number', this.getOptionName() + ' option requires the "value" property to be defined' ); this._maximumNumberOfLines = options.value; var exceptions = options.allExcept || []; this._allowComments = (exceptions.indexOf('comments') === -1); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'number') {··· assert( typeof options === 'number', this.getOptionName() + ' option requires number value or options object' ); this._maximumNumberOfLines = options; } else { |
✓ Negative was executed (else) | } else {··· assert( typeof options.value === 'number', this.getOptionName() + ' option requires the "value" property to be defined' ); this._maximumNumberOfLines = options.value; var exceptions = options.allExcept || []; this._allowComments = (exceptions.indexOf('comments') === -1); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | var exceptions = options.allExcept || []; |
✓ Was returned | var exceptions = options.allExcept || []; |
Function (anonymous_778) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'maximumNumberOfLines'; }, |
Function (anonymous_779) | |
---|---|
✓ Was called | check: function(file, errors) {··· var firstToken = file.getFirstToken({includeComments: true}); var lines = this._allowComments ? file.getLines() : file.getLinesWithCommentsRemoved(); lines = lines.filter(function(line) {return line !== '';}); if (lines.length > this._maximumNumberOfLines) { errors.add( 'File must be at most ' + this._maximumNumberOfLines + ' lines long', firstToken, firstToken.value.length ); } } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | file.getLines() : file.getLinesWithCommentsRemoved(); |
✓ Negative was returned (: ...) | file.getLines() : file.getLinesWithCommentsRemoved(); |
Function (anonymous_780) | |
---|---|
✓ Was called | lines = lines.filter(function(line) {return line !== '';}); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lines.length > this._maximumNumberOfLines) {··· errors.add( 'File must be at most ' + this._maximumNumberOfLines + ' lines long', firstToken, firstToken.value.length ); } |
✓ Negative was executed (else) | }··· } |
Function getNodeColumn | |
---|---|
✓ Was called | function getNodeColumn(node) {··· var currentToken = node.getFirstToken().getPreviousToken(); var indentationLevel = 0; while (currentToken) { if (currentToken.getNewlineCount() > 0) { var sourceCodeLines = currentToken.getSourceCodeLines(); indentationLevel += sourceCodeLines[sourceCodeLines.length - 1].length; break; } indentationLevel += currentToken.getSourceCodeLength(); currentToken = currentToken.getPreviousToken(); } return indentationLevel; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken.getNewlineCount() > 0) {··· var sourceCodeLines = currentToken.getSourceCodeLines(); indentationLevel += sourceCodeLines[sourceCodeLines.length - 1].length; break; } |
✓ Negative was executed (else) | }··· indentationLevel += currentToken.getSourceCodeLength(); |
Function (anonymous_782) | |
---|---|
✓ Was called | module.exports = function() {··· }; |
Function (anonymous_783) | |
---|---|
✓ Was called | configure: function(option) {··· if (typeof option === 'number') { this._indentationLevel = option; } else if (typeof option === 'string') { assert( option === 'firstParam', this.getOptionName() + ' option requires string value to be "firstParam"' ); this._alignWithFirstParam = true; } else if (option === true) { this._indentationLevel = 0; } else { assert( false, this.getOptionName() + ' option requires a valid option' ); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof option === 'number') {··· this._indentationLevel = option; } else if (typeof option === 'string') { |
✓ Negative was executed (else) | } else if (typeof option === 'string') {··· assert( option === 'firstParam', this.getOptionName() + ' option requires string value to be "firstParam"' ); this._alignWithFirstParam = true; } else if (option === true) { this._indentationLevel = 0; } else { assert( false, this.getOptionName() + ' option requires a valid option' ); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (typeof option === 'string') {··· assert( option === 'firstParam', this.getOptionName() + ' option requires string value to be "firstParam"' ); this._alignWithFirstParam = true; } else if (option === true) { |
✓ Negative was executed (else) | } else if (option === true) {··· this._indentationLevel = 0; } else { assert( false, this.getOptionName() + ' option requires a valid option' ); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (option === true) {··· this._indentationLevel = 0; } else { |
✓ Negative was executed (else) | } else {··· assert( false, this.getOptionName() + ' option requires a valid option' ); } |
Function (anonymous_784) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireAlignedMultilineParams'; }, |
Function (anonymous_785) | |
---|---|
✓ Was called | check: function(file, errors) {··· var _this = this; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { var params = node.params; // We can pass the check if there's no params if (params.length === 0) { return; } var firstParam = params[0]; var referenceColumn; var body; if (_this._alignWithFirstParam) { referenceColumn = getNodeColumn(firstParam); } else { body = node.body.body[0]; // If function doesn't have a body just bail out (#1988) if (!body) { return; } referenceColumn = body.getLoc().start.column + _this._indentationLevel; } var previousParam = firstParam; params.slice(1).forEach(function(param) { if (!file.isOnTheSameLine(previousParam, param)) { var paramColumn = getNodeColumn(param); if (paramColumn !== referenceColumn) { errors.assert.indentation({ token: param.getFirstToken(), actual: paramColumn, expected: referenceColumn, indentChar: ' ' }); } previousParam = param; } }); }); } |
Function (anonymous_786) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· var params = node.params; // We can pass the check if there's no params if (params.length === 0) { return; } var firstParam = params[0]; var referenceColumn; var body; if (_this._alignWithFirstParam) { referenceColumn = getNodeColumn(firstParam); } else { body = node.body.body[0]; // If function doesn't have a body just bail out (#1988) if (!body) { return; } referenceColumn = body.getLoc().start.column + _this._indentationLevel; } var previousParam = firstParam; params.slice(1).forEach(function(param) { if (!file.isOnTheSameLine(previousParam, param)) { var paramColumn = getNodeColumn(param); if (paramColumn !== referenceColumn) { errors.assert.indentation({ token: param.getFirstToken(), actual: paramColumn, expected: referenceColumn, indentChar: ' ' }); } previousParam = param; } }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (params.length === 0) {··· return; } |
✓ Negative was executed (else) | }··· var firstParam = params[0]; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._alignWithFirstParam) {··· referenceColumn = getNodeColumn(firstParam); } else { |
✓ Negative was executed (else) | } else {··· body = node.body.body[0]; // If function doesn't have a body just bail out (#1988) if (!body) { return; } referenceColumn = body.getLoc().start.column + _this._indentationLevel; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!body) {··· return; } |
✓ Negative was executed (else) | }··· referenceColumn = body.getLoc().start.column + _this._indentationLevel; |
Function (anonymous_787) | |
---|---|
✓ Was called | params.slice(1).forEach(function(param) {··· if (!file.isOnTheSameLine(previousParam, param)) { var paramColumn = getNodeColumn(param); if (paramColumn !== referenceColumn) { errors.assert.indentation({ token: param.getFirstToken(), actual: paramColumn, expected: referenceColumn, indentChar: ' ' }); } previousParam = param; } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!file.isOnTheSameLine(previousParam, param)) {··· var paramColumn = getNodeColumn(param); if (paramColumn !== referenceColumn) { errors.assert.indentation({ token: param.getFirstToken(), actual: paramColumn, expected: referenceColumn, indentChar: ' ' }); } previousParam = param; } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (paramColumn !== referenceColumn) {··· errors.assert.indentation({ token: param.getFirstToken(), actual: paramColumn, expected: referenceColumn, indentChar: ' ' }); } |
✓ Negative was executed (else) | }··· previousParam = param; |
Function (anonymous_788) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_789) | |
---|---|
✓ Was called | configure: function(mode) {··· var modes = { 'all': 'all', 'ignoreFunction': 'ignoreFunction', 'ignoreLineBreak': 'ignoreLineBreak', 'skipWithFunction': 'ignoreFunction', 'skipWithLineBreak': 'ignoreLineBreak' }; assert( typeof mode === 'string' && modes[mode], this.getOptionName() + ' requires one of the following values: ' + Object.keys(modes).join(', ') ); this._mode = modes[mode]; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof mode === 'string' && modes[mode], |
✗ Was not returned | typeof mode === 'string' && modes[mode], |
Function (anonymous_790) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireAlignedObjectValues'; }, |
Function (anonymous_791) | |
---|---|
✓ Was called | check: function(file, errors) {··· var mode = this._mode; file.iterateNodesByType('ObjectExpression', function(node) { if (node.getNewlineCount() === 0 || node.properties < 2) { return; } var maxKeyEndPos = 0; var prevKeyEndPos = 0; var minColonPos = 0; var tokens = []; var skip = node.properties.some(function(property, index) { if (property.shorthand || property.method || property.type === 'SpreadProperty') { return true; } if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { return true; } if (mode === 'ignoreLineBreak' && index > 0 && node.properties[index - 1].getLoc().end.line !== property.getLoc().start.line - 1) { return true; } prevKeyEndPos = maxKeyEndPos; maxKeyEndPos = Math.max(maxKeyEndPos, property.key.getLoc().end.column); var keyToken = file.getFirstNodeToken(property.key); if (property.computed === true) { while (keyToken.value !== ']') { keyToken = file.getNextToken(keyToken); } } var colon = file.getNextToken(keyToken); if (prevKeyEndPos < maxKeyEndPos) { minColonPos = colon.getLoc().start.column; } tokens.push({key: keyToken, colon: colon}); }); if (skip) { return; } var space = minColonPos - maxKeyEndPos; tokens.forEach(function(pair) { errors.assert.spacesBetween({ token: pair.key, nextToken: pair.colon, exactly: maxKeyEndPos - pair.key.getLoc().end.column + space, message: 'Alignment required' }); }); }); } |
Function (anonymous_792) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· if (node.getNewlineCount() === 0 || node.properties < 2) { return; } var maxKeyEndPos = 0; var prevKeyEndPos = 0; var minColonPos = 0; var tokens = []; var skip = node.properties.some(function(property, index) { if (property.shorthand || property.method || property.type === 'SpreadProperty') { return true; } if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { return true; } if (mode === 'ignoreLineBreak' && index > 0 && node.properties[index - 1].getLoc().end.line !== property.getLoc().start.line - 1) { return true; } prevKeyEndPos = maxKeyEndPos; maxKeyEndPos = Math.max(maxKeyEndPos, property.key.getLoc().end.column); var keyToken = file.getFirstNodeToken(property.key); if (property.computed === true) { while (keyToken.value !== ']') { keyToken = file.getNextToken(keyToken); } } var colon = file.getNextToken(keyToken); if (prevKeyEndPos < maxKeyEndPos) { minColonPos = colon.getLoc().start.column; } tokens.push({key: keyToken, colon: colon}); }); if (skip) { return; } var space = minColonPos - maxKeyEndPos; tokens.forEach(function(pair) { errors.assert.spacesBetween({ token: pair.key, nextToken: pair.colon, exactly: maxKeyEndPos - pair.key.getLoc().end.column + space, message: 'Alignment required' }); }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.getNewlineCount() === 0 || node.properties < 2) {··· return; } |
✓ Negative was executed (else) | }··· var maxKeyEndPos = 0; |
Branch LogicalExpression | |
✓ Was returned | if (node.getNewlineCount() === 0 || node.properties < 2) { |
✓ Was returned | if (node.getNewlineCount() === 0 || node.properties < 2) { |
Function (anonymous_793) | |
---|---|
✓ Was called | var skip = node.properties.some(function(property, index) {··· if (property.shorthand || property.method || property.type === 'SpreadProperty') { return true; } if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { return true; } if (mode === 'ignoreLineBreak' && index > 0 && node.properties[index - 1].getLoc().end.line !== property.getLoc().start.line - 1) { return true; } prevKeyEndPos = maxKeyEndPos; maxKeyEndPos = Math.max(maxKeyEndPos, property.key.getLoc().end.column); var keyToken = file.getFirstNodeToken(property.key); if (property.computed === true) { while (keyToken.value !== ']') { keyToken = file.getNextToken(keyToken); } } var colon = file.getNextToken(keyToken); if (prevKeyEndPos < maxKeyEndPos) { minColonPos = colon.getLoc().start.column; } tokens.push({key: keyToken, colon: colon}); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | property.type === 'SpreadProperty') {··· return true; } |
✓ Negative was executed (else) | }··· if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { |
Branch LogicalExpression | |
✓ Was returned | property.type === 'SpreadProperty') { |
✓ Was returned | if (property.shorthand || property.method || |
Branch LogicalExpression | |
✓ Was returned | if (property.shorthand || property.method || |
✓ Was returned | if (property.shorthand || property.method || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') {··· return true; } |
✓ Negative was executed (else) | }··· if (mode === 'ignoreLineBreak' && index > 0 && |
Branch LogicalExpression | |
✓ Was returned | if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { |
✓ Was returned | if (mode === 'ignoreFunction' && property.value.type === 'FunctionExpression') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.properties[index - 1].getLoc().end.line !== property.getLoc().start.line - 1) {··· return true; } |
✓ Negative was executed (else) | }··· prevKeyEndPos = maxKeyEndPos; |
Branch LogicalExpression | |
✓ Was returned | node.properties[index - 1].getLoc().end.line !== property.getLoc().start.line - 1) { |
✓ Was returned | if (mode === 'ignoreLineBreak' && index > 0 && |
Branch LogicalExpression | |
✓ Was returned | if (mode === 'ignoreLineBreak' && index > 0 && |
✓ Was returned | if (mode === 'ignoreLineBreak' && index > 0 && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (property.computed === true) {··· while (keyToken.value !== ']') { keyToken = file.getNextToken(keyToken); } } |
✓ Negative was executed (else) | }··· var colon = file.getNextToken(keyToken); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevKeyEndPos < maxKeyEndPos) {··· minColonPos = colon.getLoc().start.column; } |
✓ Negative was executed (else) | }··· tokens.push({key: keyToken, colon: colon}); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (skip) {··· return; } |
✓ Negative was executed (else) | }··· var space = minColonPos - maxKeyEndPos; |
Function (anonymous_794) | |
---|---|
✓ Was called | tokens.forEach(function(pair) {··· errors.assert.spacesBetween({ token: pair.key, nextToken: pair.colon, exactly: maxKeyEndPos - pair.key.getLoc().end.column + space, message: 'Alignment required' }); }); |
Function (anonymous_795) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_796) | |
---|---|
✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); if (typeof options === 'object') { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + ' item or be set to `true`'); this._exceptDeclarations = options.allExcept.indexOf('declarations') > -1; } else { assert(options === true, this.getOptionName() + ' option requires either a true value or an object'); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'object') {··· assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + ' item or be set to `true`'); this._exceptDeclarations = options.allExcept.indexOf('declarations') > -1; } else { |
✓ Negative was executed (else) | } else {··· assert(options === true, this.getOptionName() + ' option requires either a true value or an object'); } |
Function (anonymous_797) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireAnonymousFunctions'; }, |
Function (anonymous_798) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptDeclarations = this._exceptDeclarations; file.iterateNodesByType(['FunctionExpression', 'FunctionDeclaration'], function(node) { if (exceptDeclarations && node.type === 'FunctionDeclaration') { return; } if (node.id !== null) { errors.add('Functions must not be named', node); } }); } |
Function (anonymous_799) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionExpression', 'FunctionDeclaration'], function(node) {··· if (exceptDeclarations && node.type === 'FunctionDeclaration') { return; } if (node.id !== null) { errors.add('Functions must not be named', node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptDeclarations && node.type === 'FunctionDeclaration') {··· return; } |
✓ Negative was executed (else) | }··· if (node.id !== null) { |
Branch LogicalExpression | |
✓ Was returned | if (exceptDeclarations && node.type === 'FunctionDeclaration') { |
✓ Was returned | if (exceptDeclarations && node.type === 'FunctionDeclaration') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.id !== null) {··· errors.add('Functions must not be named', node); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_800) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_801) | |
---|---|
✓ Was called | configure: function(option) {··· assert(option === true, this.getOptionName() + ' requires a true value'); }, |
Function (anonymous_802) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireArrayDestructuring'; }, |
Function (anonymous_803) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('VariableDeclaration', function(node) { node.declarations.forEach(function(declaration) { if (!declaration.init || declaration.init.type !== 'MemberExpression') { return; } var property = declaration.init.property || {}; if (property.type.indexOf('Literal') > -1 && /^\d+$/.test(property.value)) { errors.add('Use array destructuring', property); } }); }); } |
Function (anonymous_804) | |
---|---|
✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· node.declarations.forEach(function(declaration) { if (!declaration.init || declaration.init.type !== 'MemberExpression') { return; } var property = declaration.init.property || {}; if (property.type.indexOf('Literal') > -1 && /^\d+$/.test(property.value)) { errors.add('Use array destructuring', property); } }); }); |
Function (anonymous_805) | |
---|---|
✓ Was called | node.declarations.forEach(function(declaration) {··· if (!declaration.init || declaration.init.type !== 'MemberExpression') { return; } var property = declaration.init.property || {}; if (property.type.indexOf('Literal') > -1 && /^\d+$/.test(property.value)) { errors.add('Use array destructuring', property); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!declaration.init || declaration.init.type !== 'MemberExpression') {··· return; } |
✓ Negative was executed (else) | }··· var property = declaration.init.property || {}; |
Branch LogicalExpression | |
✓ Was returned | if (!declaration.init || declaration.init.type !== 'MemberExpression') { |
✗ Was not returned | if (!declaration.init || declaration.init.type !== 'MemberExpression') { |
Branch LogicalExpression | |
---|---|
✗ Was not returned | var property = declaration.init.property || {}; |
✓ Was returned | var property = declaration.init.property || {}; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (property.type.indexOf('Literal') > -1 && /^\d+$/.test(property.value)) {··· errors.add('Use array destructuring', property); } |
✗ Negative was not executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (property.type.indexOf('Literal') > -1 && /^\d+$/.test(property.value)) { |
✗ Was not returned | if (property.type.indexOf('Literal') > -1 && /^\d+$/.test(property.value)) { |
Function (anonymous_806) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_807) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_808) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireArrowFunctions'; }, |
Function (anonymous_809) | |
---|---|
✓ Was called | check: function(file, errors) {··· function isCallback(node) { return node.type === 'FunctionExpression' && node.parentElement.type === 'CallExpression'; } function isFunctionBindWithThis(node) { return node.callee && node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && node.arguments && node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; } file.iterateNodesByType(['FunctionExpression', 'CallExpression'], function(node) { if (isCallback(node) || isFunctionBindWithThis(node)) { errors.add('Use arrow functions instead of function expressions', node); } }); } |
Function isCallback | |
---|---|
✓ Was called | function isCallback(node) {··· return node.type === 'FunctionExpression' && node.parentElement.type === 'CallExpression'; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | return node.type === 'FunctionExpression' && node.parentElement.type === 'CallExpression'; |
✓ Was returned | return node.type === 'FunctionExpression' && node.parentElement.type === 'CallExpression'; |
Function isFunctionBindWithThis | |
---|---|
✓ Was called | function isFunctionBindWithThis(node) {··· return node.callee && node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && node.arguments && node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; } |
Branch LogicalExpression | |
---|---|
✗ Was not returned | node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; |
✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && node.arguments && node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; |
Branch LogicalExpression | |
✗ Was not returned | node.arguments.length === 1 && node.arguments[0].type === 'ThisExpression'; |
✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && node.arguments && |
Branch LogicalExpression | |
✗ Was not returned | node.arguments && |
✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'bind' && |
Branch LogicalExpression | |
✗ Was not returned | node.callee.property.name === 'bind' && |
✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && node.callee.property.type === 'Identifier' && |
Branch LogicalExpression | |
✗ Was not returned | node.callee.property.type === 'Identifier' && |
✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && node.callee.object.type === 'FunctionExpression' && |
Branch LogicalExpression | |
✓ Was returned | node.callee.object.type === 'FunctionExpression' && |
✓ Was returned | return node.callee &&··· node.callee.type === 'MemberExpression' && |
Branch LogicalExpression | |
✓ Was returned | node.callee.type === 'MemberExpression' && |
✓ Was returned | return node.callee && |
Function (anonymous_812) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionExpression', 'CallExpression'], function(node) {··· if (isCallback(node) || isFunctionBindWithThis(node)) { errors.add('Use arrow functions instead of function expressions', node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isCallback(node) || isFunctionBindWithThis(node)) {··· errors.add('Use arrow functions instead of function expressions', node); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (isCallback(node) || isFunctionBindWithThis(node)) { |
✓ Was returned | if (isCallback(node) || isFunctionBindWithThis(node)) { |
Function hasCommentInBlock | |
---|---|
✓ Was called | function hasCommentInBlock(block) {··· for (var i = 0; i < block.childElements.length; i++) { if (block.childElements[i].isComment) { return true; } } return false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (block.childElements[i].isComment) {··· return true; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_814) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_815) | |
---|---|
✓ Was called | configure: function(options) {··· var optionType = typeof options; assert( options === true || optionType === 'number' || optionType === 'object', this.getOptionName() + ' option requires the value true, an Integer or an object' ); this._minLines = 0; this._includeComments = false; if (optionType === 'number') { this._minLines = options; } else if (optionType === 'object') { assert( options.includeComments === true, this.getOptionName() + ' option requires includeComments property to be true for object' ); this._includeComments = options.includeComments; if (options.hasOwnProperty('minLines')) { assert( typeof options.minLines === 'number', this.getOptionName() + ' option requires minLines property to be an integer for object' ); this._minLines = options.minLines; } } assert( this._minLines >= 0, this.getOptionName() + ' option requires minimum statements setting to be >= 0' ); }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || optionType === 'number' || optionType === 'object', |
✓ Was returned | options === true || optionType === 'number' || optionType === 'object', |
Branch LogicalExpression | |
✓ Was returned | options === true || optionType === 'number' || optionType === 'object', |
✓ Was returned | options === true || optionType === 'number' || optionType === 'object', |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (optionType === 'number') {··· this._minLines = options; } else if (optionType === 'object') { |
✓ Negative was executed (else) | } else if (optionType === 'object') {··· assert( options.includeComments === true, this.getOptionName() + ' option requires includeComments property to be true for object' ); this._includeComments = options.includeComments; if (options.hasOwnProperty('minLines')) { assert( typeof options.minLines === 'number', this.getOptionName() + ' option requires minLines property to be an integer for object' ); this._minLines = options.minLines; } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (optionType === 'object') {··· assert( options.includeComments === true, this.getOptionName() + ' option requires includeComments property to be true for object' ); this._includeComments = options.includeComments; if (options.hasOwnProperty('minLines')) { assert( typeof options.minLines === 'number', this.getOptionName() + ' option requires minLines property to be an integer for object' ); this._minLines = options.minLines; } } |
✓ Negative was executed (else) | }··· assert( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.hasOwnProperty('minLines')) {··· assert( typeof options.minLines === 'number', this.getOptionName() + ' option requires minLines property to be an integer for object' ); this._minLines = options.minLines; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_816) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireBlocksOnNewline'; }, |
Function (anonymous_817) | |
---|---|
✓ Was called | check: function(file, errors) {··· var minLines = this._minLines; var includeComments = this._includeComments; file.iterateNodesByType('BlockStatement', function(node) { var hasComment = false; if (includeComments === true) { hasComment = hasCommentInBlock(node); } if (hasComment === false && node.body.length <= minLines) { return; } var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket, { includeComments: includeComments }); errors.assert.differentLine({ token: openingBracket, nextToken: nextToken, message: 'Missing newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket, { includeComments: includeComments }); errors.assert.differentLine({ token: prevToken, nextToken: closingBracket, message: 'Missing newline before closing curly brace' }); }); } |
Function (anonymous_818) | |
---|---|
✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var hasComment = false; if (includeComments === true) { hasComment = hasCommentInBlock(node); } if (hasComment === false && node.body.length <= minLines) { return; } var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket, { includeComments: includeComments }); errors.assert.differentLine({ token: openingBracket, nextToken: nextToken, message: 'Missing newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket, { includeComments: includeComments }); errors.assert.differentLine({ token: prevToken, nextToken: closingBracket, message: 'Missing newline before closing curly brace' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (includeComments === true) {··· hasComment = hasCommentInBlock(node); } |
✓ Negative was executed (else) | }··· if (hasComment === false && node.body.length <= minLines) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (hasComment === false && node.body.length <= minLines) {··· return; } |
✓ Negative was executed (else) | }··· var openingBracket = node.getFirstToken(); |
Branch LogicalExpression | |
✓ Was returned | if (hasComment === false && node.body.length <= minLines) { |
✓ Was returned | if (hasComment === false && node.body.length <= minLines) { |
Function processArrayOfStringOrRegExp | |
---|---|
✓ Was called | function processArrayOfStringOrRegExp(iv) {··· if (!Array.isArray(iv)) { return; } var rv = []; var i = 0; while (rv && (i < iv.length)) { var elt = iv[i]; if (typeof elt === 'string') { // string values OK rv.push(elt); } else if (elt instanceof RegExp) { // existing RegExp OK rv.push(elt); } else if (elt && (typeof elt === 'object')) { try { // ESTree RegExpLiteral ok if it produces RegExp rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); } catch (e) { // Not a valid RegExpLiteral rv = null; } } else { // Unknown value rv = null; } ++i; } return rv; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!Array.isArray(iv)) {··· return; } |
✓ Negative was executed (else) | }··· var rv = []; |
Branch LogicalExpression | |
---|---|
✓ Was returned | while (rv && (i < iv.length)) { |
✓ Was returned | while (rv && (i < iv.length)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof elt === 'string') {··· // string values OK rv.push(elt); } else if (elt instanceof RegExp) { |
✓ Negative was executed (else) | } else if (elt instanceof RegExp) {··· // existing RegExp OK rv.push(elt); } else if (elt && (typeof elt === 'object')) { try { // ESTree RegExpLiteral ok if it produces RegExp rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); } catch (e) { // Not a valid RegExpLiteral rv = null; } } else { // Unknown value rv = null; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (elt instanceof RegExp) {··· // existing RegExp OK rv.push(elt); } else if (elt && (typeof elt === 'object')) { |
✓ Negative was executed (else) | } else if (elt && (typeof elt === 'object')) {··· try { // ESTree RegExpLiteral ok if it produces RegExp rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); } catch (e) { // Not a valid RegExpLiteral rv = null; } } else { // Unknown value rv = null; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (elt && (typeof elt === 'object')) {··· try { // ESTree RegExpLiteral ok if it produces RegExp rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); } catch (e) { // Not a valid RegExpLiteral rv = null; } } else { |
✓ Negative was executed (else) | } else {··· // Unknown value rv = null; } |
Branch LogicalExpression | |
✓ Was returned | } else if (elt && (typeof elt === 'object')) { |
✓ Was returned | } else if (elt && (typeof elt === 'object')) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); |
✓ Was returned | rv.push(new RegExp(elt.regex.pattern, elt.regex.flags || '')); |
Function startAfterStringPrefix | |
---|---|
✓ Was called | function startAfterStringPrefix(value, prefix) {··· var start = prefix.length; if (start >= value.length) { return; } if (value.substr(0, prefix.length) !== prefix) { return; } return start; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (start >= value.length) {··· return; } |
✓ Negative was executed (else) | }··· if (value.substr(0, prefix.length) !== prefix) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value.substr(0, prefix.length) !== prefix) {··· return; } |
✓ Negative was executed (else) | }··· return start; |
Function startAfterRegExpPrefix | |
---|---|
✓ Was called | function startAfterRegExpPrefix(value, prefix) {··· var match = prefix.exec(value); if (!match) { return; } if (match.index !== 0) { return; } return match[0].length; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!match) {··· return; } |
✓ Negative was executed (else) | }··· if (match.index !== 0) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (match.index !== 0) {··· return; } |
✓ Negative was executed (else) | }··· return match[0].length; |
Function endBeforeStringSuffix | |
---|---|
✓ Was called | function endBeforeStringSuffix(value, suffix) {··· var ends = value.length - suffix.length; if (ends <= 0) { return; } if (value.substr(ends) !== suffix) { return; } return ends; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (ends <= 0) {··· return; } |
✓ Negative was executed (else) | }··· if (value.substr(ends) !== suffix) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value.substr(ends) !== suffix) {··· return; } |
✓ Negative was executed (else) | }··· return ends; |
Function endBeforeRegExpSuffix | |
---|---|
✓ Was called | function endBeforeRegExpSuffix(value, suffix) {··· var match = suffix.exec(value); if (!match) { return; } var ends = match.index; if ((ends + match[0].length) !== value.length) { return; } return ends; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!match) {··· return; } |
✓ Negative was executed (else) | }··· var ends = match.index; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ((ends + match[0].length) !== value.length) {··· return; } |
✓ Negative was executed (else) | }··· return ends; |
Function matchException | |
---|---|
✓ Was called | function matchException(value, exception) {··· if (typeof exception === 'string') { return (exception === value); } return exception.test(value); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof exception === 'string') {··· return (exception === value); } |
✓ Negative was executed (else) | }··· return exception.test(value); |
Function (anonymous_825) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_826) | |
---|---|
✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true || options === 'ignoreProperties', this.getOptionName() + ' option requires a true value or `ignoreProperties`' ); var _options = { ignoreProperties: options === 'ignoreProperties' ? true : false, strict: false }; return this.configure(_options); } assert( !options.hasOwnProperty('ignoreProperties') || typeof options.ignoreProperties === 'boolean', this.getOptionName() + ' option should have boolean value for ignoreProperties' ); this._ignoreProperties = options.ignoreProperties; assert( !options.hasOwnProperty('strict') || typeof options.strict === 'boolean', this.getOptionName() + ' option should have boolean value for strict' ); this._strict = options.strict; var asre = processArrayOfStringOrRegExp(options.allowedPrefixes); assert( !options.hasOwnProperty('allowedPrefixes') || asre, this.getOptionName() + ' option should have array of string or RegExp for allowedPrefixes' ); if (asre) { this._allowedPrefixes = asre; } asre = processArrayOfStringOrRegExp(options.allowedSuffixes); assert( !options.hasOwnProperty('allowedSuffixes') || asre, this.getOptionName() + ' option should have array of string or RegExp for allowedSuffixes' ); if (asre) { this._allowedSuffixes = asre; } asre = processArrayOfStringOrRegExp(options.allExcept); assert( !options.hasOwnProperty('allExcept') || asre, this.getOptionName() + ' option should have array of string or RegExp for allExcept' ); if (asre) { this._allExcept = asre; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true || options === 'ignoreProperties', this.getOptionName() + ' option requires a true value or `ignoreProperties`' ); var _options = { ignoreProperties: options === 'ignoreProperties' ? true : false, strict: false }; return this.configure(_options); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || options === 'ignoreProperties', |
✓ Was returned | options === true || options === 'ignoreProperties', |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | ignoreProperties: options === 'ignoreProperties' ? true : false, |
✓ Negative was returned (: ...) | ignoreProperties: options === 'ignoreProperties' ? true : false, |
Branch LogicalExpression | |
---|---|
✓ Was returned | !options.hasOwnProperty('ignoreProperties') || typeof options.ignoreProperties === 'boolean', |
✓ Was returned | !options.hasOwnProperty('ignoreProperties') || typeof options.ignoreProperties === 'boolean', |
Branch LogicalExpression | |
---|---|
✓ Was returned | !options.hasOwnProperty('strict') || typeof options.strict === 'boolean', |
✓ Was returned | !options.hasOwnProperty('strict') || typeof options.strict === 'boolean', |
Branch LogicalExpression | |
---|---|
✓ Was returned | !options.hasOwnProperty('allowedPrefixes') || asre, |
✓ Was returned | !options.hasOwnProperty('allowedPrefixes') || asre, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (asre) {··· this._allowedPrefixes = asre; } |
✓ Negative was executed (else) | }··· asre = processArrayOfStringOrRegExp(options.allowedSuffixes); |
Branch LogicalExpression | |
---|---|
✓ Was returned | !options.hasOwnProperty('allowedSuffixes') || asre, |
✓ Was returned | !options.hasOwnProperty('allowedSuffixes') || asre, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (asre) {··· this._allowedSuffixes = asre; } |
✓ Negative was executed (else) | }··· asre = processArrayOfStringOrRegExp(options.allExcept); |
Branch LogicalExpression | |
---|---|
✓ Was returned | !options.hasOwnProperty('allExcept') || asre, |
✓ Was returned | !options.hasOwnProperty('allExcept') || asre, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (asre) {··· this._allExcept = asre; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_827) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireCamelCaseOrUpperCaseIdentifiers'; }, |
Function (anonymous_828) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByType('Identifier', function(token) { var value = token.value; // Leading and trailing underscores signify visibility/scope and do not affect // validation of the rule. Remove them to simplify the checks. var isPrivate = (value[0] === '_'); value = value.replace(/^_+|_+$/g, ''); // Detect exceptions before stripping prefixes/suffixes. if (this._allExcept) { for (i = 0, len = this._allExcept.length; i < len; ++i) { if (matchException(value, this._allExcept[i])) { return; } } } // Strip at most one prefix permitted text from the identifier. This transformation // cannot change an acceptable identifier into an unacceptable identifier so we can // continue with the normal verification of whatever it produces. var i; var len; if (this._allowedPrefixes) { for (i = 0, len = this._allowedPrefixes.length; i < len; ++i) { var prefix = this._allowedPrefixes[i]; var start; if (typeof prefix === 'string') { start = startAfterStringPrefix(value, prefix); } else { start = startAfterRegExpPrefix(value, prefix); } if (start !== undefined) { value = value.substr(start); break; } } } // As with prefix but for one suffix permitted text. if (this._allowedSuffixes) { for (i = 0, len = this._allowedSuffixes.length; i < len; ++i) { var suffix = this._allowedSuffixes[i]; var ends; if (typeof suffix === 'string') { ends = endBeforeStringSuffix(value, suffix); } else { ends = endBeforeRegExpSuffix(value, suffix); } if (ends !== undefined) { value = value.substr(0, ends); break; } } } if (value.indexOf('_') === -1 || value.toUpperCase() === value) { if (!this._strict) {return;} if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { return; } } if (this._ignoreProperties) { var nextToken = file.getNextToken(token); var prevToken = token.getPreviousCodeToken(); if (nextToken && nextToken.value === ':') { return; } /* This enables an identifier to be snake cased via the object * destructuring pattern. We must check to see if the identifier * is being used to set values into an object to determine if * this is a legal assignment. * Example: ({camelCase: snake_case}) => camelCase.length */ if (prevToken && prevToken.value === ':') { var node = token.parentElement; var parentElement = node.parentElement; if (parentElement && parentElement.type === 'ObjectProperty') { var grandpa = parentElement.parentElement; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } } if (prevToken && (prevToken.value === '.' || prevToken.value === 'get' || prevToken.value === 'set')) { return; } } errors.add( 'All identifiers must be camelCase or UPPER_CASE', token ); }.bind(this)); } |
Function (anonymous_829) | |
---|---|
✓ Was called | file.iterateTokensByType('Identifier', function(token) {··· var value = token.value; // Leading and trailing underscores signify visibility/scope and do not affect // validation of the rule. Remove them to simplify the checks. var isPrivate = (value[0] === '_'); value = value.replace(/^_+|_+$/g, ''); // Detect exceptions before stripping prefixes/suffixes. if (this._allExcept) { for (i = 0, len = this._allExcept.length; i < len; ++i) { if (matchException(value, this._allExcept[i])) { return; } } } // Strip at most one prefix permitted text from the identifier. This transformation // cannot change an acceptable identifier into an unacceptable identifier so we can // continue with the normal verification of whatever it produces. var i; var len; if (this._allowedPrefixes) { for (i = 0, len = this._allowedPrefixes.length; i < len; ++i) { var prefix = this._allowedPrefixes[i]; var start; if (typeof prefix === 'string') { start = startAfterStringPrefix(value, prefix); } else { start = startAfterRegExpPrefix(value, prefix); } if (start !== undefined) { value = value.substr(start); break; } } } // As with prefix but for one suffix permitted text. if (this._allowedSuffixes) { for (i = 0, len = this._allowedSuffixes.length; i < len; ++i) { var suffix = this._allowedSuffixes[i]; var ends; if (typeof suffix === 'string') { ends = endBeforeStringSuffix(value, suffix); } else { ends = endBeforeRegExpSuffix(value, suffix); } if (ends !== undefined) { value = value.substr(0, ends); break; } } } if (value.indexOf('_') === -1 || value.toUpperCase() === value) { if (!this._strict) {return;} if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { return; } } if (this._ignoreProperties) { var nextToken = file.getNextToken(token); var prevToken = token.getPreviousCodeToken(); if (nextToken && nextToken.value === ':') { return; } /* This enables an identifier to be snake cased via the object * destructuring pattern. We must check to see if the identifier * is being used to set values into an object to determine if * this is a legal assignment. * Example: ({camelCase: snake_case}) => camelCase.length */ if (prevToken && prevToken.value === ':') { var node = token.parentElement; var parentElement = node.parentElement; if (parentElement && parentElement.type === 'ObjectProperty') { var grandpa = parentElement.parentElement; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } } if (prevToken && (prevToken.value === '.' || prevToken.value === 'get' || prevToken.value === 'set')) { return; } } errors.add( 'All identifiers must be camelCase or UPPER_CASE', token ); }.bind(this)); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._allExcept) {··· for (i = 0, len = this._allExcept.length; i < len; ++i) { if (matchException(value, this._allExcept[i])) { return; } } } |
✓ Negative was executed (else) | }··· // Strip at most one prefix permitted text from the identifier. This transformation |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (matchException(value, this._allExcept[i])) {··· return; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._allowedPrefixes) {··· for (i = 0, len = this._allowedPrefixes.length; i < len; ++i) { var prefix = this._allowedPrefixes[i]; var start; if (typeof prefix === 'string') { start = startAfterStringPrefix(value, prefix); } else { start = startAfterRegExpPrefix(value, prefix); } if (start !== undefined) { value = value.substr(start); break; } } } |
✓ Negative was executed (else) | }··· // As with prefix but for one suffix permitted text. |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof prefix === 'string') {··· start = startAfterStringPrefix(value, prefix); } else { |
✓ Negative was executed (else) | } else {··· start = startAfterRegExpPrefix(value, prefix); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (start !== undefined) {··· value = value.substr(start); break; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._allowedSuffixes) {··· for (i = 0, len = this._allowedSuffixes.length; i < len; ++i) { var suffix = this._allowedSuffixes[i]; var ends; if (typeof suffix === 'string') { ends = endBeforeStringSuffix(value, suffix); } else { ends = endBeforeRegExpSuffix(value, suffix); } if (ends !== undefined) { value = value.substr(0, ends); break; } } } |
✓ Negative was executed (else) | }··· if (value.indexOf('_') === -1 || value.toUpperCase() === value) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof suffix === 'string') {··· ends = endBeforeStringSuffix(value, suffix); } else { |
✓ Negative was executed (else) | } else {··· ends = endBeforeRegExpSuffix(value, suffix); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (ends !== undefined) {··· value = value.substr(0, ends); break; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value.indexOf('_') === -1 || value.toUpperCase() === value) {··· if (!this._strict) {return;} if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { return; } } |
✓ Negative was executed (else) | }··· if (this._ignoreProperties) { |
Branch LogicalExpression | |
✓ Was returned | if (value.indexOf('_') === -1 || value.toUpperCase() === value) { |
✓ Was returned | if (value.indexOf('_') === -1 || value.toUpperCase() === value) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._strict) {return;} |
✓ Negative was executed (else) | if (!this._strict) {return;}··· if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) {··· return; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
✓ Was returned | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
Branch LogicalExpression | |
✓ Was returned | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
✓ Was returned | if (value.length === 0 || value[0].toUpperCase() !== value[0] || isPrivate) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._ignoreProperties) {··· var nextToken = file.getNextToken(token); var prevToken = token.getPreviousCodeToken(); if (nextToken && nextToken.value === ':') { return; } /* This enables an identifier to be snake cased via the object * destructuring pattern. We must check to see if the identifier * is being used to set values into an object to determine if * this is a legal assignment. * Example: ({camelCase: snake_case}) => camelCase.length */ if (prevToken && prevToken.value === ':') { var node = token.parentElement; var parentElement = node.parentElement; if (parentElement && parentElement.type === 'ObjectProperty') { var grandpa = parentElement.parentElement; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } } if (prevToken && (prevToken.value === '.' || prevToken.value === 'get' || prevToken.value === 'set')) { return; } } |
✓ Negative was executed (else) | }··· errors.add( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken && nextToken.value === ':') {··· return; } |
✓ Negative was executed (else) | }··· /* This enables an identifier to be snake cased via the object |
Branch LogicalExpression | |
✓ Was returned | if (nextToken && nextToken.value === ':') { |
✗ Was not returned | if (nextToken && nextToken.value === ':') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken && prevToken.value === ':') {··· var node = token.parentElement; var parentElement = node.parentElement; if (parentElement && parentElement.type === 'ObjectProperty') { var grandpa = parentElement.parentElement; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } } |
✓ Negative was executed (else) | }··· if (prevToken && (prevToken.value === '.' || |
Branch LogicalExpression | |
✓ Was returned | if (prevToken && prevToken.value === ':') { |
✓ Was returned | if (prevToken && prevToken.value === ':') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement && parentElement.type === 'ObjectProperty') {··· var grandpa = parentElement.parentElement; if (grandpa && grandpa.type === 'ObjectPattern') { return; } } |
✗ Negative was not executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (parentElement && parentElement.type === 'ObjectProperty') { |
✗ Was not returned | if (parentElement && parentElement.type === 'ObjectProperty') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (grandpa && grandpa.type === 'ObjectPattern') {··· return; } |
✗ Negative was not executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (grandpa && grandpa.type === 'ObjectPattern') { |
✗ Was not returned | if (grandpa && grandpa.type === 'ObjectPattern') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | prevToken.value === 'get' || prevToken.value === 'set')) {··· return; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (prevToken && (prevToken.value === '.' ||··· prevToken.value === 'get' || prevToken.value === 'set')) { |
✓ Was returned | if (prevToken && (prevToken.value === '.' || |
Branch LogicalExpression | |
✓ Was returned | prevToken.value === 'get' || prevToken.value === 'set')) { |
✓ Was returned | if (prevToken && (prevToken.value === '.' ||··· prevToken.value === 'get' || prevToken.value === 'set')) { |
Branch LogicalExpression | |
✓ Was returned | prevToken.value === 'get' || prevToken.value === 'set')) { |
✓ Was returned | if (prevToken && (prevToken.value === '.' || |
Function (anonymous_830) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_831) | |
---|---|
✓ Was called | configure: function(options) {··· var exceptions; this.inlined = false; this._isPragma = null; var optionName = this.getOptionName(); var isObject = typeof options === 'object'; var error = optionName + ' option requires a true value ' + 'or an object with String[] `allExcept` property or true with `inlined`'; assert( options === true || isObject, error ); if (isObject && options.allExcept) { exceptions = options.allExcept; // verify items in `allExcept` property in object are string values assert( Array.isArray(exceptions) && exceptions.every(function(el) { return typeof el === 'string'; }), 'Property `allExcept` in ' + optionName + ' should be an array of strings' ); this._isPragma = isPragma(exceptions); } if (!this._isPragma) { this._isPragma = isPragma(); } if (isObject && options.inlined) { this.inlined = true; } if (isObject && !options.allExcept && !options.inlined) { assert(false, error); } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | isObject, |
✓ Was returned | options === true || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject && options.allExcept) {··· exceptions = options.allExcept; // verify items in `allExcept` property in object are string values assert( Array.isArray(exceptions) && exceptions.every(function(el) { return typeof el === 'string'; }), 'Property `allExcept` in ' + optionName + ' should be an array of strings' ); this._isPragma = isPragma(exceptions); } |
✓ Negative was executed (else) | }··· if (!this._isPragma) { |
Branch LogicalExpression | |
✓ Was returned | if (isObject && options.allExcept) { |
✓ Was returned | if (isObject && options.allExcept) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | exceptions.every(function(el) { return typeof el === 'string'; }), |
✗ Was not returned | Array.isArray(exceptions) && |
Function (anonymous_832) | |
---|---|
✓ Was called | exceptions.every(function(el) { return typeof el === 'string'; }), |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._isPragma) {··· this._isPragma = isPragma(); } |
✓ Negative was executed (else) | }··· if (isObject && options.inlined) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject && options.inlined) {··· this.inlined = true; } |
✓ Negative was executed (else) | }··· if (isObject && !options.allExcept && !options.inlined) { |
Branch LogicalExpression | |
✓ Was returned | if (isObject && options.inlined) { |
✓ Was returned | if (isObject && options.inlined) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject && !options.allExcept && !options.inlined) {··· assert(false, error); } |
✓ Negative was executed (else) | }··· }, |
Branch LogicalExpression | |
✓ Was returned | if (isObject && !options.allExcept && !options.inlined) { |
✓ Was returned | if (isObject && !options.allExcept && !options.inlined) { |
Branch LogicalExpression | |
✓ Was returned | if (isObject && !options.allExcept && !options.inlined) { |
✓ Was returned | if (isObject && !options.allExcept && !options.inlined) { |
Function (anonymous_833) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireCapitalizedComments'; }, |
Function (anonymous_834) | |
---|---|
✓ Was called | _isUrl: function(comment) {··· var protocolParts = comment.value.split('://'); if (protocolParts.length === 1) { return false; } return comment.value.indexOf(protocolParts[0]) === 0; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (protocolParts.length === 1) {··· return false; } |
✓ Negative was executed (else) | }··· return comment.value.indexOf(protocolParts[0]) === 0; |
Function (anonymous_835) | |
---|---|
✓ Was called | _isException: function(comment) {··· return this._isPragma(comment.value); }, |
Function (anonymous_836) | |
---|---|
✓ Was called | _isValid: function(comment) {··· var first = this._getFirstChar(comment); return first && upperCasePattern.test(first); }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | return first && upperCasePattern.test(first); |
✗ Was not returned | return first && upperCasePattern.test(first); |
Function (anonymous_837) | |
---|---|
✓ Was called | _isLetter: function(comment) {··· var first = this._getFirstChar(comment); return first && letterPattern.test(first); }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | return first && letterPattern.test(first); |
✓ Was returned | return first && letterPattern.test(first); |
Function (anonymous_838) | |
---|---|
✓ Was called | _getFirstChar: function(comment) {··· return comment.value.replace(/[\n\s\*]/g, '')[0]; }, |
Function (anonymous_839) | |
---|---|
✓ Was called | _isTextBlock: function(file, comment) {··· var prevComment = file.getPrevToken(comment, {includeComments: true}); if (prevComment) { return prevComment.type === 'CommentLine' && !file.isOnTheSameLine(comment, prevComment) && prevComment.value.trim().length > 0; } return false; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevComment) {··· return prevComment.type === 'CommentLine' && !file.isOnTheSameLine(comment, prevComment) && prevComment.value.trim().length > 0; } |
✓ Negative was executed (else) | }··· return false; |
Branch LogicalExpression | |
---|---|
✓ Was returned | prevComment.value.trim().length > 0; |
✓ Was returned | return prevComment.type === 'CommentLine' &&··· !file.isOnTheSameLine(comment, prevComment) && |
Branch LogicalExpression | |
✓ Was returned | !file.isOnTheSameLine(comment, prevComment) && |
✓ Was returned | return prevComment.type === 'CommentLine' && |
Function (anonymous_840) | |
---|---|
✓ Was called | _shouldIgnoreIfInTheMiddle: function(file, comment) {··· if (!this.inlined) { return false; } var firstToken = comment.getFirstToken(); var otherToken = firstToken.getPreviousNonWhitespaceToken(); return otherToken ? file.isOnTheSameLine(otherToken, firstToken) : false; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this.inlined) {··· return false; } |
✓ Negative was executed (else) | }··· var firstToken = comment.getFirstToken(); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return otherToken ? file.isOnTheSameLine(otherToken, firstToken) : false; |
✓ Negative was returned (: ...) | return otherToken ? file.isOnTheSameLine(otherToken, firstToken) : false; |
Function (anonymous_841) | |
---|---|
✓ Was called | check: function(file, errors) {··· var _this = this; function add(comment) { errors.cast({ message: 'Comments must start with an uppercase letter, unless it is part of a textblock', element: comment, additional: comment }); } file.iterateTokensByType('CommentLine', function(comment) { if (_this._isException(comment)) { return; } if (_this._isUrl(comment)) { return; } if (!_this._isLetter(comment)) { return; } if (_this._isTextBlock(file, comment)) { return; } if (_this._isValid(comment)) { return; } add(comment); }); file.iterateTokensByType('CommentBlock', function(comment) { if (_this._isException(comment)) { return; } if (_this._isUrl(comment)) { return; } if (!_this._isLetter(comment)) { return; } if (_this._shouldIgnoreIfInTheMiddle(file, comment)) { return; } if (_this._isValid(comment)) { return; } add(comment); }); }, |
Function add | |
---|---|
✓ Was called | function add(comment) {··· errors.cast({ message: 'Comments must start with an uppercase letter, unless it is part of a textblock', element: comment, additional: comment }); } |
Function (anonymous_843) | |
---|---|
✓ Was called | file.iterateTokensByType('CommentLine', function(comment) {··· if (_this._isException(comment)) { return; } if (_this._isUrl(comment)) { return; } if (!_this._isLetter(comment)) { return; } if (_this._isTextBlock(file, comment)) { return; } if (_this._isValid(comment)) { return; } add(comment); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._isException(comment)) {··· return; } |
✓ Negative was executed (else) | }··· if (_this._isUrl(comment)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._isUrl(comment)) {··· return; } |
✓ Negative was executed (else) | }··· if (!_this._isLetter(comment)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!_this._isLetter(comment)) {··· return; } |
✓ Negative was executed (else) | }··· if (_this._isTextBlock(file, comment)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._isTextBlock(file, comment)) {··· return; } |
✓ Negative was executed (else) | }··· if (_this._isValid(comment)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._isValid(comment)) {··· return; } |
✓ Negative was executed (else) | }··· add(comment); |
Function (anonymous_844) | |
---|---|
✓ Was called | file.iterateTokensByType('CommentBlock', function(comment) {··· if (_this._isException(comment)) { return; } if (_this._isUrl(comment)) { return; } if (!_this._isLetter(comment)) { return; } if (_this._shouldIgnoreIfInTheMiddle(file, comment)) { return; } if (_this._isValid(comment)) { return; } add(comment); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._isException(comment)) {··· return; } |
✓ Negative was executed (else) | }··· if (_this._isUrl(comment)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._isUrl(comment)) {··· return; } |
✓ Negative was executed (else) | }··· if (!_this._isLetter(comment)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!_this._isLetter(comment)) {··· return; } |
✓ Negative was executed (else) | }··· if (_this._shouldIgnoreIfInTheMiddle(file, comment)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._shouldIgnoreIfInTheMiddle(file, comment)) {··· return; } |
✓ Negative was executed (else) | }··· if (_this._isValid(comment)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._isValid(comment)) {··· return; } |
✓ Negative was executed (else) | }··· add(comment); |
Function (anonymous_845) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var comment = error.additional; var first = this._getFirstChar(comment); var newValue = comment.value.replace(first, first.toUpperCase()); var newComment = new cst.Token(comment.type, newValue); comment.parentElement.replaceChild(newComment, comment); } |
Function (anonymous_846) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_847) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || Array.isArray(options.allExcept), this.getOptionName() + ' option requires a true value or an object of exceptions' ); this._allowedConstructors = {}; var allExcept = options.allExcept; if (allExcept) { for (var i = 0, l = allExcept.length; i < l; i++) { this._allowedConstructors[allExcept[i]] = true; } } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || Array.isArray(options.allExcept), |
✓ Was returned | options === true || Array.isArray(options.allExcept), |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (allExcept) {··· for (var i = 0, l = allExcept.length; i < l; i++) { this._allowedConstructors[allExcept[i]] = true; } } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_848) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireCapitalizedConstructorsNew'; }, |
Function (anonymous_849) | |
---|---|
✓ Was called | check: function(file, errors) {··· var allowedConstructors = this._allowedConstructors; file.iterateNodesByType('CallExpression', function(node) { if (node.callee.type === 'Identifier' && !allowedConstructors[node.callee.name] && node.callee.name[0].toLowerCase() !== node.callee.name[0] ) { errors.add( 'Constructor functions should use the "new" keyword', node.callee ); } }); } |
Function (anonymous_850) | |
---|---|
✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· if (node.callee.type === 'Identifier' && !allowedConstructors[node.callee.name] && node.callee.name[0].toLowerCase() !== node.callee.name[0] ) { errors.add( 'Constructor functions should use the "new" keyword', node.callee ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add( 'Constructor functions should use the "new" keyword', node.callee ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | node.callee.name[0].toLowerCase() !== node.callee.name[0] |
✓ Was returned | if (node.callee.type === 'Identifier' &&··· !allowedConstructors[node.callee.name] && |
Branch LogicalExpression | |
✓ Was returned | !allowedConstructors[node.callee.name] && |
✓ Was returned | if (node.callee.type === 'Identifier' && |
Function (anonymous_851) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_852) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || Array.isArray(options.allExcept), this.getOptionName() + ' option requires a true value or an object of exceptions' ); this._allowedConstructors = {}; var allExcept = options.allExcept; if (allExcept) { for (var i = 0, l = allExcept.length; i < l; i++) { this._allowedConstructors[allExcept[i]] = true; } } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || Array.isArray(options.allExcept), |
✓ Was returned | options === true || Array.isArray(options.allExcept), |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (allExcept) {··· for (var i = 0, l = allExcept.length; i < l; i++) { this._allowedConstructors[allExcept[i]] = true; } } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_853) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireCapitalizedConstructors'; }, |
Function (anonymous_854) | |
---|---|
✓ Was called | check: function(file, errors) {··· var allowedConstructors = this._allowedConstructors; file.iterateNodesByType('NewExpression', function(node) { if (node.callee.type === 'Identifier' && !allowedConstructors[node.callee.name] && node.callee.name[0].toUpperCase() !== node.callee.name[0] ) { errors.add( 'Constructor functions should be capitalized', node.callee ); } }); } |
Function (anonymous_855) | |
---|---|
✓ Was called | file.iterateNodesByType('NewExpression', function(node) {··· if (node.callee.type === 'Identifier' && !allowedConstructors[node.callee.name] && node.callee.name[0].toUpperCase() !== node.callee.name[0] ) { errors.add( 'Constructor functions should be capitalized', node.callee ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add( 'Constructor functions should be capitalized', node.callee ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | node.callee.name[0].toUpperCase() !== node.callee.name[0] |
✓ Was returned | if (node.callee.type === 'Identifier' &&··· !allowedConstructors[node.callee.name] && |
Branch LogicalExpression | |
✓ Was returned | !allowedConstructors[node.callee.name] && |
✓ Was returned | if (node.callee.type === 'Identifier' && |
Function (anonymous_856) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_857) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_858) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireCommaBeforeLineBreak'; }, |
Function (anonymous_859) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var prevToken = token.getPreviousCodeToken(); if (prevToken.value === ',') { return; } errors.assert.sameLine({ token: prevToken, nextToken: token, message: 'Commas should not be placed on new line' }); }); } |
Function (anonymous_860) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var prevToken = token.getPreviousCodeToken(); if (prevToken.value === ',') { return; } errors.assert.sameLine({ token: prevToken, nextToken: token, message: 'Commas should not be placed on new line' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.value === ',') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.sameLine({ |
Function (anonymous_861) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_862) | |
---|---|
✓ Was called | configure: function(options) {··· assert( Array.isArray(options) || options === true || typeof options === 'object', this.getOptionName() + ' option requires array, true value, or object' ); var keywordMap = { 'return': 'ReturnStatement', 'break': 'BreakStatement', 'continue': 'ContinueStatement' }; if (options === true) { options = defaultKeywords; } if (!Array.isArray(options)) { assert( Array.isArray(options.allExcept), this.getOptionName() + '.allExcept ' + 'property requires an array value' ); assert( Array.isArray(options.keywords) || options.keywords === true, this.getOptionName() + '.keywords ' + 'property requires an array value or a value of true' ); if (options.keywords === true) { options.keywords = defaultKeywords; } this._exceptions = options.allExcept.map(function(statementType) { return keywordMap[statementType]; }); options = options.keywords; } this._typeIndex = {}; for (var i = 0, l = options.length; i < l; i++) { this._typeIndex[options[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(options) || options === true || typeof options === 'object', |
✓ Was returned | Array.isArray(options) || options === true || typeof options === 'object', |
Branch LogicalExpression | |
✓ Was returned | Array.isArray(options) || options === true || typeof options === 'object', |
✓ Was returned | Array.isArray(options) || options === true || typeof options === 'object', |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options === true) {··· options = defaultKeywords; } |
✓ Negative was executed (else) | }··· if (!Array.isArray(options)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!Array.isArray(options)) {··· assert( Array.isArray(options.allExcept), this.getOptionName() + '.allExcept ' + 'property requires an array value' ); assert( Array.isArray(options.keywords) || options.keywords === true, this.getOptionName() + '.keywords ' + 'property requires an array value or a value of true' ); if (options.keywords === true) { options.keywords = defaultKeywords; } this._exceptions = options.allExcept.map(function(statementType) { return keywordMap[statementType]; }); options = options.keywords; } |
✓ Negative was executed (else) | }··· this._typeIndex = {}; |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(options.keywords) || options.keywords === true, |
✓ Was returned | Array.isArray(options.keywords) || options.keywords === true, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.keywords === true) {··· options.keywords = defaultKeywords; } |
✓ Negative was executed (else) | }··· this._exceptions = options.allExcept.map(function(statementType) { |
Function (anonymous_863) | |
---|---|
✓ Was called | this._exceptions = options.allExcept.map(function(statementType) {··· return keywordMap[statementType]; }); |
Function (anonymous_864) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireCurlyBraces'; }, |
Function (anonymous_865) | |
---|---|
✓ Was called | check: function(file, errors) {··· var typeIndex = this._typeIndex; var exceptions = this._exceptions; function isNotABlockStatement(node) { return node && node.type !== 'BlockStatement'; } function addError(typeString, entity) { errors.add( typeString + ' statement without curly braces', entity ); } function checkBody(type, typeString) { file.iterateNodesByType(type, function(node) { if (isNotABlockStatement(node.body)) { addError(typeString, node); } }); } if (typeIndex.if || typeIndex.else) { file.iterateNodesByType('IfStatement', function(node) { if (typeIndex.if && isNotABlockStatement(node.consequent) && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { // console.log(node.firstChild.getSourceCode()); addError('If', node.firstChild); } if (typeIndex.else && isNotABlockStatement(node.alternate) && node.alternate.type !== 'IfStatement' && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { addError('Else', node.alternate.getPreviousCodeToken()); } }); } if (typeIndex.case || typeIndex.default) { file.iterateNodesByType('SwitchCase', function(node) { // empty case statement if (node.consequent.length === 0) { return; } if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { return; } if (node.test === null && typeIndex.default) { addError('Default', node); } if (node.test !== null && typeIndex.case) { addError('Case', node); } }); } if (typeIndex.while) { checkBody('WhileStatement', 'While'); } if (typeIndex.for) { checkBody('ForStatement', 'For'); checkBody('ForInStatement', 'For in'); checkBody('ForOfStatement', 'For of'); } if (typeIndex.do) { checkBody('DoWhileStatement', 'Do while'); } if (typeIndex.with) { checkBody('WithStatement', 'With'); } } |
Function isNotABlockStatement | |
---|---|
✓ Was called | function isNotABlockStatement(node) {··· return node && node.type !== 'BlockStatement'; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | return node && node.type !== 'BlockStatement'; |
✓ Was returned | return node && node.type !== 'BlockStatement'; |
Function addError | |
---|---|
✓ Was called | function addError(typeString, entity) {··· errors.add( typeString + ' statement without curly braces', entity ); } |
Function checkBody | |
---|---|
✓ Was called | function checkBody(type, typeString) {··· file.iterateNodesByType(type, function(node) { if (isNotABlockStatement(node.body)) { addError(typeString, node); } }); } |
Function (anonymous_869) | |
---|---|
✓ Was called | file.iterateNodesByType(type, function(node) {··· if (isNotABlockStatement(node.body)) { addError(typeString, node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isNotABlockStatement(node.body)) {··· addError(typeString, node); } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.if || typeIndex.else) {··· file.iterateNodesByType('IfStatement', function(node) { if (typeIndex.if && isNotABlockStatement(node.consequent) && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { // console.log(node.firstChild.getSourceCode()); addError('If', node.firstChild); } if (typeIndex.else && isNotABlockStatement(node.alternate) && node.alternate.type !== 'IfStatement' && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { addError('Else', node.alternate.getPreviousCodeToken()); } }); } |
✓ Negative was executed (else) | }··· if (typeIndex.case || typeIndex.default) { |
Branch LogicalExpression | |
✓ Was returned | if (typeIndex.if || typeIndex.else) { |
✓ Was returned | if (typeIndex.if || typeIndex.else) { |
Function (anonymous_870) | |
---|---|
✓ Was called | file.iterateNodesByType('IfStatement', function(node) {··· if (typeIndex.if && isNotABlockStatement(node.consequent) && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { // console.log(node.firstChild.getSourceCode()); addError('If', node.firstChild); } if (typeIndex.else && isNotABlockStatement(node.alternate) && node.alternate.type !== 'IfStatement' && // check exceptions for if and else !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { addError('Else', node.alternate.getPreviousCodeToken()); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) {··· // console.log(node.firstChild.getSourceCode()); addError('If', node.firstChild); } |
✓ Negative was executed (else) | }··· if (typeIndex.else && isNotABlockStatement(node.alternate) && |
Branch LogicalExpression | |
✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
✓ Was returned | if (typeIndex.if && isNotABlockStatement(node.consequent) && |
Branch LogicalExpression | |
✓ Was returned | if (typeIndex.if && isNotABlockStatement(node.consequent) && |
✓ Was returned | if (typeIndex.if && isNotABlockStatement(node.consequent) && |
Branch LogicalExpression | |
---|---|
✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) {··· addError('Else', node.alternate.getPreviousCodeToken()); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
✓ Was returned | if (typeIndex.else && isNotABlockStatement(node.alternate) &&··· node.alternate.type !== 'IfStatement' && |
Branch LogicalExpression | |
✓ Was returned | node.alternate.type !== 'IfStatement' && |
✓ Was returned | if (typeIndex.else && isNotABlockStatement(node.alternate) && |
Branch LogicalExpression | |
✓ Was returned | if (typeIndex.else && isNotABlockStatement(node.alternate) && |
✓ Was returned | if (typeIndex.else && isNotABlockStatement(node.alternate) && |
Branch LogicalExpression | |
---|---|
✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
✓ Was returned | !(exceptions && exceptions.indexOf(node.consequent.type) !== -1)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.case || typeIndex.default) {··· file.iterateNodesByType('SwitchCase', function(node) { // empty case statement if (node.consequent.length === 0) { return; } if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { return; } if (node.test === null && typeIndex.default) { addError('Default', node); } if (node.test !== null && typeIndex.case) { addError('Case', node); } }); } |
✓ Negative was executed (else) | }··· if (typeIndex.while) { |
Branch LogicalExpression | |
✓ Was returned | if (typeIndex.case || typeIndex.default) { |
✓ Was returned | if (typeIndex.case || typeIndex.default) { |
Function (anonymous_871) | |
---|---|
✓ Was called | file.iterateNodesByType('SwitchCase', function(node) {··· // empty case statement if (node.consequent.length === 0) { return; } if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { return; } if (node.test === null && typeIndex.default) { addError('Default', node); } if (node.test !== null && typeIndex.case) { addError('Case', node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.consequent.length === 0) {··· return; } |
✓ Negative was executed (else) | }··· if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') {··· return; } |
✓ Negative was executed (else) | }··· if (node.test === null && typeIndex.default) { |
Branch LogicalExpression | |
✓ Was returned | if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { |
✓ Was returned | if (node.consequent.length === 1 && node.consequent[0].type === 'BlockStatement') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.test === null && typeIndex.default) {··· addError('Default', node); } |
✓ Negative was executed (else) | }··· if (node.test !== null && typeIndex.case) { |
Branch LogicalExpression | |
✓ Was returned | if (node.test === null && typeIndex.default) { |
✓ Was returned | if (node.test === null && typeIndex.default) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.test !== null && typeIndex.case) {··· addError('Case', node); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (node.test !== null && typeIndex.case) { |
✓ Was returned | if (node.test !== null && typeIndex.case) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.while) {··· checkBody('WhileStatement', 'While'); } |
✓ Negative was executed (else) | }··· if (typeIndex.for) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.for) {··· checkBody('ForStatement', 'For'); checkBody('ForInStatement', 'For in'); checkBody('ForOfStatement', 'For of'); } |
✓ Negative was executed (else) | }··· if (typeIndex.do) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.do) {··· checkBody('DoWhileStatement', 'Do while'); } |
✓ Negative was executed (else) | }··· if (typeIndex.with) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeIndex.with) {··· checkBody('WithStatement', 'With'); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_872) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_873) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || options === 'ignoreProperties', this.getOptionName() + ' option requires true or "ignoreProperties" value, or should be removed' ); this._ignoreProperties = (options === 'ignoreProperties'); }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || options === 'ignoreProperties', |
✓ Was returned | options === true || options === 'ignoreProperties', |
Function (anonymous_874) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireDollarBeforejQueryAssignment'; }, |
Function (anonymous_875) | |
---|---|
✓ Was called | check: function(file, errors) {··· var ignoreProperties = this._ignoreProperties; file.iterateNodesByType(['VariableDeclarator', 'AssignmentExpression', 'ObjectExpression'], function(node) { var type = node.type; var left; var varName; var right; function checkIfVarNameShouldStartWithDollar(varName, left, right) { if (/^_?\$/.test(varName)) { return; } if (!right || right.type !== 'CallExpression') { return; } var nextToken = right.callee.firstChild; if (nextToken.value !== '$') { return; } nextToken = file.getNextToken(nextToken); if (nextToken.value !== '(') { return; } while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { nextToken = file.getNextToken(nextToken); } nextToken = file.getNextToken(nextToken); if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { errors.add( 'jQuery identifiers must start with a $', left ); } } if (type === 'VariableDeclarator') { if (node.id.type === 'ObjectPattern' || node.id.type === 'ArrayPattern') { return; } left = node.id; varName = left.name; right = node.init; checkIfVarNameShouldStartWithDollar(varName, left, right); } else if (ignoreProperties) { return; } else if (type === 'AssignmentExpression') { left = node.left; if (left.computed || left.type === 'ArrayPattern') { return; } varName = left.name || left.property.name; right = node.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' var props = node.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left || !left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } }); } |
Function (anonymous_876) | |
---|---|
✓ Was called | file.iterateNodesByType(['VariableDeclarator', 'AssignmentExpression', 'ObjectExpression'], function(node) {··· var type = node.type; var left; var varName; var right; function checkIfVarNameShouldStartWithDollar(varName, left, right) { if (/^_?\$/.test(varName)) { return; } if (!right || right.type !== 'CallExpression') { return; } var nextToken = right.callee.firstChild; if (nextToken.value !== '$') { return; } nextToken = file.getNextToken(nextToken); if (nextToken.value !== '(') { return; } while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { nextToken = file.getNextToken(nextToken); } nextToken = file.getNextToken(nextToken); if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { errors.add( 'jQuery identifiers must start with a $', left ); } } if (type === 'VariableDeclarator') { if (node.id.type === 'ObjectPattern' || node.id.type === 'ArrayPattern') { return; } left = node.id; varName = left.name; right = node.init; checkIfVarNameShouldStartWithDollar(varName, left, right); } else if (ignoreProperties) { return; } else if (type === 'AssignmentExpression') { left = node.left; if (left.computed || left.type === 'ArrayPattern') { return; } varName = left.name || left.property.name; right = node.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' var props = node.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left || !left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } }); |
Function checkIfVarNameShouldStartWithDollar | |
---|---|
✓ Was called | function checkIfVarNameShouldStartWithDollar(varName, left, right) {··· if (/^_?\$/.test(varName)) { return; } if (!right || right.type !== 'CallExpression') { return; } var nextToken = right.callee.firstChild; if (nextToken.value !== '$') { return; } nextToken = file.getNextToken(nextToken); if (nextToken.value !== '(') { return; } while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { nextToken = file.getNextToken(nextToken); } nextToken = file.getNextToken(nextToken); if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { errors.add( 'jQuery identifiers must start with a $', left ); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (/^_?\$/.test(varName)) {··· return; } |
✓ Negative was executed (else) | }··· if (!right || right.type !== 'CallExpression') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!right || right.type !== 'CallExpression') {··· return; } |
✓ Negative was executed (else) | }··· var nextToken = right.callee.firstChild; |
Branch LogicalExpression | |
✓ Was returned | if (!right || right.type !== 'CallExpression') { |
✓ Was returned | if (!right || right.type !== 'CallExpression') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.value !== '$') {··· return; } |
✓ Negative was executed (else) | }··· nextToken = file.getNextToken(nextToken); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (nextToken.value !== '(') {··· return; } |
✓ Negative was executed (else) | }··· while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { |
✓ Was returned | while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) {··· errors.add( 'jQuery identifiers must start with a $', left ); } |
✗ Negative was not executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { |
✗ Was not returned | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { |
Branch LogicalExpression | |
✓ Was returned | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { |
✓ Was returned | if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (type === 'VariableDeclarator') {··· if (node.id.type === 'ObjectPattern' || node.id.type === 'ArrayPattern') { return; } left = node.id; varName = left.name; right = node.init; checkIfVarNameShouldStartWithDollar(varName, left, right); } else if (ignoreProperties) { |
✓ Negative was executed (else) | } else if (ignoreProperties) {··· return; } else if (type === 'AssignmentExpression') { left = node.left; if (left.computed || left.type === 'ArrayPattern') { return; } varName = left.name || left.property.name; right = node.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' var props = node.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left || !left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.id.type === 'ObjectPattern' || node.id.type === 'ArrayPattern') {··· return; } |
✓ Negative was executed (else) | }··· left = node.id; |
Branch LogicalExpression | |
✓ Was returned | if (node.id.type === 'ObjectPattern' || node.id.type === 'ArrayPattern') { |
✓ Was returned | if (node.id.type === 'ObjectPattern' || node.id.type === 'ArrayPattern') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (ignoreProperties) {··· return; } else if (type === 'AssignmentExpression') { |
✓ Negative was executed (else) | } else if (type === 'AssignmentExpression') {··· left = node.left; if (left.computed || left.type === 'ArrayPattern') { return; } varName = left.name || left.property.name; right = node.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' var props = node.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left || !left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (type === 'AssignmentExpression') {··· left = node.left; if (left.computed || left.type === 'ArrayPattern') { return; } varName = left.name || left.property.name; right = node.right; checkIfVarNameShouldStartWithDollar(varName, left, right); } else {// type === 'ObjectExpression' |
✓ Negative was executed (else) | } else {// type === 'ObjectExpression'··· var props = node.properties; if (!props) { return; } props.forEach(function(prop) { left = prop.key; if (!left || !left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (left.computed || left.type === 'ArrayPattern') {··· return; } |
✓ Negative was executed (else) | }··· varName = left.name || left.property.name; |
Branch LogicalExpression | |
✓ Was returned | if (left.computed || left.type === 'ArrayPattern') { |
✓ Was returned | if (left.computed || left.type === 'ArrayPattern') { |
Branch LogicalExpression | |
---|---|
✓ Was returned | varName = left.name || left.property.name; |
✓ Was returned | varName = left.name || left.property.name; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!props) {··· return; } |
✓ Negative was executed (else) | }··· props.forEach(function(prop) { |
Function (anonymous_878) | |
---|---|
✓ Was called | props.forEach(function(prop) {··· left = prop.key; if (!left || !left.name) { return; } varName = left.name; right = prop.value; checkIfVarNameShouldStartWithDollar(varName, left, right); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!left || !left.name) {··· return; } |
✓ Negative was executed (else) | }··· varName = left.name; |
Branch LogicalExpression | |
✓ Was returned | if (!left || !left.name) { |
✓ Was returned | if (!left || !left.name) { |
Function (anonymous_879) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_880) | |
---|---|
✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true || options === 'except_snake_case', this.getOptionName() + ' option requires either a true value or an object' ); var _options = {}; if (options === 'except_snake_case') { _options.allExcept = ['snake_case']; } return this.configure(_options); } assert( !options.allExcept || Array.isArray(options.allExcept), 'allExcept value of ' + this.getOptionName() + ' option requires an array with exceptions' ); if (Array.isArray(options.allExcept)) { this._exceptSnakeCase = options.allExcept.indexOf('snake_case') > -1; this._exceptKeywords = options.allExcept.indexOf('keywords') > -1; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true || options === 'except_snake_case', this.getOptionName() + ' option requires either a true value or an object' ); var _options = {}; if (options === 'except_snake_case') { _options.allExcept = ['snake_case']; } return this.configure(_options); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || options === 'except_snake_case', |
✓ Was returned | options === true || options === 'except_snake_case', |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options === 'except_snake_case') {··· _options.allExcept = ['snake_case']; } |
✓ Negative was executed (else) | }··· return this.configure(_options); |
Branch LogicalExpression | |
---|---|
✓ Was returned | !options.allExcept || Array.isArray(options.allExcept), |
✓ Was returned | !options.allExcept || Array.isArray(options.allExcept), |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptSnakeCase = options.allExcept.indexOf('snake_case') > -1; this._exceptKeywords = options.allExcept.indexOf('keywords') > -1; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_881) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireDotNotation'; }, |
Function (anonymous_882) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptSnakeCase = this._exceptSnakeCase; var exceptKeywords = this._exceptKeywords; var dialect = file.getDialect(); file.iterateNodesByType('MemberExpression', function(node) { if (!node.computed || node.property.type !== 'StringLiteral') { return; } var value = node.property.value; if (// allow numbers, nulls, and anything else typeof value !== 'string' || // allow invalid identifiers !utils.isValidIdentifierName(value, file.getDialect()) || // allow quoted snake cased identifiers if allExcept: ['snake_case'] (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || // allow quoted reserved words if allExcept: ['keywords'] ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) ) { return; } errors.add('Use dot notation instead of brackets for member expressions', node.property); }); } |
Function (anonymous_883) | |
---|---|
✓ Was called | file.iterateNodesByType('MemberExpression', function(node) {··· if (!node.computed || node.property.type !== 'StringLiteral') { return; } var value = node.property.value; if (// allow numbers, nulls, and anything else typeof value !== 'string' || // allow invalid identifiers !utils.isValidIdentifierName(value, file.getDialect()) || // allow quoted snake cased identifiers if allExcept: ['snake_case'] (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || // allow quoted reserved words if allExcept: ['keywords'] ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) ) { return; } errors.add('Use dot notation instead of brackets for member expressions', node.property); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!node.computed || node.property.type !== 'StringLiteral') {··· return; } |
✓ Negative was executed (else) | }··· var value = node.property.value; |
Branch LogicalExpression | |
✓ Was returned | if (!node.computed || node.property.type !== 'StringLiteral') { |
✓ Was returned | if (!node.computed || node.property.type !== 'StringLiteral') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· errors.add('Use dot notation instead of brackets for member expressions', node.property); |
Branch LogicalExpression | |
---|---|
✓ Was returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
✓ Was returned | typeof value !== 'string' ||··· // allow invalid identifiers !utils.isValidIdentifierName(value, file.getDialect()) || // allow quoted snake cased identifiers if allExcept: ['snake_case'] (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || |
Branch LogicalExpression | |
✓ Was returned | (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || |
✓ Was returned | typeof value !== 'string' ||··· // allow invalid identifiers !utils.isValidIdentifierName(value, file.getDialect()) || |
Branch LogicalExpression | |
✓ Was returned | !utils.isValidIdentifierName(value, file.getDialect()) || |
✗ Was not returned | typeof value !== 'string' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || |
✓ Was returned | (exceptSnakeCase && utils.isSnakeCased(utils.trimUnderscores(value))) || |
Branch LogicalExpression | |
---|---|
✗ Was not returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
✓ Was returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
Branch LogicalExpression | |
✓ Was returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
✗ Was not returned | ((dialect === 'es3' || exceptKeywords) && reservedWords.check(value, dialect, true)) |
Function (anonymous_884) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_885) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option allow only the `true` value' ); }, |
Function (anonymous_886) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireEarlyReturn'; }, |
Function (anonymous_887) | |
---|---|
✓ Was called | check: function(file, errors) {··· function addError(entity) { errors.add( 'Use of else after return', entity ); } // Check if the IfStatement node contain a ReturnStatement. // If the node has a block, check all the statements in backward order to see if there is one. // This is to ensure that code like this will still return true: // // if (true) { // return; // eval(); // } function hasNodeReturn(node) { if (node.type === 'BlockStatement') { for (var i = node.body.length - 1; i >= 0; i--) { if (node.body[i].type === 'ReturnStatement') { return true; } } return false; } return node.type === 'ReturnStatement'; } file.iterateNodesByType('IfStatement', function(node) { if (!node.alternate) { return; } // Check if all the parents have a return statement, if not continue to the following IfStatement node. // // Example: // // if (foo) { // return; // } else if (bar) { <-- error // bar(); // } else if (baz) { <-- safe // return baz(); // } else { <-- safe // bas(); // } for (var nodeIf = node; nodeIf && nodeIf.type === 'IfStatement'; nodeIf = nodeIf.parentElement) { if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) { return; } } return addError(file.getPrevToken(file.getFirstNodeToken(node.alternate))); }); } |
Function addError | |
---|---|
✓ Was called | function addError(entity) {··· errors.add( 'Use of else after return', entity ); } |
Function hasNodeReturn | |
---|---|
✓ Was called | function hasNodeReturn(node) {··· if (node.type === 'BlockStatement') { for (var i = node.body.length - 1; i >= 0; i--) { if (node.body[i].type === 'ReturnStatement') { return true; } } return false; } return node.type === 'ReturnStatement'; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'BlockStatement') {··· for (var i = node.body.length - 1; i >= 0; i--) { if (node.body[i].type === 'ReturnStatement') { return true; } } return false; } |
✓ Negative was executed (else) | }··· return node.type === 'ReturnStatement'; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.body[i].type === 'ReturnStatement') {··· return true; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_890) | |
---|---|
✓ Was called | file.iterateNodesByType('IfStatement', function(node) {··· if (!node.alternate) { return; } // Check if all the parents have a return statement, if not continue to the following IfStatement node. // // Example: // // if (foo) { // return; // } else if (bar) { <-- error // bar(); // } else if (baz) { <-- safe // return baz(); // } else { <-- safe // bas(); // } for (var nodeIf = node; nodeIf && nodeIf.type === 'IfStatement'; nodeIf = nodeIf.parentElement) { if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) { return; } } return addError(file.getPrevToken(file.getFirstNodeToken(node.alternate))); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!node.alternate) {··· return; } |
✓ Negative was executed (else) | }··· // Check if all the parents have a return statement, if not continue to the following IfStatement node. |
Branch LogicalExpression | |
---|---|
✓ Was returned | for (var nodeIf = node; nodeIf && nodeIf.type === 'IfStatement'; nodeIf = nodeIf.parentElement) { |
✗ Was not returned | for (var nodeIf = node; nodeIf && nodeIf.type === 'IfStatement'; nodeIf = nodeIf.parentElement) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) {··· return; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) { |
✓ Was returned | if (nodeIf.alternate && !hasNodeReturn(nodeIf.consequent)) { |
Function (anonymous_891) | |
---|---|
✓ Was called | var parse = function(code) {··· var program = new Parser().parse('({' + code + '})'); return program.body[0].expression.properties[0]; }; |
Function (anonymous_892) | |
---|---|
✓ Was called | module.exports = function() { }; |
Function (anonymous_893) | |
---|---|
✓ Was called | configure: function(option) {··· assert(option === true, this.getOptionName() + ' requires a true value'); }, |
Function (anonymous_894) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireEnhancedObjectLiterals'; }, |
Function (anonymous_895) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectProperty', function(node) { // node.key.name is used when the property key is an unquoted identifier // node.key.value is used when the property key is a quoted string var propertyName = node.key.name || node.key.value; var valueName = node.value.name; var shorthand = node.shorthand; var computed = node.computed; // check for non-shorthand properties if (propertyName && propertyName === valueName && !(shorthand || computed)) { errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ propName: propName }` is not allowed.', node ); } // check for non-method function properties var valueType = node.value.type; var valueIsMethod = node.method; if (valueType === 'FunctionExpression' && !valueIsMethod) { errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ funcName: function() {} }` is not allowed.', node ); } }); }, |
Function (anonymous_896) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectProperty', function(node) {··· // node.key.name is used when the property key is an unquoted identifier // node.key.value is used when the property key is a quoted string var propertyName = node.key.name || node.key.value; var valueName = node.value.name; var shorthand = node.shorthand; var computed = node.computed; // check for non-shorthand properties if (propertyName && propertyName === valueName && !(shorthand || computed)) { errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ propName: propName }` is not allowed.', node ); } // check for non-method function properties var valueType = node.value.type; var valueIsMethod = node.method; if (valueType === 'FunctionExpression' && !valueIsMethod) { errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ funcName: function() {} }` is not allowed.', node ); } }); |
Branch LogicalExpression | |
---|---|
✗ Was not returned | var propertyName = node.key.name || node.key.value; |
✓ Was returned | var propertyName = node.key.name || node.key.value; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (propertyName && propertyName === valueName && !(shorthand || computed)) {··· errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ propName: propName }` is not allowed.', node ); } |
✓ Negative was executed (else) | }··· // check for non-method function properties |
Branch LogicalExpression | |
✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
Branch LogicalExpression | |
✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
✗ Was not returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
Branch LogicalExpression | |
✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
✓ Was returned | if (propertyName && propertyName === valueName && !(shorthand || computed)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (valueType === 'FunctionExpression' && !valueIsMethod) {··· errors.add( 'Property assignment should use enhanced object literal function.\n' + ' `{ funcName: function() {} }` is not allowed.', node ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (valueType === 'FunctionExpression' && !valueIsMethod) { |
✓ Was returned | if (valueType === 'FunctionExpression' && !valueIsMethod) { |
Function (anonymous_897) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var elem = error.element; // Can't fix it yet if (elem.value.type === 'FunctionExpression') { return; } var element = parse(elem.key.name); element.remove(); elem.parentElement.replaceChild(element, elem); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (elem.value.type === 'FunctionExpression') {··· return; } |
✓ Negative was executed (else) | }··· var element = parse(elem.key.name); |
Function (anonymous_898) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_899) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_900) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireFunctionDeclarations'; }, |
Function (anonymous_901) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType( 'VariableDeclarator', function(node) { if (node.init && node.init.type === 'FunctionExpression') { errors.add('Use a function declaration instead', node); } } ); file.iterateNodesByType( 'AssignmentExpression', function(node) { if (node.left.type !== 'MemberExpression' && node.right.type === 'FunctionExpression') { errors.add('Use a function declaration instead', node); } } ); } |
Function (anonymous_902) | |
---|---|
✓ Was called | function(node) {··· if (node.init && node.init.type === 'FunctionExpression') { errors.add('Use a function declaration instead', node); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.init && node.init.type === 'FunctionExpression') {··· errors.add('Use a function declaration instead', node); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (node.init && node.init.type === 'FunctionExpression') { |
✓ Was returned | if (node.init && node.init.type === 'FunctionExpression') { |
Function (anonymous_903) | |
---|---|
✓ Was called | function(node) {··· if (node.left.type !== 'MemberExpression' && node.right.type === 'FunctionExpression') { errors.add('Use a function declaration instead', node); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.right.type === 'FunctionExpression') {··· errors.add('Use a function declaration instead', node); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | node.right.type === 'FunctionExpression') { |
✓ Was returned | if (node.left.type !== 'MemberExpression' && |
Function (anonymous_904) | |
---|---|
✓ Was called | module.exports = function() {··· }; |
Function (anonymous_905) | |
---|---|
✓ Was called | configure: function(option) {··· assert( option === true, this.getOptionName() + ' option requires true value' ); }, |
Function (anonymous_906) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireImportAlphabetized'; }, |
Function (anonymous_907) | |
---|---|
✓ Was called | check: function(file, errors) {··· var previous; var current; var createSpecHash = function(specifier) { var imported = ''; var local = ''; if (specifier.imported && specifier.imported.name) { imported = specifier.imported.name; } if (specifier.local && specifier.local.name) { local = specifier.local.name; } return imported === local ? imported : imported + local; }; file.iterateNodesByType( 'ImportDeclaration', function(node) { current = ''; for (var i = 0; i < node.specifiers.length; i++) { current += createSpecHash(node.specifiers[i]); } if (node.source && node.source.value) { current += node.source.value; } if (previous && previous > current) { errors.add('imports must be alphabetized', node); } previous = current; } ); } |
Function (anonymous_908) | |
---|---|
✓ Was called | var createSpecHash = function(specifier) {··· var imported = ''; var local = ''; if (specifier.imported && specifier.imported.name) { imported = specifier.imported.name; } if (specifier.local && specifier.local.name) { local = specifier.local.name; } return imported === local ? imported : imported + local; }; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (specifier.imported && specifier.imported.name) {··· imported = specifier.imported.name; } |
✓ Negative was executed (else) | }··· if (specifier.local && specifier.local.name) { |
Branch LogicalExpression | |
✓ Was returned | if (specifier.imported && specifier.imported.name) { |
✓ Was returned | if (specifier.imported && specifier.imported.name) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (specifier.local && specifier.local.name) {··· local = specifier.local.name; } |
✗ Negative was not executed (else) | }··· return imported === local ? imported : imported + local; |
Branch LogicalExpression | |
✓ Was returned | if (specifier.local && specifier.local.name) { |
✗ Was not returned | if (specifier.local && specifier.local.name) { |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return imported === local ? imported : imported + local; |
✓ Negative was returned (: ...) | return imported === local ? imported : imported + local; |
Function (anonymous_909) | |
---|---|
✓ Was called | function(node) {··· current = ''; for (var i = 0; i < node.specifiers.length; i++) { current += createSpecHash(node.specifiers[i]); } if (node.source && node.source.value) { current += node.source.value; } if (previous && previous > current) { errors.add('imports must be alphabetized', node); } previous = current; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.source && node.source.value) {··· current += node.source.value; } |
✗ Negative was not executed (else) | }··· if (previous && previous > current) { |
Branch LogicalExpression | |
✓ Was returned | if (node.source && node.source.value) { |
✗ Was not returned | if (node.source && node.source.value) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (previous && previous > current) {··· errors.add('imports must be alphabetized', node); } |
✓ Negative was executed (else) | }··· previous = current; |
Branch LogicalExpression | |
✓ Was returned | if (previous && previous > current) { |
✓ Was returned | if (previous && previous > current) { |
Function (anonymous_910) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_911) | |
---|---|
✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords), this.getOptionName() + ' option requires array value'); this._keywords = keywords; }, |
Function (anonymous_912) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireKeywordsOnNewLine'; }, |
Function (anonymous_913) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { errors.assert.differentLine({ token: token.getPreviousCodeToken(), nextToken: token }); }); } |
Function (anonymous_914) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· errors.assert.differentLine({ token: token.getPreviousCodeToken(), nextToken: token }); }); |
Function (anonymous_915) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_916) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_917) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireLineBreakAfterVariableAssignment'; }, |
Function (anonymous_918) | |
---|---|
✓ Was called | check: function(file, errors) {··· var lastDeclaration; file.iterateNodesByType('VariableDeclaration', function(node) { if (node.parentElement.type === 'ForStatement' || node.parentElement.type === 'ForInStatement' || node.parentElement.type === 'ForOfStatement') { return; } for (var i = 0; i < node.declarations.length; i++) { var thisDeclaration = node.declarations[i]; if (thisDeclaration.parentElement.kind === 'var' || thisDeclaration.parentElement.kind === 'let' || thisDeclaration.parentElement.kind === 'const') { if (lastDeclaration && lastDeclaration.init) { errors.assert.differentLine({ token: lastDeclaration, nextToken: thisDeclaration, message: 'Variable assignments should be followed by new line' }); } lastDeclaration = thisDeclaration; } } }); } |
Function (anonymous_919) | |
---|---|
✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· if (node.parentElement.type === 'ForStatement' || node.parentElement.type === 'ForInStatement' || node.parentElement.type === 'ForOfStatement') { return; } for (var i = 0; i < node.declarations.length; i++) { var thisDeclaration = node.declarations[i]; if (thisDeclaration.parentElement.kind === 'var' || thisDeclaration.parentElement.kind === 'let' || thisDeclaration.parentElement.kind === 'const') { if (lastDeclaration && lastDeclaration.init) { errors.assert.differentLine({ token: lastDeclaration, nextToken: thisDeclaration, message: 'Variable assignments should be followed by new line' }); } lastDeclaration = thisDeclaration; } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.parentElement.type === 'ForOfStatement') {··· return; } |
✓ Negative was executed (else) | }··· for (var i = 0; i < node.declarations.length; i++) { |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type === 'ForOfStatement') { |
✓ Was returned | if (node.parentElement.type === 'ForStatement' ||··· node.parentElement.type === 'ForInStatement' || |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type === 'ForInStatement' || |
✓ Was returned | if (node.parentElement.type === 'ForStatement' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | thisDeclaration.parentElement.kind === 'const') {··· if (lastDeclaration && lastDeclaration.init) { errors.assert.differentLine({ token: lastDeclaration, nextToken: thisDeclaration, message: 'Variable assignments should be followed by new line' }); } lastDeclaration = thisDeclaration; } |
✗ Negative was not executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | thisDeclaration.parentElement.kind === 'const') { |
✓ Was returned | if (thisDeclaration.parentElement.kind === 'var' ||··· thisDeclaration.parentElement.kind === 'let' || |
Branch LogicalExpression | |
✓ Was returned | thisDeclaration.parentElement.kind === 'let' || |
✓ Was returned | if (thisDeclaration.parentElement.kind === 'var' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lastDeclaration && lastDeclaration.init) {··· errors.assert.differentLine({ token: lastDeclaration, nextToken: thisDeclaration, message: 'Variable assignments should be followed by new line' }); } |
✓ Negative was executed (else) | }··· lastDeclaration = thisDeclaration; |
Branch LogicalExpression | |
✓ Was returned | if (lastDeclaration && lastDeclaration.init) { |
✓ Was returned | if (lastDeclaration && lastDeclaration.init) { |
Function (anonymous_920) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_921) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_922) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireLineFeedAtFileEnd'; }, |
Function (anonymous_923) | |
---|---|
✓ Was called | check: function(file, errors) {··· var lastToken = file.getLastToken({includeComments: true}); var prevToken = file.getPrevToken(lastToken, {includeComments: true}); errors.assert.differentLine({ token: prevToken, nextToken: lastToken, message: 'Missing line feed at file end' }); } |
Function (anonymous_924) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_925) | |
---|---|
✓ Was called | configure: function(requireMatchingFunctionName) {··· if (typeof requireMatchingFunctionName === 'object') { assert(requireMatchingFunctionName.includeModuleExports === true, 'requireMatchingFunctionName option requires includeModuleExports property to be true for object'); this._includeModuleExports = requireMatchingFunctionName.includeModuleExports; } else { assert( requireMatchingFunctionName === true, 'requireMatchingFunctionName option requires true value or should be removed' ); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof requireMatchingFunctionName === 'object') {··· assert(requireMatchingFunctionName.includeModuleExports === true, 'requireMatchingFunctionName option requires includeModuleExports property to be true for object'); this._includeModuleExports = requireMatchingFunctionName.includeModuleExports; } else { |
✓ Negative was executed (else) | } else {··· assert( requireMatchingFunctionName === true, 'requireMatchingFunctionName option requires true value or should be removed' ); } |
Function (anonymous_926) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireMatchingFunctionName'; }, |
Function (anonymous_927) | |
---|---|
✓ Was called | check: function(file, errors) {··· var _includeModuleExports = this._includeModuleExports; file.iterateNodesByType(['FunctionExpression'], function(node) { switch (node.parentElement.type) { // var foo = function bar() {} // object.foo = function bar() {} // object['foo'] = function bar() {} case 'AssignmentExpression': if (_includeModuleExports || !_isModuleExports(node.parentElement.left)) { checkForMember(node.parentElement, skip, errors); } break; // object = {foo: function bar() {}} case 'ObjectProperty': checkForProperty(node.parentElement, skip, errors); break; } }); function skip(key, value) { // We don't care about anonymous functions as // those should be enforced by separate rule if (!value.id) { return true; } // Relax a bit when reserved word is detected if (reservedWords.check(key, file.getDialect(), true)) { return true; } } } |
Function (anonymous_928) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· switch (node.parentElement.type) { // var foo = function bar() {} // object.foo = function bar() {} // object['foo'] = function bar() {} case 'AssignmentExpression': if (_includeModuleExports || !_isModuleExports(node.parentElement.left)) { checkForMember(node.parentElement, skip, errors); } break; // object = {foo: function bar() {}} case 'ObjectProperty': checkForProperty(node.parentElement, skip, errors); break; } }); |
Branch SwitchStatement | |
---|---|
✓ Was evaluated | case 'AssignmentExpression':··· if (_includeModuleExports || !_isModuleExports(node.parentElement.left)) { checkForMember(node.parentElement, skip, errors); } break; |
✓ Was evaluated | case 'ObjectProperty':··· checkForProperty(node.parentElement, skip, errors); break; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_includeModuleExports || !_isModuleExports(node.parentElement.left)) {··· checkForMember(node.parentElement, skip, errors); } |
✓ Negative was executed (else) | }··· break; |
Branch LogicalExpression | |
✓ Was returned | if (_includeModuleExports || !_isModuleExports(node.parentElement.left)) { |
✓ Was returned | if (_includeModuleExports || !_isModuleExports(node.parentElement.left)) { |
Function skip | |
---|---|
✓ Was called | function skip(key, value) {··· // We don't care about anonymous functions as // those should be enforced by separate rule if (!value.id) { return true; } // Relax a bit when reserved word is detected if (reservedWords.check(key, file.getDialect(), true)) { return true; } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!value.id) {··· return true; } |
✓ Negative was executed (else) | }··· // Relax a bit when reserved word is detected |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (reservedWords.check(key, file.getDialect(), true)) {··· return true; } |
✓ Negative was executed (else) | }··· } |
Function _isModuleExports | |
---|---|
✓ Was called | function _isModuleExports(pattern) {··· if (pattern.type === 'MemberExpression') { // must be module.sth if (pattern.object.type === 'Identifier' && pattern.object.name === 'module') { if (pattern.property.type === 'Identifier' && pattern.property.name === 'exports') { // sth.exports return true; } else if (pattern.property.type === 'StringLiteral' && pattern.property.value === 'exports') { // sth["exports"] return true; } } } return false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (pattern.type === 'MemberExpression') {··· // must be module.sth if (pattern.object.type === 'Identifier' && pattern.object.name === 'module') { if (pattern.property.type === 'Identifier' && pattern.property.name === 'exports') { // sth.exports return true; } else if (pattern.property.type === 'StringLiteral' && pattern.property.value === 'exports') { // sth["exports"] return true; } } } |
✓ Negative was executed (else) | }··· return false; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | pattern.object.name === 'module') {··· if (pattern.property.type === 'Identifier' && pattern.property.name === 'exports') { // sth.exports return true; } else if (pattern.property.type === 'StringLiteral' && pattern.property.value === 'exports') { // sth["exports"] return true; } } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | pattern.object.name === 'module') { |
✓ Was returned | if (pattern.object.type === 'Identifier' && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | pattern.property.name === 'exports') {··· // sth.exports return true; } else if (pattern.property.type === 'StringLiteral' && |
✓ Negative was executed (else) | } else if (pattern.property.type === 'StringLiteral' &&··· pattern.property.value === 'exports') { // sth["exports"] return true; } |
Branch LogicalExpression | |
✓ Was returned | pattern.property.name === 'exports') { |
✓ Was returned | if (pattern.property.type === 'Identifier' && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | pattern.property.value === 'exports') {··· // sth["exports"] return true; } |
✗ Negative was not executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | pattern.property.value === 'exports') { |
✗ Was not returned | } else if (pattern.property.type === 'StringLiteral' && |
Function _resolvePatternName | |
---|---|
✓ Was called | function _resolvePatternName(pattern) {··· switch (pattern.type) { case 'Identifier': // prop = ...; return pattern.name; case 'StringLiteral': // obj['prop'] = ...; return pattern.value; case 'MemberExpression': // obj.prop = ...; return _resolvePatternName(pattern.property); default: // Something unhandy like obj['x' + 2] = ...; return false; } } |
Branch SwitchStatement | |
---|---|
✓ Was evaluated | case 'Identifier':··· // prop = ...; return pattern.name; |
✓ Was evaluated | case 'StringLiteral':··· // obj['prop'] = ...; return pattern.value; |
✓ Was evaluated | case 'MemberExpression':··· // obj.prop = ...; return _resolvePatternName(pattern.property); |
✓ Was evaluated | default:··· // Something unhandy like obj['x' + 2] = ...; return false; |
Function checkForMember | |
---|---|
✓ Was called | function checkForMember(assignment, skip, errors) {··· var _name = _resolvePatternName(assignment.left); if (_name === false || skip(_name, assignment.right)) { return; } if (_name !== assignment.right.id.name) { errors.add( 'Function name does not match member name', assignment ); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_name === false || skip(_name, assignment.right)) {··· return; } |
✓ Negative was executed (else) | }··· if (_name !== assignment.right.id.name) { |
Branch LogicalExpression | |
✓ Was returned | if (_name === false || skip(_name, assignment.right)) { |
✓ Was returned | if (_name === false || skip(_name, assignment.right)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_name !== assignment.right.id.name) {··· errors.add( 'Function name does not match member name', assignment ); } |
✓ Negative was executed (else) | }··· } |
Function checkForProperty | |
---|---|
✓ Was called | function checkForProperty(property, skip, errors) {··· var _name = _resolvePatternName(property.key); if (_name === false || skip(_name, property.value)) { return; } if (_name !== property.value.id.name) { errors.add( 'Function name does not match property name', property ); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_name === false || skip(_name, property.value)) {··· return; } |
✓ Negative was executed (else) | }··· if (_name !== property.value.id.name) { |
Branch LogicalExpression | |
✓ Was returned | if (_name === false || skip(_name, property.value)) { |
✓ Was returned | if (_name === false || skip(_name, property.value)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_name !== property.value.id.name) {··· errors.add( 'Function name does not match property name', property ); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_934) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_935) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_936) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireMultiLineTernary'; }, |
Function (anonymous_937) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ConditionalExpression', function(node) { errors.assert.differentLine({ token: node.test, nextToken: node.consequent, message: 'Missing new line after test' }); errors.assert.differentLine({ token: node.consequent, nextToken: node.alternate, message: 'Missing new line after consequent' }); }); } |
Function (anonymous_938) | |
---|---|
✓ Was called | file.iterateNodesByType('ConditionalExpression', function(node) {··· errors.assert.differentLine({ token: node.test, nextToken: node.consequent, message: 'Missing new line after test' }); errors.assert.differentLine({ token: node.consequent, nextToken: node.alternate, message: 'Missing new line after consequent' }); }); |
Function consecutive | |
---|---|
✓ Was called | function consecutive(file, errors) {··· var isExceptRequire = this._isExceptRequire; file.iterateNodesByType('VariableDeclaration', function(node) { if (isExceptRequire && hasRequireStatements(node)) { return; } var sibling = node.nextSibling; if (!sibling) { return; } while (sibling.nextSibling) { sibling = sibling.nextSibling; if (sibling.type !== node.type) { break; } if (isExceptRequire && hasRequireStatements(sibling)) { break; } if (sibling.kind === node.kind) { errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling ); } } }); } |
Function (anonymous_940) | |
---|---|
✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· if (isExceptRequire && hasRequireStatements(node)) { return; } var sibling = node.nextSibling; if (!sibling) { return; } while (sibling.nextSibling) { sibling = sibling.nextSibling; if (sibling.type !== node.type) { break; } if (isExceptRequire && hasRequireStatements(sibling)) { break; } if (sibling.kind === node.kind) { errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling ); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isExceptRequire && hasRequireStatements(node)) {··· return; } |
✓ Negative was executed (else) | }··· var sibling = node.nextSibling; |
Branch LogicalExpression | |
✓ Was returned | if (isExceptRequire && hasRequireStatements(node)) { |
✓ Was returned | if (isExceptRequire && hasRequireStatements(node)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!sibling) {··· return; } |
✓ Negative was executed (else) | }··· while (sibling.nextSibling) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (sibling.type !== node.type) {··· break; } |
✓ Negative was executed (else) | }··· if (isExceptRequire && hasRequireStatements(sibling)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isExceptRequire && hasRequireStatements(sibling)) {··· break; } |
✓ Negative was executed (else) | }··· if (sibling.kind === node.kind) { |
Branch LogicalExpression | |
✓ Was returned | if (isExceptRequire && hasRequireStatements(sibling)) { |
✓ Was returned | if (isExceptRequire && hasRequireStatements(sibling)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (sibling.kind === node.kind) {··· errors.add( node.kind[0].toUpperCase() + node.kind.slice(1) + ' declarations should be joined', sibling ); } |
✓ Negative was executed (else) | }··· } |
Function _onevar | |
---|---|
✓ Was called | function _onevar(file, errors, node) {··· var firstVar = true; var firstConst = true; var firstParent = true; file.iterate(function(node) { var type = node.type; var kind = node.kind; // Don't go in nested scopes if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) { return false; } if (firstParent) { firstParent = false; } if (type === 'VariableDeclaration') { if (kind === 'var') { if (!firstVar) { errors.add('Var declarations should be joined', node); } else { firstVar = false; } } if (kind === 'const') { if (!firstConst) { errors.add('Const declarations should be joined', node); } else { firstConst = false; } } } }, node); } |
Function (anonymous_942) | |
---|---|
✓ Was called | file.iterate(function(node) {··· var type = node.type; var kind = node.kind; // Don't go in nested scopes if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) { return false; } if (firstParent) { firstParent = false; } if (type === 'VariableDeclaration') { if (kind === 'var') { if (!firstVar) { errors.add('Var declarations should be joined', node); } else { firstVar = false; } } if (kind === 'const') { if (!firstConst) { errors.add('Const declarations should be joined', node); } else { firstConst = false; } } } }, node); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) {··· return false; } |
✓ Negative was executed (else) | }··· if (firstParent) { |
Branch LogicalExpression | |
✓ Was returned | if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) { |
✓ Was returned | if (!firstParent && ['FunctionDeclaration', 'FunctionExpression'].indexOf(type) > -1) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (firstParent) {··· firstParent = false; } |
✓ Negative was executed (else) | }··· if (type === 'VariableDeclaration') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (type === 'VariableDeclaration') {··· if (kind === 'var') { if (!firstVar) { errors.add('Var declarations should be joined', node); } else { firstVar = false; } } if (kind === 'const') { if (!firstConst) { errors.add('Const declarations should be joined', node); } else { firstConst = false; } } } |
✓ Negative was executed (else) | }··· }, node); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (kind === 'var') {··· if (!firstVar) { errors.add('Var declarations should be joined', node); } else { firstVar = false; } } |
✓ Negative was executed (else) | }··· if (kind === 'const') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!firstVar) {··· errors.add('Var declarations should be joined', node); } else { |
✓ Negative was executed (else) | } else {··· firstVar = false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (kind === 'const') {··· if (!firstConst) { errors.add('Const declarations should be joined', node); } else { firstConst = false; } } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!firstConst) {··· errors.add('Const declarations should be joined', node); } else { |
✓ Negative was executed (else) | } else {··· firstConst = false; } |
Function onevar | |
---|---|
✓ Was called | function onevar(file, errors) {··· _onevar(file, errors, file.getProgram()); file.iterateNodesByType( ['FunctionDeclaration', 'FunctionExpression'], _onevar.bind(this, file, errors) ); } |
Function hasRequireStatements | |
---|---|
✓ Was called | function hasRequireStatements(node) {··· if (!Array.isArray(node.declarations)) { return false; } return node.declarations.some(function(declaration) { var init = declaration.init; return init && init.callee && init.callee.name === 'require'; }); } |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!Array.isArray(node.declarations)) {··· return false; } |
✓ Negative was executed (else) | }··· return node.declarations.some(function(declaration) { |
Function (anonymous_945) | |
---|---|
✓ Was called | return node.declarations.some(function(declaration) {··· var init = declaration.init; return init && init.callee && init.callee.name === 'require'; }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | init.callee.name === 'require'; |
✓ Was returned | return init &&··· init.callee && |
Branch LogicalExpression | |
✓ Was returned | init.callee && |
✓ Was returned | return init && |
Function (anonymous_946) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_947) | |
---|---|
✓ Was called | configure: function(options) {··· var isExceptRequire = typeof options === 'object' && options.allExcept.length && options.allExcept.indexOf('require') !== -1; assert( options === true || options === 'onevar' || isExceptRequire, this.getOptionName() + ' option requires a true value, `onevar` or {allExcept: [\'require\']}' ); var checkers = { 'true': consecutive, onevar: onevar }; this._isExceptRequire = isExceptRequire; this._check = isExceptRequire ? consecutive : checkers[options]; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.allExcept.indexOf('require') !== -1; |
✓ Was returned | var isExceptRequire = typeof options === 'object' &&··· options.allExcept.length && |
Branch LogicalExpression | |
✓ Was returned | options.allExcept.length && |
✓ Was returned | var isExceptRequire = typeof options === 'object' && |
Branch LogicalExpression | |
---|---|
✓ Was returned | isExceptRequire, |
✓ Was returned | options === true ||··· options === 'onevar' || |
Branch LogicalExpression | |
✓ Was returned | options === 'onevar' || |
✓ Was returned | options === true || |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | this._check = isExceptRequire ? consecutive : checkers[options]; |
✓ Negative was returned (: ...) | this._check = isExceptRequire ? consecutive : checkers[options]; |
Function (anonymous_948) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireMultipleVarDecl'; }, |
Function (anonymous_949) | |
---|---|
✓ Was called | check: function() {··· return this._check.apply(this, arguments); } |
Function getNodeName | |
---|---|
✓ Was called | function getNodeName(node) {··· if (node.type === 'Identifier') { return node.name; } else { return node.value; } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'Identifier') {··· return node.name; } else { |
✓ Negative was executed (else) | } else {··· return node.value; } |
Function (anonymous_951) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_952) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || typeof options === 'object', this.getOptionName() + ' option requires true value ' + 'or an object with String[] `allExcept` property' ); // verify first item in `allExcept` property in object (if it's an object) assert( typeof options !== 'object' || Array.isArray(options.allExcept) && typeof options.allExcept[0] === 'string', 'Property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); if (options.allExcept) { this._allExceptItems = options.allExcept.map(function(item) { var parts = pathval.parse(item).map(function extractPart(part) { return part.i !== undefined ? part.i : part.p; }); return JSON.stringify(parts); }); } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof options === 'object', |
✓ Was returned | options === true || |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(options.allExcept) &&··· typeof options.allExcept[0] === 'string', |
✓ Was returned | typeof options !== 'object' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof options.allExcept[0] === 'string', |
✓ Was returned | Array.isArray(options.allExcept) && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.allExcept) {··· this._allExceptItems = options.allExcept.map(function(item) { var parts = pathval.parse(item).map(function extractPart(part) { return part.i !== undefined ? part.i : part.p; }); return JSON.stringify(parts); }); } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_953) | |
---|---|
✓ Was called | this._allExceptItems = options.allExcept.map(function(item) {··· var parts = pathval.parse(item).map(function extractPart(part) { return part.i !== undefined ? part.i : part.p; }); return JSON.stringify(parts); }); |
Function extractPart | |
---|---|
✓ Was called | var parts = pathval.parse(item).map(function extractPart(part) {··· return part.i !== undefined ? part.i : part.p; }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return part.i !== undefined ? part.i : part.p; |
✓ Negative was returned (: ...) | return part.i !== undefined ? part.i : part.p; |
Function (anonymous_955) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireNamedUnassignedFunctions'; }, |
Function (anonymous_956) | |
---|---|
✓ Was called | check: function(file, errors) {··· var _this = this; file.iterateNodesByType('FunctionExpression', function(node) { var parentElement = node.parentElement; // If the function has been named via left hand assignment, skip it // e.g. `var hello = function() {`, `foo.bar = function() {` if (parentElement.type.match(/VariableDeclarator|Property|AssignmentExpression/)) { return; } // If the function has been named, skip it // e.g. `[].forEach(function hello() {` if (node.id !== null) { return; } // If we have exceptions and the function is being invoked, detect whether we excepted it if (_this._allExceptItems && parentElement.type === 'CallExpression') { // Determine the path that resolves to our call expression // We must cover both direct calls (e.g. `it(function() {`) and // member expressions (e.g. `foo.bar(function() {`) var memberNode = parentElement.callee; var canBeRepresented = true; var fullpathParts = []; while (memberNode) { if (memberNode.type.match(/Identifier|Literal/)) { fullpathParts.unshift(getNodeName(memberNode)); } else if (memberNode.type === 'MemberExpression') { fullpathParts.unshift(getNodeName(memberNode.property)); } else { canBeRepresented = false; break; } memberNode = memberNode.object; } // If the path is not-dynamic (i.e. can be represented by static parts), // then check it against our exceptions if (canBeRepresented) { var fullpath = JSON.stringify(fullpathParts); for (var i = 0, l = _this._allExceptItems.length; i < l; i++) { if (fullpath === _this._allExceptItems[i]) { return; } } } } // Complain that this function must be named errors.add('Inline functions need to be named', node); }); } |
Function (anonymous_957) | |
---|---|
✓ Was called | file.iterateNodesByType('FunctionExpression', function(node) {··· var parentElement = node.parentElement; // If the function has been named via left hand assignment, skip it // e.g. `var hello = function() {`, `foo.bar = function() {` if (parentElement.type.match(/VariableDeclarator|Property|AssignmentExpression/)) { return; } // If the function has been named, skip it // e.g. `[].forEach(function hello() {` if (node.id !== null) { return; } // If we have exceptions and the function is being invoked, detect whether we excepted it if (_this._allExceptItems && parentElement.type === 'CallExpression') { // Determine the path that resolves to our call expression // We must cover both direct calls (e.g. `it(function() {`) and // member expressions (e.g. `foo.bar(function() {`) var memberNode = parentElement.callee; var canBeRepresented = true; var fullpathParts = []; while (memberNode) { if (memberNode.type.match(/Identifier|Literal/)) { fullpathParts.unshift(getNodeName(memberNode)); } else if (memberNode.type === 'MemberExpression') { fullpathParts.unshift(getNodeName(memberNode.property)); } else { canBeRepresented = false; break; } memberNode = memberNode.object; } // If the path is not-dynamic (i.e. can be represented by static parts), // then check it against our exceptions if (canBeRepresented) { var fullpath = JSON.stringify(fullpathParts); for (var i = 0, l = _this._allExceptItems.length; i < l; i++) { if (fullpath === _this._allExceptItems[i]) { return; } } } } // Complain that this function must be named errors.add('Inline functions need to be named', node); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type.match(/VariableDeclarator|Property|AssignmentExpression/)) {··· return; } |
✓ Negative was executed (else) | }··· // If the function has been named, skip it |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.id !== null) {··· return; } |
✓ Negative was executed (else) | }··· // If we have exceptions and the function is being invoked, detect whether we excepted it |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._allExceptItems && parentElement.type === 'CallExpression') {··· // Determine the path that resolves to our call expression // We must cover both direct calls (e.g. `it(function() {`) and // member expressions (e.g. `foo.bar(function() {`) var memberNode = parentElement.callee; var canBeRepresented = true; var fullpathParts = []; while (memberNode) { if (memberNode.type.match(/Identifier|Literal/)) { fullpathParts.unshift(getNodeName(memberNode)); } else if (memberNode.type === 'MemberExpression') { fullpathParts.unshift(getNodeName(memberNode.property)); } else { canBeRepresented = false; break; } memberNode = memberNode.object; } // If the path is not-dynamic (i.e. can be represented by static parts), // then check it against our exceptions if (canBeRepresented) { var fullpath = JSON.stringify(fullpathParts); for (var i = 0, l = _this._allExceptItems.length; i < l; i++) { if (fullpath === _this._allExceptItems[i]) { return; } } } } |
✓ Negative was executed (else) | }··· // Complain that this function must be named |
Branch LogicalExpression | |
✓ Was returned | if (_this._allExceptItems && parentElement.type === 'CallExpression') { |
✓ Was returned | if (_this._allExceptItems && parentElement.type === 'CallExpression') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (memberNode.type.match(/Identifier|Literal/)) {··· fullpathParts.unshift(getNodeName(memberNode)); } else if (memberNode.type === 'MemberExpression') { |
✓ Negative was executed (else) | } else if (memberNode.type === 'MemberExpression') {··· fullpathParts.unshift(getNodeName(memberNode.property)); } else { canBeRepresented = false; break; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (memberNode.type === 'MemberExpression') {··· fullpathParts.unshift(getNodeName(memberNode.property)); } else { |
✓ Negative was executed (else) | } else {··· canBeRepresented = false; break; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (canBeRepresented) {··· var fullpath = JSON.stringify(fullpathParts); for (var i = 0, l = _this._allExceptItems.length; i < l; i++) { if (fullpath === _this._allExceptItems[i]) { return; } } } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (fullpath === _this._allExceptItems[i]) {··· return; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_958) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_959) | |
---|---|
✓ Was called | configure: function(settingValue) {··· assert( Array.isArray(settingValue) && settingValue.length || settingValue === true, 'requireNewlineBeforeBlockStatements option requires non-empty array value or true value' ); this._setting = settingValue; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
Branch LogicalExpression | |
✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
✓ Was returned | Array.isArray(settingValue) && settingValue.length || settingValue === true, |
Function (anonymous_960) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireNewlineBeforeBlockStatements'; }, |
Function (anonymous_961) | |
---|---|
✓ Was called | check: function(file, errors) {··· var setting = this._setting; function assertDifferentLine(token, nextToken) { errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is required' }); } file.iterateNodesByType('BlockStatement', function(node) { if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { var openingBrace = node.getFirstToken(); var prevToken = openingBrace.getPreviousCodeToken(); assertDifferentLine(prevToken, openingBrace); } }); if (setting === true || setting.indexOf('switch') !== -1) { file.iterateNodesByType(['SwitchStatement'], function(node) { var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); assertDifferentLine(prevToken, openingBrace); }); } } |
Function assertDifferentLine | |
---|---|
✓ Was called | function assertDifferentLine(token, nextToken) {··· errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before curly brace for block statement is required' }); } |
Function (anonymous_963) | |
---|---|
✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { var openingBrace = node.getFirstToken(); var prevToken = openingBrace.getPreviousCodeToken(); assertDifferentLine(prevToken, openingBrace); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) {··· var openingBrace = node.getFirstToken(); var prevToken = openingBrace.getPreviousCodeToken(); assertDifferentLine(prevToken, openingBrace); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
✓ Was returned | if (setting === true || setting.indexOf(getBlockType(node)) !== -1) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (setting === true || setting.indexOf('switch') !== -1) {··· file.iterateNodesByType(['SwitchStatement'], function(node) { var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); assertDifferentLine(prevToken, openingBrace); }); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (setting === true || setting.indexOf('switch') !== -1) { |
✓ Was returned | if (setting === true || setting.indexOf('switch') !== -1) { |
Function (anonymous_964) | |
---|---|
✓ Was called | file.iterateNodesByType(['SwitchStatement'], function(node) {··· var openingBrace = file.findNextToken(file.getLastNodeToken(node.discriminant), 'Punctuator', '{'); var prevToken = file.getPrevToken(openingBrace); assertDifferentLine(prevToken, openingBrace); }); |
Function getBlockType | |
---|---|
✓ Was called | function getBlockType(node) {··· var parentElement = node.parentElement; switch (parentElement.type) { case 'IfStatement': return (parentElement.alternate === node) ? 'else' : 'if'; case 'FunctionDeclaration': case 'FunctionExpression': case 'ArrowFunctionExpression': return 'function'; case 'ForStatement': case 'ForInStatement': case 'ForOfStatement': return 'for'; case 'WhileStatement': return 'while'; case 'DoWhileStatement': return 'do'; case 'TryStatement': return (parentElement.finalizer === node) ? 'finally' : 'try'; case 'CatchClause': return 'catch'; } } |
Branch SwitchStatement | |
---|---|
✓ Was evaluated | case 'IfStatement':··· return (parentElement.alternate === node) ? 'else' : 'if'; |
✓ Was evaluated | case 'FunctionDeclaration': |
✓ Was evaluated | case 'FunctionExpression': |
✓ Was evaluated | case 'ArrowFunctionExpression':··· return 'function'; |
✓ Was evaluated | case 'ForStatement': |
✓ Was evaluated | case 'ForInStatement': |
✓ Was evaluated | case 'ForOfStatement':··· return 'for'; |
✓ Was evaluated | case 'WhileStatement':··· return 'while'; |
✓ Was evaluated | case 'DoWhileStatement':··· return 'do'; |
✓ Was evaluated | case 'TryStatement':··· return (parentElement.finalizer === node) ? 'finally' : 'try'; |
✓ Was evaluated | case 'CatchClause':··· return 'catch'; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return (parentElement.alternate === node) ? 'else' : 'if'; |
✓ Negative was returned (: ...) | return (parentElement.alternate === node) ? 'else' : 'if'; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return (parentElement.finalizer === node) ? 'finally' : 'try'; |
✓ Negative was returned (: ...) | return (parentElement.finalizer === node) ? 'finally' : 'try'; |
Function (anonymous_966) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function getFirstStatement | |
---|---|
✓ Was called | function getFirstStatement(node) {··· if (node && node.type === 'BlockStatement') { return node.body[0]; } return node; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node && node.type === 'BlockStatement') {··· return node.body[0]; } |
✓ Negative was executed (else) | }··· return node; |
Branch LogicalExpression | |
✓ Was returned | if (node && node.type === 'BlockStatement') { |
✓ Was returned | if (node && node.type === 'BlockStatement') { |
Function (anonymous_968) | |
---|---|
✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_969) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireNewlineBeforeSingleStatementsInIf'; }, |
Function (anonymous_970) | |
---|---|
✓ Was called | check: function(file, errors) {··· function assertDifferentLine(token, nextToken) { errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before single statement in if is required' }); } // Recursively locate a token based on it's type. function getToken(entity, tokenType, tokenProperty) { if (entity.type === tokenType || !entity[tokenProperty]) { return entity; } else { return getToken(entity[tokenProperty], tokenType, tokenProperty); } } file.iterateNodesByType('IfStatement', function(node) { var consequentNode = getFirstStatement(node.consequent); var alternateNode = getFirstStatement(node.alternate); if (consequentNode) { assertDifferentLine( getToken(consequentNode, 'Keyword', 'previousSibling'), consequentNode ); } if (alternateNode && alternateNode.type !== 'IfStatement' && alternateNode.type !== 'BlockStatement') { assertDifferentLine( getToken(alternateNode, 'Keyword', 'previousSibling'), alternateNode ); } }); } |
Function assertDifferentLine | |
---|---|
✓ Was called | function assertDifferentLine(token, nextToken) {··· errors.assert.differentLine({ token: token, nextToken: nextToken, message: 'Newline before single statement in if is required' }); } |
Function getToken | |
---|---|
✓ Was called | function getToken(entity, tokenType, tokenProperty) {··· if (entity.type === tokenType || !entity[tokenProperty]) { return entity; } else { return getToken(entity[tokenProperty], tokenType, tokenProperty); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (entity.type === tokenType || !entity[tokenProperty]) {··· return entity; } else { |
✓ Negative was executed (else) | } else {··· return getToken(entity[tokenProperty], tokenType, tokenProperty); } |
Branch LogicalExpression | |
✓ Was returned | if (entity.type === tokenType || !entity[tokenProperty]) { |
✓ Was returned | if (entity.type === tokenType || !entity[tokenProperty]) { |
Function (anonymous_973) | |
---|---|
✓ Was called | file.iterateNodesByType('IfStatement', function(node) {··· var consequentNode = getFirstStatement(node.consequent); var alternateNode = getFirstStatement(node.alternate); if (consequentNode) { assertDifferentLine( getToken(consequentNode, 'Keyword', 'previousSibling'), consequentNode ); } if (alternateNode && alternateNode.type !== 'IfStatement' && alternateNode.type !== 'BlockStatement') { assertDifferentLine( getToken(alternateNode, 'Keyword', 'previousSibling'), alternateNode ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (consequentNode) {··· assertDifferentLine( getToken(consequentNode, 'Keyword', 'previousSibling'), consequentNode ); } |
✗ Negative was not executed (else) | }··· if (alternateNode && alternateNode.type !== 'IfStatement' && alternateNode.type !== 'BlockStatement') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (alternateNode && alternateNode.type !== 'IfStatement' && alternateNode.type !== 'BlockStatement') {··· assertDifferentLine( getToken(alternateNode, 'Keyword', 'previousSibling'), alternateNode ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (alternateNode && alternateNode.type !== 'IfStatement' && alternateNode.type !== 'BlockStatement') { |
✓ Was returned | if (alternateNode && alternateNode.type !== 'IfStatement' && alternateNode.type !== 'BlockStatement') { |
Branch LogicalExpression | |
✓ Was returned | if (alternateNode && alternateNode.type !== 'IfStatement' && alternateNode.type !== 'BlockStatement') { |
✓ Was returned | if (alternateNode && alternateNode.type !== 'IfStatement' && alternateNode.type !== 'BlockStatement') { |
Function (anonymous_974) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_975) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); this._radixMap = { 2: 'binary', 8: 'octal', 16: 'hexadecimal' }; }, |
Function (anonymous_976) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireNumericLiterals'; }, |
Function (anonymous_977) | |
---|---|
✓ Was called | check: function(file, errors) {··· var radixMap = this._radixMap; file.iterateNodesByType(['CallExpression'], function(node) { // don't check for parseInt(1) if (node.arguments.length !== 2) { return; } // only error if the radix is 2, 8, or 16 var radixName = radixMap[node.arguments[1].value]; if (node.callee.type === 'Identifier' && node.callee.name === 'parseInt' && radixName && node.arguments[0].type.indexOf('Literal') > -1 ) { errors.add('Use ' + radixName + ' literals instead of parseInt', node); } }); } |
Function (anonymous_978) | |
---|---|
✓ Was called | file.iterateNodesByType(['CallExpression'], function(node) {··· // don't check for parseInt(1) if (node.arguments.length !== 2) { return; } // only error if the radix is 2, 8, or 16 var radixName = radixMap[node.arguments[1].value]; if (node.callee.type === 'Identifier' && node.callee.name === 'parseInt' && radixName && node.arguments[0].type.indexOf('Literal') > -1 ) { errors.add('Use ' + radixName + ' literals instead of parseInt', node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.arguments.length !== 2) {··· return; } |
✓ Negative was executed (else) | }··· // only error if the radix is 2, 8, or 16 |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add('Use ' + radixName + ' literals instead of parseInt', node); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | node.arguments[0].type.indexOf('Literal') > -1 |
✓ Was returned | if (node.callee.type === 'Identifier' &&··· node.callee.name === 'parseInt' && radixName && |
Branch LogicalExpression | |
✓ Was returned | radixName && |
✓ Was returned | if (node.callee.type === 'Identifier' &&··· node.callee.name === 'parseInt' && |
Branch LogicalExpression | |
✓ Was returned | node.callee.name === 'parseInt' && |
✓ Was returned | if (node.callee.type === 'Identifier' && |
Function (anonymous_979) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_980) | |
---|---|
✓ Was called | configure: function(option) {··· var isTrue = option === true; assert( isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), this.getOptionName() + ' requires the value `true` ' + 'or an object with an `allExcept` array property' ); this._propertyExceptions = !isTrue && option.allExcept || []; }, |
Branch LogicalExpression | |
---|---|
✗ Was not returned | isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), |
✓ Was returned | isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), |
Branch LogicalExpression | |
✗ Was not returned | isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), |
✗ Was not returned | isTrue || (typeof option === 'object' && Array.isArray(option.allExcept)), |
Branch LogicalExpression | |
---|---|
✓ Was returned | this._propertyExceptions = !isTrue && option.allExcept || []; |
✗ Was not returned | this._propertyExceptions = !isTrue && option.allExcept || []; |
Branch LogicalExpression | |
✗ Was not returned | this._propertyExceptions = !isTrue && option.allExcept || []; |
✓ Was returned | this._propertyExceptions = !isTrue && option.allExcept || []; |
Function (anonymous_981) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireObjectDestructuring'; }, |
Function (anonymous_982) | |
---|---|
✓ Was called | check: function(file, errors) {··· var propertyExceptions = this._propertyExceptions; file.iterateNodesByType('VariableDeclaration', function(node) { node.declarations.forEach(function(declaration) { var declarationId = declaration.id || {}; var declarationInit = declaration.init || {}; if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { return; } var propertyName = declarationInit.property && declarationInit.property.name; if (declarationId.name === propertyName && propertyExceptions.indexOf(propertyName) < 0) { errors.add('Property assignments should use destructuring', node); } }); }); } |
Function (anonymous_983) | |
---|---|
✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· node.declarations.forEach(function(declaration) { var declarationId = declaration.id || {}; var declarationInit = declaration.init || {}; if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { return; } var propertyName = declarationInit.property && declarationInit.property.name; if (declarationId.name === propertyName && propertyExceptions.indexOf(propertyName) < 0) { errors.add('Property assignments should use destructuring', node); } }); }); |
Function (anonymous_984) | |
---|---|
✓ Was called | node.declarations.forEach(function(declaration) {··· var declarationId = declaration.id || {}; var declarationInit = declaration.init || {}; if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { return; } var propertyName = declarationInit.property && declarationInit.property.name; if (declarationId.name === propertyName && propertyExceptions.indexOf(propertyName) < 0) { errors.add('Property assignments should use destructuring', node); } }); |
Branch LogicalExpression | |
---|---|
✗ Was not returned | var declarationId = declaration.id || {}; |
✓ Was returned | var declarationId = declaration.id || {}; |
Branch LogicalExpression | |
---|---|
✗ Was not returned | var declarationInit = declaration.init || {}; |
✓ Was returned | var declarationInit = declaration.init || {}; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') {··· return; } |
✓ Negative was executed (else) | }··· var propertyName = declarationInit.property && declarationInit.property.name; |
Branch LogicalExpression | |
✓ Was returned | if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { |
✓ Was returned | if (declarationId.type !== 'Identifier' || declarationInit.type !== 'MemberExpression') { |
Branch LogicalExpression | |
---|---|
✓ Was returned | var propertyName = declarationInit.property && declarationInit.property.name; |
✗ Was not returned | var propertyName = declarationInit.property && declarationInit.property.name; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | propertyExceptions.indexOf(propertyName) < 0) {··· errors.add('Property assignments should use destructuring', node); } |
✗ Negative was not executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | propertyExceptions.indexOf(propertyName) < 0) { |
✗ Was not returned | if (declarationId.name === propertyName && |
Function (anonymous_985) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_986) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || Array.isArray(options.allExcept), this.getOptionName() + ' option requires a true value or an object of exceptions' ); this._isSameLine = false; if (Array.isArray(options.allExcept)) { this._isSameLine = options.allExcept[0] === 'sameLine'; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || Array.isArray(options.allExcept), |
✓ Was returned | options === true || Array.isArray(options.allExcept), |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._isSameLine = options.allExcept[0] === 'sameLine'; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_987) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireObjectKeysOnNewLine'; }, |
Function (anonymous_988) | |
---|---|
✓ Was called | check: function(file, errors) {··· var message = 'Object keys must go on a new line'; var isSameLine = this._isSameLine; if (isSameLine) { message = 'Object keys must go on a new line if they aren\'t all on the same line'; } file.iterateNodesByType('ObjectExpression', function(node) { var firstKeyToken; var lastValueToken; var lastProp; if (isSameLine) { if (node.properties.length > 1) { firstKeyToken = file.getFirstNodeToken(node.properties[0].key); lastProp = node.properties[node.properties.length - 1]; lastValueToken = file.getLastNodeToken(lastProp.value || lastProp.key); if (firstKeyToken.getLoc().end.line === lastValueToken.getLoc().start.line) { // It's ok, all keys and values are on the same line. return; } } } for (var i = 1; i < node.properties.length; i++) { var prop = node.properties[i - 1]; lastValueToken = file.getLastNodeToken(prop.value || prop.body); var comma = file.findNextToken(lastValueToken, 'Punctuator', ','); firstKeyToken = file.getFirstNodeToken(node.properties[i].key); errors.assert.differentLine({ token: comma, nextToken: firstKeyToken, message: message }); } }); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isSameLine) {··· message = 'Object keys must go on a new line if they aren\'t all on the same line'; } |
✓ Negative was executed (else) | }··· file.iterateNodesByType('ObjectExpression', function(node) { |
Function (anonymous_989) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var firstKeyToken; var lastValueToken; var lastProp; if (isSameLine) { if (node.properties.length > 1) { firstKeyToken = file.getFirstNodeToken(node.properties[0].key); lastProp = node.properties[node.properties.length - 1]; lastValueToken = file.getLastNodeToken(lastProp.value || lastProp.key); if (firstKeyToken.getLoc().end.line === lastValueToken.getLoc().start.line) { // It's ok, all keys and values are on the same line. return; } } } for (var i = 1; i < node.properties.length; i++) { var prop = node.properties[i - 1]; lastValueToken = file.getLastNodeToken(prop.value || prop.body); var comma = file.findNextToken(lastValueToken, 'Punctuator', ','); firstKeyToken = file.getFirstNodeToken(node.properties[i].key); errors.assert.differentLine({ token: comma, nextToken: firstKeyToken, message: message }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isSameLine) {··· if (node.properties.length > 1) { firstKeyToken = file.getFirstNodeToken(node.properties[0].key); lastProp = node.properties[node.properties.length - 1]; lastValueToken = file.getLastNodeToken(lastProp.value || lastProp.key); if (firstKeyToken.getLoc().end.line === lastValueToken.getLoc().start.line) { // It's ok, all keys and values are on the same line. return; } } } |
✓ Negative was executed (else) | }··· for (var i = 1; i < node.properties.length; i++) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.properties.length > 1) {··· firstKeyToken = file.getFirstNodeToken(node.properties[0].key); lastProp = node.properties[node.properties.length - 1]; lastValueToken = file.getLastNodeToken(lastProp.value || lastProp.key); if (firstKeyToken.getLoc().end.line === lastValueToken.getLoc().start.line) { // It's ok, all keys and values are on the same line. return; } } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
---|---|
✓ Was returned | lastValueToken = file.getLastNodeToken(lastProp.value || lastProp.key); |
✓ Was returned | lastValueToken = file.getLastNodeToken(lastProp.value || lastProp.key); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (firstKeyToken.getLoc().end.line === lastValueToken.getLoc().start.line) {··· // It's ok, all keys and values are on the same line. return; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
---|---|
✓ Was returned | lastValueToken = file.getLastNodeToken(prop.value || prop.body); |
✓ Was returned | lastValueToken = file.getLastNodeToken(prop.value || prop.body); |
Function (anonymous_990) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_991) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array value or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_992) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireOperatorBeforeLineBreak'; }, |
Function (anonymous_993) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; var throughTokens = ['?', ',']; function errorIfApplicable(operatorToken) { errors.assert.sameLine({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + operatorToken.value + ' should not be on a new line', stickToPreviousToken: true }); } throughTokens = throughTokens.filter(function(operator) { return operators[operator]; }); if (throughTokens.length) { file.iterateTokensByType('Punctuator', function(token) { var operator = token.value; if (throughTokens.every(function() { return throughTokens.indexOf(operator) >= 0; })) { errorIfApplicable(token); } }); } file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'LogicalExpression'], function(node) { var operator = node.operator; if (!operators[operator]) { return; } var nextToken = file.getFirstNodeToken(node.argument || node.right); var token = file.findPrevOperatorToken(nextToken, operator); errorIfApplicable(token); } ); } |
Function errorIfApplicable | |
---|---|
✓ Was called | function errorIfApplicable(operatorToken) {··· errors.assert.sameLine({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + operatorToken.value + ' should not be on a new line', stickToPreviousToken: true }); } |
Function (anonymous_995) | |
---|---|
✓ Was called | throughTokens = throughTokens.filter(function(operator) {··· return operators[operator]; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (throughTokens.length) {··· file.iterateTokensByType('Punctuator', function(token) { var operator = token.value; if (throughTokens.every(function() { return throughTokens.indexOf(operator) >= 0; })) { errorIfApplicable(token); } }); } |
✓ Negative was executed (else) | }··· file.iterateNodesByType( |
Function (anonymous_996) | |
---|---|
✓ Was called | file.iterateTokensByType('Punctuator', function(token) {··· var operator = token.value; if (throughTokens.every(function() { return throughTokens.indexOf(operator) >= 0; })) { errorIfApplicable(token); } }); |
Function (anonymous_997) | |
---|---|
✓ Was called | if (throughTokens.every(function() {··· return throughTokens.indexOf(operator) >= 0; })) { |
Branch IfStatement | |
✓ Positive was executed (if) | })) {··· errorIfApplicable(token); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_998) | |
---|---|
✓ Was called | function(node) {··· var operator = node.operator; if (!operators[operator]) { return; } var nextToken = file.getFirstNodeToken(node.argument || node.right); var token = file.findPrevOperatorToken(nextToken, operator); errorIfApplicable(token); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!operators[operator]) {··· return; } |
✓ Negative was executed (else) | }··· var nextToken = file.getFirstNodeToken(node.argument || node.right); |
Branch LogicalExpression | |
---|---|
✓ Was returned | var nextToken = file.getFirstNodeToken(node.argument || node.right); |
✗ Was not returned | var nextToken = file.getFirstNodeToken(node.argument || node.right); |
Function (anonymous_999) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1000) | |
---|---|
✓ Was called | configure: function(requirePaddingNewLineAfterVariableDeclaration) {··· assert( requirePaddingNewLineAfterVariableDeclaration === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1001) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLineAfterVariableDeclaration'; }, |
Function (anonymous_1002) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('VariableDeclaration', function(node) { if (node.parentElement.type === 'ForStatement' || node.parentElement.type === 'ForInStatement' || node.parentElement.type === 'ForOfStatement') { return; } var endOfDeclaration = file.getLastNodeToken(node); var nextToken = file.getNextToken(endOfDeclaration); // check export declaration if (nextToken.value === 'export') { nextToken = file.getNextToken(nextToken); } if (nextToken.value in {'var': true, 'let': true, 'const': true}) { return; } if (nextToken.value === '}') { return; } if (nextToken.type === 'EOF') { return; } errors.assert.linesBetween({ atLeast: 2, token: endOfDeclaration, nextToken: nextToken }); }); } |
Function (anonymous_1003) | |
---|---|
✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· if (node.parentElement.type === 'ForStatement' || node.parentElement.type === 'ForInStatement' || node.parentElement.type === 'ForOfStatement') { return; } var endOfDeclaration = file.getLastNodeToken(node); var nextToken = file.getNextToken(endOfDeclaration); // check export declaration if (nextToken.value === 'export') { nextToken = file.getNextToken(nextToken); } if (nextToken.value in {'var': true, 'let': true, 'const': true}) { return; } if (nextToken.value === '}') { return; } if (nextToken.type === 'EOF') { return; } errors.assert.linesBetween({ atLeast: 2, token: endOfDeclaration, nextToken: nextToken }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.parentElement.type === 'ForOfStatement') {··· return; } |
✓ Negative was executed (else) | }··· var endOfDeclaration = file.getLastNodeToken(node); |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type === 'ForOfStatement') { |
✓ Was returned | if (node.parentElement.type === 'ForStatement' ||··· node.parentElement.type === 'ForInStatement' || |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type === 'ForInStatement' || |
✓ Was returned | if (node.parentElement.type === 'ForStatement' || |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (nextToken.value === 'export') {··· nextToken = file.getNextToken(nextToken); } |
✓ Negative was executed (else) | }··· if (nextToken.value in {'var': true, 'let': true, 'const': true}) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.value in {'var': true, 'let': true, 'const': true}) {··· return; } |
✓ Negative was executed (else) | }··· if (nextToken.value === '}') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.value === '}') {··· return; } |
✓ Negative was executed (else) | }··· if (nextToken.type === 'EOF') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.type === 'EOF') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
Function (anonymous_1004) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1005) | |
---|---|
✓ Was called | configure: function(value) {··· this.exceptions = { 'CallExpression': false, 'NewExpression': false, 'ArrayExpression': false, 'ObjectProperty': false, 'SingleLine': false }; var optionName = this.getOptionName(); if (typeof value === 'object') { assert(Array.isArray(value.allExcept), optionName + ' option requires "allExcept" ' + 'to be an array'); assert(value.allExcept.length > 0, optionName + ' option requires "allExcept" ' + 'to have at least one item or be set to `true`'); value.allExcept.forEach(function(except) { if (except === 'inCallExpressions') { this.exceptions.CallExpression = true; } else if (except === 'inNewExpressions') { this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.ObjectProperty = true; } else if (except === 'singleLine') { this.exceptions.SingleLine = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions",' + '"inArrayExpressions", "inProperties" or "singleLine"'); } }, this); } else { assert(value === true, optionName + ' option requires true value or object' ); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof value === 'object') {··· assert(Array.isArray(value.allExcept), optionName + ' option requires "allExcept" ' + 'to be an array'); assert(value.allExcept.length > 0, optionName + ' option requires "allExcept" ' + 'to have at least one item or be set to `true`'); value.allExcept.forEach(function(except) { if (except === 'inCallExpressions') { this.exceptions.CallExpression = true; } else if (except === 'inNewExpressions') { this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.ObjectProperty = true; } else if (except === 'singleLine') { this.exceptions.SingleLine = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions",' + '"inArrayExpressions", "inProperties" or "singleLine"'); } }, this); } else { |
✓ Negative was executed (else) | } else {··· assert(value === true, optionName + ' option requires true value or object' ); } |
Function (anonymous_1006) | |
---|---|
✓ Was called | value.allExcept.forEach(function(except) {··· if (except === 'inCallExpressions') { this.exceptions.CallExpression = true; } else if (except === 'inNewExpressions') { this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.ObjectProperty = true; } else if (except === 'singleLine') { this.exceptions.SingleLine = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions",' + '"inArrayExpressions", "inProperties" or "singleLine"'); } }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (except === 'inCallExpressions') {··· this.exceptions.CallExpression = true; } else if (except === 'inNewExpressions') { |
✓ Negative was executed (else) | } else if (except === 'inNewExpressions') {··· this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.ObjectProperty = true; } else if (except === 'singleLine') { this.exceptions.SingleLine = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions",' + '"inArrayExpressions", "inProperties" or "singleLine"'); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (except === 'inNewExpressions') {··· this.exceptions.NewExpression = true; } else if (except === 'inArrayExpressions') { |
✓ Negative was executed (else) | } else if (except === 'inArrayExpressions') {··· this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { this.exceptions.ObjectProperty = true; } else if (except === 'singleLine') { this.exceptions.SingleLine = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions",' + '"inArrayExpressions", "inProperties" or "singleLine"'); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (except === 'inArrayExpressions') {··· this.exceptions.ArrayExpression = true; } else if (except === 'inProperties') { |
✓ Negative was executed (else) | } else if (except === 'inProperties') {··· this.exceptions.ObjectProperty = true; } else if (except === 'singleLine') { this.exceptions.SingleLine = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions",' + '"inArrayExpressions", "inProperties" or "singleLine"'); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (except === 'inProperties') {··· this.exceptions.ObjectProperty = true; } else if (except === 'singleLine') { |
✓ Negative was executed (else) | } else if (except === 'singleLine') {··· this.exceptions.SingleLine = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions",' + '"inArrayExpressions", "inProperties" or "singleLine"'); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (except === 'singleLine') {··· this.exceptions.SingleLine = true; } else { |
✓ Negative was executed (else) | } else {··· assert(false, optionName + ' option requires "allExcept" to only have ' + 'one of "inCallExpressions", "inNewExpressions",' + '"inArrayExpressions", "inProperties" or "singleLine"'); } |
Function (anonymous_1007) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesAfterBlocks'; }, |
Function (anonymous_1008) | |
---|---|
✓ Was called | check: function(file, errors) {··· function isException(node, parent, exceptions) { var grandpa = parent.parentElement; // Check if this block is used in call or array expression if (grandpa && exceptions[grandpa.type]) { return true; } var first = node.getFirstToken(); var last = node.getLastToken(); if (exceptions.SingleLine && file.isOnTheSameLine(first, last)) { return true; } return false; } file.iterateNodesByType('BlockStatement', (function(node) { var endToken = file.getLastNodeToken(node); var parentElement = node.parentElement; var tokens = { next: endToken.getNextCodeToken(), token: endToken }; if (isException(node, parentElement, this.exceptions)) { return; } while (tokens.next.type !== 'EOF') { var excludeValues = excludes[parentElement.type]; if (excludeValues && excludeValues.indexOf(tokens.next.value) !== -1) { return; } if (file.isOnTheSameLine(tokens.token, tokens.next)) { endToken = tokens.next; tokens.next = tokens.next.getNextCodeToken(); continue; } if (tokens.next.type === 'Punctuator' && ( tokens.next.value === '}' || tokens.next.value === ']' || tokens.next.value === '>' || tokens.next.value === ')') ) { return; } errors.assert.linesBetween({ token: tokens.token, nextToken: tokens.next, atLeast: 2, message: 'Missing newline after block' }); return; } }).bind(this)); } |
Function isException | |
---|---|
✓ Was called | function isException(node, parent, exceptions) {··· var grandpa = parent.parentElement; // Check if this block is used in call or array expression if (grandpa && exceptions[grandpa.type]) { return true; } var first = node.getFirstToken(); var last = node.getLastToken(); if (exceptions.SingleLine && file.isOnTheSameLine(first, last)) { return true; } return false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (grandpa && exceptions[grandpa.type]) {··· return true; } |
✓ Negative was executed (else) | }··· var first = node.getFirstToken(); |
Branch LogicalExpression | |
✓ Was returned | if (grandpa && exceptions[grandpa.type]) { |
✓ Was returned | if (grandpa && exceptions[grandpa.type]) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptions.SingleLine && file.isOnTheSameLine(first, last)) {··· return true; } |
✓ Negative was executed (else) | }··· return false; |
Branch LogicalExpression | |
✓ Was returned | if (exceptions.SingleLine && file.isOnTheSameLine(first, last)) { |
✓ Was returned | if (exceptions.SingleLine && file.isOnTheSameLine(first, last)) { |
Function (anonymous_1010) | |
---|---|
✓ Was called | file.iterateNodesByType('BlockStatement', (function(node) {··· var endToken = file.getLastNodeToken(node); var parentElement = node.parentElement; var tokens = { next: endToken.getNextCodeToken(), token: endToken }; if (isException(node, parentElement, this.exceptions)) { return; } while (tokens.next.type !== 'EOF') { var excludeValues = excludes[parentElement.type]; if (excludeValues && excludeValues.indexOf(tokens.next.value) !== -1) { return; } if (file.isOnTheSameLine(tokens.token, tokens.next)) { endToken = tokens.next; tokens.next = tokens.next.getNextCodeToken(); continue; } if (tokens.next.type === 'Punctuator' && ( tokens.next.value === '}' || tokens.next.value === ']' || tokens.next.value === '>' || tokens.next.value === ')') ) { return; } errors.assert.linesBetween({ token: tokens.token, nextToken: tokens.next, atLeast: 2, message: 'Missing newline after block' }); return; } }).bind(this)); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isException(node, parentElement, this.exceptions)) {··· return; } |
✓ Negative was executed (else) | }··· while (tokens.next.type !== 'EOF') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (excludeValues && excludeValues.indexOf(tokens.next.value) !== -1) {··· return; } |
✓ Negative was executed (else) | }··· if (file.isOnTheSameLine(tokens.token, tokens.next)) { |
Branch LogicalExpression | |
✓ Was returned | if (excludeValues && excludeValues.indexOf(tokens.next.value) !== -1) { |
✗ Was not returned | if (excludeValues && excludeValues.indexOf(tokens.next.value) !== -1) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (file.isOnTheSameLine(tokens.token, tokens.next)) {··· endToken = tokens.next; tokens.next = tokens.next.getNextCodeToken(); continue; } |
✓ Negative was executed (else) | }··· if (tokens.next.type === 'Punctuator' && ( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
Branch LogicalExpression | |
✓ Was returned | tokens.next.value === '}' ||··· tokens.next.value === ']' || tokens.next.value === '>' || tokens.next.value === ')') |
✓ Was returned | if (tokens.next.type === 'Punctuator' && ( |
Branch LogicalExpression | |
---|---|
✓ Was returned | tokens.next.value === ')') |
✓ Was returned | tokens.next.value === '}' ||··· tokens.next.value === ']' || tokens.next.value === '>' || |
Branch LogicalExpression | |
✓ Was returned | tokens.next.value === '>' || |
✓ Was returned | tokens.next.value === '}' ||··· tokens.next.value === ']' || |
Branch LogicalExpression | |
✓ Was returned | tokens.next.value === ']' || |
✓ Was returned | tokens.next.value === '}' || |
Function (anonymous_1011) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1012) | |
---|---|
✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true, this.getOptionName() + ' option requires either a true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } if (Array.isArray(options.allExcept)) { this._exceptRequire = options.allExcept.indexOf('require') > -1; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, this.getOptionName() + ' option requires either a true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
✓ Negative was executed (else) | }··· if (Array.isArray(options.allExcept)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptRequire = options.allExcept.indexOf('require') > -1; } |
✗ Negative was not executed (else) | }··· }, |
Function (anonymous_1013) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesAfterUseStrict'; }, |
Function (anonymous_1014) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptRequire = this._exceptRequire; file.iterateNodesByType('Directive', function(node) { var literal = node.value; if (literal.value !== 'use strict') { return; } var endOfNode = file.getLastNodeToken(node); if (exceptRequire) { var requireToken = file.findNextToken(endOfNode, 'Identifier', 'require'); if (requireToken && node.getLoc().start.line + 1 === requireToken.getLoc().start.line) { // Ensure the detected require is the first declaration of this line var keywordToken = file.getNextToken(endOfNode, { includeComments: true }); var identifierToken = file.getNextToken(file.getLastNodeToken(keywordToken), { includeComments: true }); var punctuatorToken = file.getNextToken(file.getLastNodeToken(identifierToken), { includeComments: true }); requireToken = file.getNextToken(file.getLastNodeToken(punctuatorToken), { includeComments: true }); if ( keywordToken.type === 'Keyword' && identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && requireToken.value === 'require' ) { return; } } } var nextToken = file.getNextToken(endOfNode, { includeComments: true }); errors.assert.linesBetween({ atLeast: 2, token: endOfNode, nextToken: nextToken }); }); } |
Function (anonymous_1015) | |
---|---|
✓ Was called | file.iterateNodesByType('Directive', function(node) {··· var literal = node.value; if (literal.value !== 'use strict') { return; } var endOfNode = file.getLastNodeToken(node); if (exceptRequire) { var requireToken = file.findNextToken(endOfNode, 'Identifier', 'require'); if (requireToken && node.getLoc().start.line + 1 === requireToken.getLoc().start.line) { // Ensure the detected require is the first declaration of this line var keywordToken = file.getNextToken(endOfNode, { includeComments: true }); var identifierToken = file.getNextToken(file.getLastNodeToken(keywordToken), { includeComments: true }); var punctuatorToken = file.getNextToken(file.getLastNodeToken(identifierToken), { includeComments: true }); requireToken = file.getNextToken(file.getLastNodeToken(punctuatorToken), { includeComments: true }); if ( keywordToken.type === 'Keyword' && identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && requireToken.value === 'require' ) { return; } } } var nextToken = file.getNextToken(endOfNode, { includeComments: true }); errors.assert.linesBetween({ atLeast: 2, token: endOfNode, nextToken: nextToken }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (literal.value !== 'use strict') {··· return; } |
✓ Negative was executed (else) | }··· var endOfNode = file.getLastNodeToken(node); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptRequire) {··· var requireToken = file.findNextToken(endOfNode, 'Identifier', 'require'); if (requireToken && node.getLoc().start.line + 1 === requireToken.getLoc().start.line) { // Ensure the detected require is the first declaration of this line var keywordToken = file.getNextToken(endOfNode, { includeComments: true }); var identifierToken = file.getNextToken(file.getLastNodeToken(keywordToken), { includeComments: true }); var punctuatorToken = file.getNextToken(file.getLastNodeToken(identifierToken), { includeComments: true }); requireToken = file.getNextToken(file.getLastNodeToken(punctuatorToken), { includeComments: true }); if ( keywordToken.type === 'Keyword' && identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && requireToken.value === 'require' ) { return; } } } |
✓ Negative was executed (else) | }··· var nextToken = file.getNextToken(endOfNode, { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (requireToken && node.getLoc().start.line + 1 === requireToken.getLoc().start.line) {··· // Ensure the detected require is the first declaration of this line var keywordToken = file.getNextToken(endOfNode, { includeComments: true }); var identifierToken = file.getNextToken(file.getLastNodeToken(keywordToken), { includeComments: true }); var punctuatorToken = file.getNextToken(file.getLastNodeToken(identifierToken), { includeComments: true }); requireToken = file.getNextToken(file.getLastNodeToken(punctuatorToken), { includeComments: true }); if ( keywordToken.type === 'Keyword' && identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && requireToken.value === 'require' ) { return; } } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (requireToken && node.getLoc().start.line + 1 === requireToken.getLoc().start.line) { |
✓ Was returned | if (requireToken && node.getLoc().start.line + 1 === requireToken.getLoc().start.line) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
---|---|
✓ Was returned | requireToken.value === 'require' |
✓ Was returned | keywordToken.type === 'Keyword' &&··· identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && requireToken.type === 'Identifier' && |
Branch LogicalExpression | |
✓ Was returned | requireToken.type === 'Identifier' && |
✗ Was not returned | keywordToken.type === 'Keyword' &&··· identifierToken.type === 'Identifier' && punctuatorToken.type === 'Punctuator' && |
Branch LogicalExpression | |
✓ Was returned | punctuatorToken.type === 'Punctuator' && |
✗ Was not returned | keywordToken.type === 'Keyword' &&··· identifierToken.type === 'Identifier' && |
Branch LogicalExpression | |
✓ Was returned | identifierToken.type === 'Identifier' && |
✗ Was not returned | keywordToken.type === 'Keyword' && |
Function (anonymous_1016) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1017) | |
---|---|
✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1018) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesBeforeExport'; }, |
Function (anonymous_1019) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('AssignmentExpression', function(node) { var left = node.left; var greatGrandpa = node.parentElement.parentElement; if (!( left.object && left.object.name === 'module' && left.property && left.property.name === 'exports')) { return; } // module.exports is in a block and is the only statement. if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) { return; } var firstToken = node.getFirstToken(); var prevToken = file.getPrevToken(firstToken); errors.assert.linesBetween({ atLeast: 2, token: prevToken, nextToken: firstToken, message: 'Missing newline before export' }); }); } |
Function (anonymous_1020) | |
---|---|
✓ Was called | file.iterateNodesByType('AssignmentExpression', function(node) {··· var left = node.left; var greatGrandpa = node.parentElement.parentElement; if (!( left.object && left.object.name === 'module' && left.property && left.property.name === 'exports')) { return; } // module.exports is in a block and is the only statement. if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) { return; } var firstToken = node.getFirstToken(); var prevToken = file.getPrevToken(firstToken); errors.assert.linesBetween({ atLeast: 2, token: prevToken, nextToken: firstToken, message: 'Missing newline before export' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | left.property.name === 'exports')) {··· return; } |
✓ Negative was executed (else) | }··· // module.exports is in a block and is the only statement. |
Branch LogicalExpression | |
---|---|
✓ Was returned | left.property.name === 'exports')) { |
✓ Was returned | left.object &&··· left.object.name === 'module' && left.property && |
Branch LogicalExpression | |
✓ Was returned | left.property && |
✓ Was returned | left.object &&··· left.object.name === 'module' && |
Branch LogicalExpression | |
✓ Was returned | left.object.name === 'module' && |
✗ Was not returned | left.object && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) {··· return; } |
✓ Negative was executed (else) | }··· var firstToken = node.getFirstToken(); |
Branch LogicalExpression | |
✓ Was returned | if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) { |
✓ Was returned | if (greatGrandpa.type === 'BlockStatement' && greatGrandpa.body.length === 1) { |
Function (anonymous_1021) | |
---|---|
✓ Was called | module.exports = function() { }; |
Function (anonymous_1022) | |
---|---|
✓ Was called | configure: function(keywords) {··· assert(Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value'); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | assert(Array.isArray(keywords) || keywords === true, |
✓ Was returned | assert(Array.isArray(keywords) || keywords === true, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
✓ Negative was executed (else) | }··· this._keywords = keywords; |
Function (anonymous_1023) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requirePaddingNewlinesBeforeKeywords'; }, |
Function (anonymous_1024) | |
---|---|
✓ Was called | check: function(file, errors) {··· var excludedTokens = [':', ',', '(', '=']; var specialCases = { 'if': 'else' }; file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var prevToken = token.getPreviousCodeToken(); if (!prevToken) { return; } // Handle special cases listed in specialCasesToken array if (prevToken.value === specialCases[token.value]) { return; } // allow returning a function if (prevToken.value === 'return' && token.value === 'function') { return; } // Do not report `do...while` statements if (token.value === 'while' && token.parentElement.type === 'DoWhileStatement') { return; } // Handle excludedTokens if (excludedTokens.indexOf(prevToken.value) > -1) { return; } // Handle all other cases // The { character is there to handle the case of a matching token which happens to be the first // statement in a block // The ) character is there to handle the case of `if (...) matchingKeyword` in which case // requiring padding would break the statement if (prevToken.value !== '{' && prevToken.value !== ')') { errors.assert.linesBetween({ token: prevToken, nextToken: token, atLeast: 2, message: 'Keyword `' + token.value + '` should have an empty line above it' }); } }); } |
Function (anonymous_1025) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var prevToken = token.getPreviousCodeToken(); if (!prevToken) { return; } // Handle special cases listed in specialCasesToken array if (prevToken.value === specialCases[token.value]) { return; } // allow returning a function if (prevToken.value === 'return' && token.value === 'function') { return; } // Do not report `do...while` statements if (token.value === 'while' && token.parentElement.type === 'DoWhileStatement') { return; } // Handle excludedTokens if (excludedTokens.indexOf(prevToken.value) > -1) { return; } // Handle all other cases // The { character is there to handle the case of a matching token which happens to be the first // statement in a block // The ) character is there to handle the case of `if (...) matchingKeyword` in which case // requiring padding would break the statement if (prevToken.value !== '{' && prevToken.value !== ')') { errors.assert.linesBetween({ token: prevToken, nextToken: token, atLeast: 2, message: 'Keyword `' + token.value + '` should have an empty line above it' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!prevToken) {··· return; } |
✓ Negative was executed (else) | }··· // Handle special cases listed in specialCasesToken array |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.value === specialCases[token.value]) {··· return; } |
✓ Negative was executed (else) | }··· // allow returning a function |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.value === 'return' && token.value === 'function') {··· return; } |
✓ Negative was executed (else) | }··· // Do not report `do...while` statements |
Branch LogicalExpression | |
✓ Was returned | if (prevToken.value === 'return' && token.value === 'function') { |
✓ Was returned | if (prevToken.value === 'return' && token.value === 'function') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (token.value === 'while' && token.parentElement.type === 'DoWhileStatement') {··· return; } |
✓ Negative was executed (else) | }··· // Handle excludedTokens |
Branch LogicalExpression | |
✓ Was returned | if (token.value === 'while' && token.parentElement.type === 'DoWhileStatement') { |
✓ Was returned | if (token.value === 'while' && token.parentElement.type === 'DoWhileStatement') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (excludedTokens.indexOf(prevToken.value) > -1) {··· return; } |
✓ Negative was executed (else) | }··· // Handle all other cases |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.value !== '{' && prevToken.value !== ')') {··· errors.assert.linesBetween({ token: prevToken, nextToken: token, atLeast: 2, message: 'Keyword `' + token.value + '` should have an empty line above it' }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (prevToken.value !== '{' && prevToken.value !== ')') { |
✓ Was returned | if (prevToken.value !== '{' && prevToken.value !== ')') { |
Function (anonymous_1026) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1027) | |
---|---|
✓ Was called | configure: function(value) {··· this._allowFirstAfterCurly = false; if (typeof value === 'object') { assert(typeof value.allExcept === 'string' && value.allExcept === 'firstAfterCurly', this.getOptionName() + ' option requires the "allExcept" ' + 'property to equal "firstAfterCurly"'); this._allowFirstAfterCurly = true; } else { assert(value === true, this.getOptionName() + ' option requires true value or object' ); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof value === 'object') {··· assert(typeof value.allExcept === 'string' && value.allExcept === 'firstAfterCurly', this.getOptionName() + ' option requires the "allExcept" ' + 'property to equal "firstAfterCurly"'); this._allowFirstAfterCurly = true; } else { |
✓ Negative was executed (else) | } else {··· assert(value === true, this.getOptionName() + ' option requires true value or object' ); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | assert(typeof value.allExcept === 'string' && value.allExcept === 'firstAfterCurly', |
✓ Was returned | assert(typeof value.allExcept === 'string' && value.allExcept === 'firstAfterCurly', |
Function (anonymous_1028) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesBeforeLineComments'; }, |
Function (anonymous_1029) | |
---|---|
✓ Was called | check: function(file, errors) {··· var allowFirstAfterCurly = this._allowFirstAfterCurly; file.iterateTokensByType('CommentLine', function(comment) { if (comment.getLoc().start.line === 1) { return; } var firstToken = file.getFirstTokenOnLineWith(comment); // Should not consider code and comment on the same line (#1194) if (firstToken !== null && firstToken.type !== 'EOF') { return; } var prevToken = file.getPrevToken(comment, {includeComments: true}); if (!prevToken || prevToken.type === 'CommentLine') { return; } if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { return; } errors.assert.linesBetween({ token: prevToken, nextToken: comment, atLeast: 2, message: 'Line comments must be preceded with a blank line' }); }); } |
Function (anonymous_1030) | |
---|---|
✓ Was called | file.iterateTokensByType('CommentLine', function(comment) {··· if (comment.getLoc().start.line === 1) { return; } var firstToken = file.getFirstTokenOnLineWith(comment); // Should not consider code and comment on the same line (#1194) if (firstToken !== null && firstToken.type !== 'EOF') { return; } var prevToken = file.getPrevToken(comment, {includeComments: true}); if (!prevToken || prevToken.type === 'CommentLine') { return; } if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { return; } errors.assert.linesBetween({ token: prevToken, nextToken: comment, atLeast: 2, message: 'Line comments must be preceded with a blank line' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (comment.getLoc().start.line === 1) {··· return; } |
✓ Negative was executed (else) | }··· var firstToken = file.getFirstTokenOnLineWith(comment); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (firstToken !== null && firstToken.type !== 'EOF') {··· return; } |
✓ Negative was executed (else) | }··· var prevToken = file.getPrevToken(comment, {includeComments: true}); |
Branch LogicalExpression | |
✓ Was returned | if (firstToken !== null && firstToken.type !== 'EOF') { |
✓ Was returned | if (firstToken !== null && firstToken.type !== 'EOF') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!prevToken || prevToken.type === 'CommentLine') {··· return; } |
✓ Negative was executed (else) | }··· if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
Branch LogicalExpression | |
✓ Was returned | if (!prevToken || prevToken.type === 'CommentLine') { |
✓ Was returned | if (!prevToken || prevToken.type === 'CommentLine') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.linesBetween({ |
Branch LogicalExpression | |
✓ Was returned | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
✓ Was returned | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
Branch LogicalExpression | |
✓ Was returned | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
✓ Was returned | if (allowFirstAfterCurly && prevToken.type === 'Punctuator' && prevToken.value === '{') { |
Function (anonymous_1031) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1032) | |
---|---|
✓ Was called | configure: function(options) {··· var optionName = this.getOptionName(); assert( options === true || typeof options === 'number' || typeof options === 'object', optionName + ' option requires the value true, an Integer or an object' ); this._checkOpen = true; this._checkClose = true; this._minLines = 0; if (typeof options === 'object') { assert(options.allExcept || options.open || options.close, optionName + 'option requires either "open", "close", "allExcept"'); if (options.allExcept) { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } if (options.open || options.close) { assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } } else if (typeof options === 'number') { this._minLines = options; } else { assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || typeof options === 'number' || typeof options === 'object', |
✓ Was returned | options === true || typeof options === 'number' || typeof options === 'object', |
Branch LogicalExpression | |
✓ Was returned | options === true || typeof options === 'number' || typeof options === 'object', |
✓ Was returned | options === true || typeof options === 'number' || typeof options === 'object', |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'object') {··· assert(options.allExcept || options.open || options.close, optionName + 'option requires either "open", "close", "allExcept"'); if (options.allExcept) { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } if (options.open || options.close) { assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } } else if (typeof options === 'number') { |
✓ Negative was executed (else) | } else if (typeof options === 'number') {··· this._minLines = options; } else { assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | assert(options.allExcept || options.open || options.close, |
✓ Was returned | assert(options.allExcept || options.open || options.close, |
Branch LogicalExpression | |
✓ Was returned | assert(options.allExcept || options.open || options.close, |
✓ Was returned | assert(options.allExcept || options.open || options.close, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.allExcept) {··· assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" to have at least one ' + 'item or be set to `true`'); this._exceptConditionals = options.allExcept.indexOf('conditionals') > -1; this._exceptFunctions = options.allExcept.indexOf('functions') > -1; } |
✓ Negative was executed (else) | }··· if (options.open || options.close) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options.open || options.close) {··· assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', this.getOptionName() + ' option requires the "open" and "close" ' + 'properties to be booleans'); this._checkOpen = options.open; this._checkClose = options.close; } |
✓ Negative was executed (else) | }··· } else if (typeof options === 'number') { |
Branch LogicalExpression | |
✓ Was returned | if (options.open || options.close) { |
✓ Was returned | if (options.open || options.close) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', |
✓ Was returned | assert(typeof options.open === 'boolean' && typeof options.close === 'boolean', |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (typeof options === 'number') {··· this._minLines = options; } else { |
✓ Negative was executed (else) | } else {··· assert(options === true, this.getOptionName() + ' option requires either a true value, or an object'); } |
Function (anonymous_1033) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requirePaddingNewlinesInBlocks'; }, |
Function (anonymous_1034) | |
---|---|
✓ Was called | check: function(file, errors) {··· var minLines = this._minLines; var exceptConditionals = this._exceptConditionals; var exceptFunctions = this._exceptFunctions; var checkOpen = this._checkOpen; var checkClose = this._checkClose; file.iterateNodesByType('BlockStatement', function(node) { var openingBracket; var closingBracket; if (node.body.length <= minLines) { return; } if (exceptConditionals && node.parentElement.type === 'IfStatement' || exceptFunctions && (node.parentElement.type === 'FunctionExpression' || node.parentElement.type === 'FunctionDeclaration')) { return; } if (checkOpen === true) { openingBracket = node.getFirstToken(); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atLeast: 2, message: 'Expected a padding newline after opening curly brace' }); } if (checkClose === true) { closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atLeast: 2, message: 'Expected a padding newline before closing curly brace' }); } }); } |
Function (anonymous_1035) | |
---|---|
✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var openingBracket; var closingBracket; if (node.body.length <= minLines) { return; } if (exceptConditionals && node.parentElement.type === 'IfStatement' || exceptFunctions && (node.parentElement.type === 'FunctionExpression' || node.parentElement.type === 'FunctionDeclaration')) { return; } if (checkOpen === true) { openingBracket = node.getFirstToken(); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atLeast: 2, message: 'Expected a padding newline after opening curly brace' }); } if (checkClose === true) { closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atLeast: 2, message: 'Expected a padding newline before closing curly brace' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.body.length <= minLines) {··· return; } |
✓ Negative was executed (else) | }··· if (exceptConditionals && node.parentElement.type === 'IfStatement' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.parentElement.type === 'FunctionDeclaration')) {··· return; } |
✓ Negative was executed (else) | }··· if (checkOpen === true) { |
Branch LogicalExpression | |
✓ Was returned | exceptFunctions && (node.parentElement.type === 'FunctionExpression' ||··· node.parentElement.type === 'FunctionDeclaration')) { |
✓ Was returned | if (exceptConditionals && node.parentElement.type === 'IfStatement' || |
Branch LogicalExpression | |
✓ Was returned | if (exceptConditionals && node.parentElement.type === 'IfStatement' || |
✓ Was returned | if (exceptConditionals && node.parentElement.type === 'IfStatement' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | exceptFunctions && (node.parentElement.type === 'FunctionExpression' ||··· node.parentElement.type === 'FunctionDeclaration')) { |
✓ Was returned | exceptFunctions && (node.parentElement.type === 'FunctionExpression' || |
Branch LogicalExpression | |
✓ Was returned | node.parentElement.type === 'FunctionDeclaration')) { |
✓ Was returned | exceptFunctions && (node.parentElement.type === 'FunctionExpression' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (checkOpen === true) {··· openingBracket = node.getFirstToken(); errors.assert.linesBetween({ token: openingBracket, nextToken: file.getNextToken(openingBracket, {includeComments: true}), atLeast: 2, message: 'Expected a padding newline after opening curly brace' }); } |
✓ Negative was executed (else) | }··· if (checkClose === true) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (checkClose === true) {··· closingBracket = file.getLastNodeToken(node); errors.assert.linesBetween({ token: file.getPrevToken(closingBracket, {includeComments: true}), nextToken: closingBracket, atLeast: 2, message: 'Expected a padding newline before closing curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1036) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1037) | |
---|---|
✓ Was called | configure: function(value) {··· assert( value === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1038) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requirePaddingNewLinesInObjects'; }, |
Function (anonymous_1039) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket); if (nextToken.type === 'Punctuator' && nextToken.value === '}') { return; } errors.assert.differentLine({ token: openingBracket, nextToken: nextToken, message: 'Missing newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); errors.assert.differentLine({ token: file.getPrevToken(closingBracket), nextToken: closingBracket, message: 'Missing newline before closing curly brace' }); }); } |
Function (anonymous_1040) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket); if (nextToken.type === 'Punctuator' && nextToken.value === '}') { return; } errors.assert.differentLine({ token: openingBracket, nextToken: nextToken, message: 'Missing newline after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); errors.assert.differentLine({ token: file.getPrevToken(closingBracket), nextToken: closingBracket, message: 'Missing newline before closing curly brace' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.type === 'Punctuator' && nextToken.value === '}') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.differentLine({ |
Branch LogicalExpression | |
✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === '}') { |
✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === '}') { |
Function (anonymous_1041) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1042) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1043) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireParenthesesAroundArrowParam'; }, |
Function (anonymous_1044) | |
---|---|
✓ Was called | check: function(file, errors) {··· function isWrapped(node) { var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } file.iterateNodesByType('ArrowFunctionExpression', function(node) { var params = node.params; var firstParam = params[0]; if (params.length === 1 && !isWrapped(firstParam)) { errors.add( 'Wrap arrow function expressions in parentheses', firstParam ); } }); } |
Function isWrapped | |
---|---|
✓ Was called | function isWrapped(node) {··· var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
✗ Negative was not returned (: ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
Function (anonymous_1046) | |
---|---|
✓ Was called | file.iterateNodesByType('ArrowFunctionExpression', function(node) {··· var params = node.params; var firstParam = params[0]; if (params.length === 1 && !isWrapped(firstParam)) { errors.add( 'Wrap arrow function expressions in parentheses', firstParam ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (params.length === 1 && !isWrapped(firstParam)) {··· errors.add( 'Wrap arrow function expressions in parentheses', firstParam ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (params.length === 1 && !isWrapped(firstParam)) { |
✓ Was returned | if (params.length === 1 && !isWrapped(firstParam)) { |
Function (anonymous_1047) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1048) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1049) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireParenthesesAroundIIFE'; }, |
Function (anonymous_1050) | |
---|---|
✓ Was called | check: function(file, errors) {··· function isWrapped(node) { var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } file.iterateNodesByType('CallExpression', function(node) { var inner = utils.getFunctionNodeFromIIFE(node); if (inner && !isWrapped(inner) && !isWrapped(node)) { errors.add( 'Wrap immediately invoked function expressions in parentheses', node ); } }); } |
Function isWrapped | |
---|---|
✓ Was called | function isWrapped(node) {··· var openParensToken = file.getPrevToken(file.getFirstNodeToken(node)); var closingParensToken = file.getNextToken(file.getLastNodeToken(node)); var closingTokenValue = closingParensToken ? closingParensToken.value : ''; return openParensToken.value + closingTokenValue === '()'; } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
✗ Negative was not returned (: ...) | var closingTokenValue = closingParensToken ? closingParensToken.value : ''; |
Function (anonymous_1052) | |
---|---|
✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· var inner = utils.getFunctionNodeFromIIFE(node); if (inner && !isWrapped(inner) && !isWrapped(node)) { errors.add( 'Wrap immediately invoked function expressions in parentheses', node ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (inner && !isWrapped(inner) && !isWrapped(node)) {··· errors.add( 'Wrap immediately invoked function expressions in parentheses', node ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (inner && !isWrapped(inner) && !isWrapped(node)) { |
✓ Was returned | if (inner && !isWrapped(inner) && !isWrapped(node)) { |
Branch LogicalExpression | |
✓ Was returned | if (inner && !isWrapped(inner) && !isWrapped(node)) { |
✓ Was returned | if (inner && !isWrapped(inner) && !isWrapped(node)) { |
Function (anonymous_1053) | |
---|---|
✓ Was called | module.exports = function() { }; |
Function (anonymous_1054) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1055) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireQuotedKeysInObjects'; }, |
Function (anonymous_1056) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(property) { if ( property.type === 'ObjectMethod' && (property.kind === 'get' || property.kind === 'set') ) { return; } if (property.shorthand || property.method || node.type === 'SpreadProperty') { return; } var key = property.key; if (key && !(typeof key.value === 'string' && key.type.indexOf('Literal') > -1)) { errors.cast({ message: 'Object key without surrounding quotes', element: property.firstChild }); } }); }); }, |
Function (anonymous_1057) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(property) { if ( property.type === 'ObjectMethod' && (property.kind === 'get' || property.kind === 'set') ) { return; } if (property.shorthand || property.method || node.type === 'SpreadProperty') { return; } var key = property.key; if (key && !(typeof key.value === 'string' && key.type.indexOf('Literal') > -1)) { errors.cast({ message: 'Object key without surrounding quotes', element: property.firstChild }); } }); }); |
Function (anonymous_1058) | |
---|---|
✓ Was called | node.properties.forEach(function(property) {··· if ( property.type === 'ObjectMethod' && (property.kind === 'get' || property.kind === 'set') ) { return; } if (property.shorthand || property.method || node.type === 'SpreadProperty') { return; } var key = property.key; if (key && !(typeof key.value === 'string' && key.type.indexOf('Literal') > -1)) { errors.cast({ message: 'Object key without surrounding quotes', element: property.firstChild }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· if (property.shorthand || property.method || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (property.kind === 'get' || property.kind === 'set') |
✓ Was returned | property.type === 'ObjectMethod' && |
Branch LogicalExpression | |
---|---|
✓ Was returned | (property.kind === 'get' || property.kind === 'set') |
✓ Was returned | (property.kind === 'get' || property.kind === 'set') |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.type === 'SpreadProperty') {··· return; } |
✓ Negative was executed (else) | }··· var key = property.key; |
Branch LogicalExpression | |
✓ Was returned | node.type === 'SpreadProperty') { |
✓ Was returned | if (property.shorthand || property.method || |
Branch LogicalExpression | |
✓ Was returned | if (property.shorthand || property.method || |
✓ Was returned | if (property.shorthand || property.method || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (key && !(typeof key.value === 'string' && key.type.indexOf('Literal') > -1)) {··· errors.cast({ message: 'Object key without surrounding quotes', element: property.firstChild }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (key && !(typeof key.value === 'string' && key.type.indexOf('Literal') > -1)) { |
✓ Was returned | if (key && !(typeof key.value === 'string' && key.type.indexOf('Literal') > -1)) { |
Branch LogicalExpression | |
✓ Was returned | if (key && !(typeof key.value === 'string' && key.type.indexOf('Literal') > -1)) { |
✓ Was returned | if (key && !(typeof key.value === 'string' && key.type.indexOf('Literal') > -1)) { |
Function (anonymous_1059) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var element = error.element.firstChild; var newElem = new cst.Token(element.type, '"' + element.getSourceCode() + '"'); element.parentElement.replaceChild( newElem, element ); } |
Function (anonymous_1060) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1061) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1062) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSemicolons'; }, |
Function (anonymous_1063) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType([ 'VariableDeclaration', 'ImportDeclaration', 'ExportDeclaration', 'ExportDefaultDeclaration', 'ExportNamedDeclaration', 'ExpressionStatement', 'DoWhileStatement', 'ReturnStatement', 'ThrowStatement', 'BreakStatement', 'ContinueStatement', 'DebuggerStatement', 'ClassProperty' ], function(node) { // ignore variable declaration inside for and for-in if (node.type === 'VariableDeclaration') { if ((node.parentElement.type === 'ForInStatement' && node.parentElement.left === node) || (node.parentElement.type === 'ForOfStatement' && node.parentElement.left === node) || (node.parentElement.type === 'ForStatement' && node.parentElement.init === node)) { return; } } // don't require semicolon for class and function exports if (node.type === 'ExportDefaultDeclaration' || node.type === 'ExportNamedDeclaration') { if (node.declaration) { if (node.declaration.type === 'ClassDeclaration' || node.declaration.type === 'FunctionDeclaration') { return; } } } // get last token inside node var lastToken = file.getLastNodeToken(node); var checkToken = lastToken; // if last token is not a semicolon punctuator, try to get next token in file if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { checkToken = file.getNextToken(checkToken); } // check token is semicolon if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { var entity = lastToken || node; errors.cast({ message: 'Missing semicolon after statement', element: entity }); } }); }, |
Function (anonymous_1064) | |
---|---|
✓ Was called | ], function(node) {··· // ignore variable declaration inside for and for-in if (node.type === 'VariableDeclaration') { if ((node.parentElement.type === 'ForInStatement' && node.parentElement.left === node) || (node.parentElement.type === 'ForOfStatement' && node.parentElement.left === node) || (node.parentElement.type === 'ForStatement' && node.parentElement.init === node)) { return; } } // don't require semicolon for class and function exports if (node.type === 'ExportDefaultDeclaration' || node.type === 'ExportNamedDeclaration') { if (node.declaration) { if (node.declaration.type === 'ClassDeclaration' || node.declaration.type === 'FunctionDeclaration') { return; } } } // get last token inside node var lastToken = file.getLastNodeToken(node); var checkToken = lastToken; // if last token is not a semicolon punctuator, try to get next token in file if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { checkToken = file.getNextToken(checkToken); } // check token is semicolon if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { var entity = lastToken || node; errors.cast({ message: 'Missing semicolon after statement', element: entity }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'VariableDeclaration') {··· if ((node.parentElement.type === 'ForInStatement' && node.parentElement.left === node) || (node.parentElement.type === 'ForOfStatement' && node.parentElement.left === node) || (node.parentElement.type === 'ForStatement' && node.parentElement.init === node)) { return; } } |
✓ Negative was executed (else) | }··· // don't require semicolon for class and function exports |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | (node.parentElement.type === 'ForStatement' && node.parentElement.init === node)) {··· return; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | (node.parentElement.type === 'ForStatement' && node.parentElement.init === node)) { |
✓ Was returned | if ((node.parentElement.type === 'ForInStatement' && node.parentElement.left === node) ||··· (node.parentElement.type === 'ForOfStatement' && node.parentElement.left === node) || |
Branch LogicalExpression | |
✓ Was returned | (node.parentElement.type === 'ForOfStatement' && node.parentElement.left === node) || |
✓ Was returned | if ((node.parentElement.type === 'ForInStatement' && node.parentElement.left === node) || |
Branch LogicalExpression | |
✓ Was returned | if ((node.parentElement.type === 'ForInStatement' && node.parentElement.left === node) || |
✓ Was returned | if ((node.parentElement.type === 'ForInStatement' && node.parentElement.left === node) || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.parentElement.type === 'ForOfStatement' && node.parentElement.left === node) || |
✓ Was returned | (node.parentElement.type === 'ForOfStatement' && node.parentElement.left === node) || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.parentElement.type === 'ForStatement' && node.parentElement.init === node)) { |
✓ Was returned | (node.parentElement.type === 'ForStatement' && node.parentElement.init === node)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.type === 'ExportNamedDeclaration') {··· if (node.declaration) { if (node.declaration.type === 'ClassDeclaration' || node.declaration.type === 'FunctionDeclaration') { return; } } } |
✓ Negative was executed (else) | }··· // get last token inside node |
Branch LogicalExpression | |
✓ Was returned | node.type === 'ExportNamedDeclaration') { |
✓ Was returned | if (node.type === 'ExportDefaultDeclaration' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.declaration) {··· if (node.declaration.type === 'ClassDeclaration' || node.declaration.type === 'FunctionDeclaration') { return; } } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | node.declaration.type === 'FunctionDeclaration') {··· return; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | node.declaration.type === 'FunctionDeclaration') { |
✓ Was returned | if (node.declaration.type === 'ClassDeclaration' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) {··· checkToken = file.getNextToken(checkToken); } |
✓ Negative was executed (else) | }··· // check token is semicolon |
Branch LogicalExpression | |
✓ Was returned | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { |
✗ Was not returned | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { |
Branch LogicalExpression | |
✓ Was returned | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { |
✓ Was returned | if (checkToken && (checkToken.type !== 'Punctuator' || checkToken.value !== ';')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') {··· var entity = lastToken || node; errors.cast({ message: 'Missing semicolon after statement', element: entity }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { |
✓ Was returned | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { |
Branch LogicalExpression | |
✓ Was returned | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { |
✗ Was not returned | if (!checkToken || checkToken.type !== 'Punctuator' || checkToken.value !== ';') { |
Branch LogicalExpression | |
---|---|
✗ Was not returned | var entity = lastToken || node; |
✓ Was returned | var entity = lastToken || node; |
Function (anonymous_1065) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var element = error.element; var semicolon = new cst.Token('Punctuator', ';'); while (element) { try { element.appendChild(semicolon); break; } catch (e) {} element = element.parentElement; } } |
Function (anonymous_1066) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1067) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1068) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireShorthandArrowFunctions'; }, |
Function (anonymous_1069) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ArrowFunctionExpression', function(node) { var body = node.body; if (body.type === 'BlockStatement' && body.body.length === 1 && body.body[0].type === 'ReturnStatement') { errors.add( 'Use the shorthand arrow function form', node.body ); } }); } |
Function (anonymous_1070) | |
---|---|
✓ Was called | file.iterateNodesByType('ArrowFunctionExpression', function(node) {··· var body = node.body; if (body.type === 'BlockStatement' && body.body.length === 1 && body.body[0].type === 'ReturnStatement') { errors.add( 'Use the shorthand arrow function form', node.body ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | body.body[0].type === 'ReturnStatement') {··· errors.add( 'Use the shorthand arrow function form', node.body ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | body.body[0].type === 'ReturnStatement') { |
✓ Was returned | if (body.type === 'BlockStatement' &&··· body.body.length === 1 && |
Branch LogicalExpression | |
✓ Was returned | body.body.length === 1 && |
✓ Was returned | if (body.type === 'BlockStatement' && |
Function (anonymous_1071) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1072) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = allOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = allOperators; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_1073) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterBinaryOperators'; }, |
Function (anonymous_1074) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; // Comma if (operators[',']) { file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should not stick to following expression' }); }); } // For everything else file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'VariableDeclarator', 'LogicalExpression'], function(node) { var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var nextToken = file.getNextToken(operatorToken); if (operators[operator]) { errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should not stick to following expression' }); } } ); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[',']) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should not stick to following expression' }); }); } |
✓ Negative was executed (else) | }··· // For everything else |
Function (anonymous_1075) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Operator , should not stick to following expression' }); }); |
Function (anonymous_1076) | |
---|---|
✓ Was called | function(node) {··· var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var nextToken = file.getNextToken(operatorToken); if (operators[operator]) { errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should not stick to following expression' }); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'VariableDeclarator') {··· expression = node.init; operator = '='; } else { |
✓ Negative was executed (else) | } else {··· operator = node.operator; expression = node.right; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (expression === null) {··· return; } |
✓ Negative was executed (else) | }··· var operatorToken = file.findPrevOperatorToken( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[operator]) {··· errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + operator + ' should not stick to following expression' }); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_1077) | |
---|---|
✓ Was called | module.exports = function() {··· }; |
Function (anonymous_1078) | |
---|---|
✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } assert( Array.isArray(options.allExcept), ' property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); this._exceptTrailingCommas = options.allExcept.indexOf('trailing') >= 0; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, this.getOptionName() + ' option requires true value or an object' ); var _options = {allExcept: []}; return this.configure(_options); } |
✓ Negative was executed (else) | }··· assert( |
Function (anonymous_1079) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterComma'; }, |
Function (anonymous_1080) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptTrailingCommas = this._exceptTrailingCommas; file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) { return; } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Space required after comma' }); }); } |
Function (anonymous_1081) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) { return; } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Space required after comma' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Branch LogicalExpression | |
✓ Was returned | if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) { |
✓ Was returned | if (exceptTrailingCommas && [']', '}'].indexOf(file.getNextToken(token).value) >= 0) { |
Function (anonymous_1082) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1083) | |
---|---|
✓ Was called | configure: function(keywords) {··· assert( Array.isArray(keywords) || keywords === true, this.getOptionName() + ' option requires array or true value'); if (keywords === true) { keywords = defaultKeywords; } this._keywords = keywords; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(keywords) || keywords === true, |
✓ Was returned | Array.isArray(keywords) || keywords === true, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (keywords === true) {··· keywords = defaultKeywords; } |
✓ Negative was executed (else) | }··· this._keywords = keywords; |
Function (anonymous_1084) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterKeywords'; }, |
Function (anonymous_1085) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); if (nextToken.type === 'Punctuator' && nextToken.value === ';') { return; } errors.assert.spacesBetween({ token: token, nextToken: nextToken, exactly: 1, message: 'One space required after "' + token.value + '" keyword' }); }); } |
Function (anonymous_1086) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); if (nextToken.type === 'Punctuator' && nextToken.value === ';') { return; } errors.assert.spacesBetween({ token: token, nextToken: nextToken, exactly: 1, message: 'One space required after "' + token.value + '" keyword' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.type === 'Punctuator' && nextToken.value === ';') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
Branch LogicalExpression | |
✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === ';') { |
✓ Was returned | if (nextToken.type === 'Punctuator' && nextToken.value === ';') { |
Function (anonymous_1087) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1088) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || options === 'allowSlash' || typeof options === 'object', this.getOptionName() + ' option requires a true value ' + 'or an object with String[] `allExcept` property' ); // verify first item in `allExcept` property in object (if it's an object) assert( typeof options !== 'object' || Array.isArray(options.allExcept) && typeof options.allExcept[0] === 'string', 'Property `allExcept` in ' + this.getOptionName() + ' should be an array of strings' ); // don't check triple slashed comments, microsoft js doc convention. see #593 // exceptions. see #592 // need to drop allowSlash support in 2.0. Fixes #697 this._allExcept = options === 'allowSlash' ? ['/'] : options.allExcept || []; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof options === 'object', |
✓ Was returned | options === true ||··· options === 'allowSlash' || |
Branch LogicalExpression | |
✓ Was returned | options === 'allowSlash' || |
✓ Was returned | options === true || |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(options.allExcept) &&··· typeof options.allExcept[0] === 'string', |
✓ Was returned | typeof options !== 'object' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof options.allExcept[0] === 'string', |
✗ Was not returned | Array.isArray(options.allExcept) && |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | this._allExcept = options === 'allowSlash' ? ['/'] : |
✓ Negative was returned (: ...) | options.allExcept || []; |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.allExcept || []; |
✓ Was returned | options.allExcept || []; |
Function (anonymous_1089) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterLineComment'; }, |
Function (anonymous_1090) | |
---|---|
✓ Was called | check: function(file, errors) {··· var allExcept = this._allExcept; file.iterateTokensByType('CommentLine', function(comment) { var value = comment.value; // cutout exceptions allExcept.forEach(function(el) { if (value.indexOf(el) === 0) { value = value.substr(el.length); } }); if (value.length === 0) { return; } if (value[0] !== ' ') { errors.add('Missing space after line comment', comment); } }); } |
Function (anonymous_1091) | |
---|---|
✓ Was called | file.iterateTokensByType('CommentLine', function(comment) {··· var value = comment.value; // cutout exceptions allExcept.forEach(function(el) { if (value.indexOf(el) === 0) { value = value.substr(el.length); } }); if (value.length === 0) { return; } if (value[0] !== ' ') { errors.add('Missing space after line comment', comment); } }); |
Function (anonymous_1092) | |
---|---|
✓ Was called | allExcept.forEach(function(el) {··· if (value.indexOf(el) === 0) { value = value.substr(el.length); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value.indexOf(el) === 0) {··· value = value.substr(el.length); } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value.length === 0) {··· return; } |
✓ Negative was executed (else) | }··· if (value[0] !== ' ') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value[0] !== ' ') {··· errors.add('Missing space after line comment', comment); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1093) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1094) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1095) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterObjectKeys'; }, |
Function (anonymous_1096) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(property) { if ( property.type === 'ObjectMethod' && (property.kind === 'get' || property.kind === 'set') ) { return; } if (property.shorthand || property.type === 'SpreadProperty') { return; } var token = file.getLastNodeToken(property.key); if (property.computed === true) { token = file.getNextToken(token); } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Missing space after key' }); }); }); } |
Function (anonymous_1097) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(property) { if ( property.type === 'ObjectMethod' && (property.kind === 'get' || property.kind === 'set') ) { return; } if (property.shorthand || property.type === 'SpreadProperty') { return; } var token = file.getLastNodeToken(property.key); if (property.computed === true) { token = file.getNextToken(token); } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Missing space after key' }); }); }); |
Function (anonymous_1098) | |
---|---|
✓ Was called | node.properties.forEach(function(property) {··· if ( property.type === 'ObjectMethod' && (property.kind === 'get' || property.kind === 'set') ) { return; } if (property.shorthand || property.type === 'SpreadProperty') { return; } var token = file.getLastNodeToken(property.key); if (property.computed === true) { token = file.getNextToken(token); } errors.assert.whitespaceBetween({ token: token, nextToken: file.getNextToken(token), message: 'Missing space after key' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· if (property.shorthand || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (property.kind === 'get' || property.kind === 'set') |
✓ Was returned | property.type === 'ObjectMethod' && |
Branch LogicalExpression | |
---|---|
✓ Was returned | (property.kind === 'get' || property.kind === 'set') |
✓ Was returned | (property.kind === 'get' || property.kind === 'set') |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | property.type === 'SpreadProperty') {··· return; } |
✓ Negative was executed (else) | }··· var token = file.getLastNodeToken(property.key); |
Branch LogicalExpression | |
✓ Was returned | property.type === 'SpreadProperty') { |
✓ Was returned | if (property.shorthand || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (property.computed === true) {··· token = file.getNextToken(token); } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Function (anonymous_1099) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1100) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_1101) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceAfterPrefixUnaryOperators'; }, |
Function (anonymous_1102) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operatorIndex = this._operatorIndex; file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) { // Check "node.prefix" for prefix type of (inc|dec)rement if (node.prefix && operatorIndex[node.operator]) { var argument = node.argument.type; var operatorToken = node.getFirstToken(); var nextToken = file.getNextToken(operatorToken); // Do not report consecutive operators (#405) if ( argument === 'UnaryExpression' || argument === 'UpdateExpression' && nextToken.value !== '(' ) { return; } errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } }); } |
Function (anonymous_1103) | |
---|---|
✓ Was called | file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) {··· // Check "node.prefix" for prefix type of (inc|dec)rement if (node.prefix && operatorIndex[node.operator]) { var argument = node.argument.type; var operatorToken = node.getFirstToken(); var nextToken = file.getNextToken(operatorToken); // Do not report consecutive operators (#405) if ( argument === 'UnaryExpression' || argument === 'UpdateExpression' && nextToken.value !== '(' ) { return; } errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.prefix && operatorIndex[node.operator]) {··· var argument = node.argument.type; var operatorToken = node.getFirstToken(); var nextToken = file.getNextToken(operatorToken); // Do not report consecutive operators (#405) if ( argument === 'UnaryExpression' || argument === 'UpdateExpression' && nextToken.value !== '(' ) { return; } errors.assert.whitespaceBetween({ token: operatorToken, nextToken: nextToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (node.prefix && operatorIndex[node.operator]) { |
✗ Was not returned | if (node.prefix && operatorIndex[node.operator]) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Branch LogicalExpression | |
---|---|
✓ Was returned | argument === 'UnaryExpression' || argument === 'UpdateExpression' &&··· nextToken.value !== '(' |
✓ Was returned | argument === 'UnaryExpression' || argument === 'UpdateExpression' && |
Branch LogicalExpression | |
✓ Was returned | nextToken.value !== '(' |
✓ Was returned | argument === 'UnaryExpression' || argument === 'UpdateExpression' && |
Function (anonymous_1105) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1106) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = allOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = allOperators; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_1107) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeBinaryOperators'; }, |
Function (anonymous_1108) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; // Comma if (operators[',']) { file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { errors.assert.whitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Operator , should not stick to preceding expression' }); }); } // For everything else file.iterateNodesByType( ['BinaryExpression', 'AssignmentExpression', 'VariableDeclarator', 'LogicalExpression'], function(node) { var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var prevToken = file.getPrevToken(operatorToken); if (operators[operator]) { errors.assert.whitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + operator + ' should not stick to preceding expression' }); } } ); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[',']) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { errors.assert.whitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Operator , should not stick to preceding expression' }); }); } |
✓ Negative was executed (else) | }··· // For everything else |
Function (anonymous_1109) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· errors.assert.whitespaceBetween({ token: file.getPrevToken(token), nextToken: token, message: 'Operator , should not stick to preceding expression' }); }); |
Function (anonymous_1110) | |
---|---|
✓ Was called | function(node) {··· var operator; var expression; if (node.type === 'VariableDeclarator') { expression = node.init; operator = '='; } else { operator = node.operator; expression = node.right; } if (expression === null) { return; } var operatorToken = file.findPrevOperatorToken( file.getFirstNodeToken(expression), operator ); var prevToken = file.getPrevToken(operatorToken); if (operators[operator]) { errors.assert.whitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + operator + ' should not stick to preceding expression' }); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'VariableDeclarator') {··· expression = node.init; operator = '='; } else { |
✓ Negative was executed (else) | } else {··· operator = node.operator; expression = node.right; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (expression === null) {··· return; } |
✓ Negative was executed (else) | }··· var operatorToken = file.findPrevOperatorToken( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[operator]) {··· errors.assert.whitespaceBetween({ token: prevToken, nextToken: operatorToken, message: 'Operator ' + operator + ' should not stick to preceding expression' }); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_1111) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1112) | |
---|---|
✓ Was called | configure: function(requireSpaceBeforeBlockStatements) {··· assert( typeof requireSpaceBeforeBlockStatements === 'boolean' || typeof requireSpaceBeforeBlockStatements === 'number', this.getOptionName() + ' option requires number or bolean' ); assert( requireSpaceBeforeBlockStatements >= 1, this.getOptionName() + ' option requires true value or a number greater than equal to 1 or should be removed' ); this._count = +requireSpaceBeforeBlockStatements; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof requireSpaceBeforeBlockStatements === 'number', |
✓ Was returned | typeof requireSpaceBeforeBlockStatements === 'boolean' || |
Function (anonymous_1113) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeBlockStatements'; }, |
Function (anonymous_1114) | |
---|---|
✓ Was called | check: function(file, errors) {··· var count = this._count; file.iterateNodesByType('BlockStatement', function(node) { var first = node.getFirstToken(); errors.assert.spacesBetween({ token: file.getPrevToken(first), nextToken: first, atLeast: count, disallowNewLine: true, message: 'One (or more) spaces required before opening brace for block expressions' }); }); } |
Function (anonymous_1115) | |
---|---|
✓ Was called | file.iterateNodesByType('BlockStatement', function(node) {··· var first = node.getFirstToken(); errors.assert.spacesBetween({ token: file.getPrevToken(first), nextToken: first, atLeast: count, disallowNewLine: true, message: 'One (or more) spaces required before opening brace for block expressions' }); }); |
Function (anonymous_1116) | |
---|---|
✓ Was called | module.exports = function() {··· }; |
Function (anonymous_1117) | |
---|---|
✓ Was called | configure: function(option) {··· assert( option === true, this.getOptionName() + ' option requires true value' ); }, |
Function (anonymous_1118) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeComma'; }, |
Function (anonymous_1119) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { var prevToken = token.getPreviousCodeToken(); errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Space required before comma' }); }); } |
Function (anonymous_1120) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {··· var prevToken = token.getPreviousCodeToken(); errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Space required before comma' }); }); |
Function (anonymous_1121) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1122) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1123) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeDestructuredValues'; }, |
Function (anonymous_1124) | |
---|---|
✓ Was called | check: function(file, errors) {··· var checkSpaceMissing = function(propKey) { var keyToken = file.getFirstNodeToken(propKey); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }; var letsCheckThisOne = function(item) { if (!item) { return; } if (item.type === 'ObjectPattern') { item.properties.forEach(function(property) { if (property.shorthand || property.method) { return; } checkSpaceMissing(property.key); //Strategy for nested structures var propValue = property.value; if (!propValue) { return; } letsCheckThisOne(propValue); }); } if (item.type === 'ArrayPattern') { item.elements.forEach(letsCheckThisOne); } }; file.iterateNodesByType(['VariableDeclaration', 'AssignmentExpression'], function(node) { if (node.type === 'VariableDeclaration') { node.declarations.forEach(function(declaration) { letsCheckThisOne(declaration.id || {}); }); } if (node.type === 'AssignmentExpression') { var left = node.left; if (left) { letsCheckThisOne(left); } } }); } |
Function (anonymous_1125) | |
---|---|
✓ Was called | var checkSpaceMissing = function(propKey) {··· var keyToken = file.getFirstNodeToken(propKey); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }; |
Function (anonymous_1126) | |
---|---|
✓ Was called | var letsCheckThisOne = function(item) {··· if (!item) { return; } if (item.type === 'ObjectPattern') { item.properties.forEach(function(property) { if (property.shorthand || property.method) { return; } checkSpaceMissing(property.key); //Strategy for nested structures var propValue = property.value; if (!propValue) { return; } letsCheckThisOne(propValue); }); } if (item.type === 'ArrayPattern') { item.elements.forEach(letsCheckThisOne); } }; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!item) {··· return; } |
✓ Negative was executed (else) | }··· if (item.type === 'ObjectPattern') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (item.type === 'ObjectPattern') {··· item.properties.forEach(function(property) { if (property.shorthand || property.method) { return; } checkSpaceMissing(property.key); //Strategy for nested structures var propValue = property.value; if (!propValue) { return; } letsCheckThisOne(propValue); }); } |
✓ Negative was executed (else) | }··· if (item.type === 'ArrayPattern') { |
Function (anonymous_1127) | |
---|---|
✓ Was called | item.properties.forEach(function(property) {··· if (property.shorthand || property.method) { return; } checkSpaceMissing(property.key); //Strategy for nested structures var propValue = property.value; if (!propValue) { return; } letsCheckThisOne(propValue); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (property.shorthand || property.method) {··· return; } |
✓ Negative was executed (else) | }··· checkSpaceMissing(property.key); |
Branch LogicalExpression | |
✓ Was returned | if (property.shorthand || property.method) { |
✓ Was returned | if (property.shorthand || property.method) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!propValue) {··· return; } |
✓ Negative was executed (else) | }··· letsCheckThisOne(propValue); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (item.type === 'ArrayPattern') {··· item.elements.forEach(letsCheckThisOne); } |
✓ Negative was executed (else) | }··· }; |
Function (anonymous_1128) | |
---|---|
✓ Was called | file.iterateNodesByType(['VariableDeclaration', 'AssignmentExpression'], function(node) {··· if (node.type === 'VariableDeclaration') { node.declarations.forEach(function(declaration) { letsCheckThisOne(declaration.id || {}); }); } if (node.type === 'AssignmentExpression') { var left = node.left; if (left) { letsCheckThisOne(left); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'VariableDeclaration') {··· node.declarations.forEach(function(declaration) { letsCheckThisOne(declaration.id || {}); }); } |
✓ Negative was executed (else) | }··· if (node.type === 'AssignmentExpression') { |
Function (anonymous_1129) | |
---|---|
✓ Was called | node.declarations.forEach(function(declaration) {··· letsCheckThisOne(declaration.id || {}); }); |
Branch LogicalExpression | |
---|---|
✗ Was not returned | letsCheckThisOne(declaration.id || {}); |
✓ Was returned | letsCheckThisOne(declaration.id || {}); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.type === 'AssignmentExpression') {··· var left = node.left; if (left) { letsCheckThisOne(left); } } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (left) {··· letsCheckThisOne(left); } |
✗ Negative was not executed (else) | }··· } |
Function (anonymous_1130) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1131) | |
---|---|
✓ Was called | configure: function(keywords) {··· var isValidObject = (keywords === Object(keywords) && keywords.hasOwnProperty('allExcept')); assert( Array.isArray(keywords) || keywords === true || isValidObject, this.getOptionName() + ' option requires array, object with "allExcept" property or true value'); var excludedKeywords = ignoredKeywords; if (isValidObject) { excludedKeywords = keywords.allExcept; } if (!Array.isArray(keywords)) { keywords = defaultKeywords.filter(function(keyword) { return (excludedKeywords.indexOf(keyword) === -1); }); } this._keywords = keywords; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | var isValidObject = (keywords === Object(keywords) && keywords.hasOwnProperty('allExcept')); |
✓ Was returned | var isValidObject = (keywords === Object(keywords) && keywords.hasOwnProperty('allExcept')); |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(keywords) || keywords === true || isValidObject, |
✓ Was returned | Array.isArray(keywords) || keywords === true || isValidObject, |
Branch LogicalExpression | |
✓ Was returned | Array.isArray(keywords) || keywords === true || isValidObject, |
✓ Was returned | Array.isArray(keywords) || keywords === true || isValidObject, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isValidObject) {··· excludedKeywords = keywords.allExcept; } |
✓ Negative was executed (else) | }··· if (!Array.isArray(keywords)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!Array.isArray(keywords)) {··· keywords = defaultKeywords.filter(function(keyword) { return (excludedKeywords.indexOf(keyword) === -1); }); } |
✓ Negative was executed (else) | }··· this._keywords = keywords; |
Function (anonymous_1132) | |
---|---|
✓ Was called | keywords = defaultKeywords.filter(function(keyword) {··· return (excludedKeywords.indexOf(keyword) === -1); }); |
Function (anonymous_1133) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeKeywords'; }, |
Function (anonymous_1134) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); if (!prevToken || prevToken.isComment) { return; } if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before "' + token.value + '" keyword' }); } }); } |
Function (anonymous_1135) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); if (!prevToken || prevToken.isComment) { return; } if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before "' + token.value + '" keyword' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!prevToken || prevToken.isComment) {··· return; } |
✓ Negative was executed (else) | }··· if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { |
Branch LogicalExpression | |
✓ Was returned | if (!prevToken || prevToken.isComment) { |
✓ Was returned | if (!prevToken || prevToken.isComment) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') {··· errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before "' + token.value + '" keyword' }); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { |
✗ Was not returned | if (prevToken.type !== 'Punctuator' || prevToken.value !== ';') { |
Function (anonymous_1136) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1137) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1138) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforeObjectValues'; }, |
Function (anonymous_1139) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ObjectExpression', function(node) { node.properties.forEach(function(property) { if ( property.type === 'ObjectMethod' && (property.kind === 'get' || property.kind === 'set') ) { return; } if (property.shorthand || property.method || property.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }); }); } |
Function (anonymous_1140) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· node.properties.forEach(function(property) { if ( property.type === 'ObjectMethod' && (property.kind === 'get' || property.kind === 'set') ) { return; } if (property.shorthand || property.method || property.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }); }); |
Function (anonymous_1141) | |
---|---|
✓ Was called | node.properties.forEach(function(property) {··· if ( property.type === 'ObjectMethod' && (property.kind === 'get' || property.kind === 'set') ) { return; } if (property.shorthand || property.method || property.type === 'SpreadProperty') { return; } var keyToken = file.getFirstNodeToken(property.key); var colon = file.findNextToken(keyToken, 'Punctuator', ':'); errors.assert.whitespaceBetween({ token: colon, nextToken: file.getNextToken(colon), message: 'Missing space after key colon' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· if (property.shorthand || property.method || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (property.kind === 'get' || property.kind === 'set') |
✓ Was returned | property.type === 'ObjectMethod' && |
Branch LogicalExpression | |
---|---|
✓ Was returned | (property.kind === 'get' || property.kind === 'set') |
✓ Was returned | (property.kind === 'get' || property.kind === 'set') |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | property.type === 'SpreadProperty') {··· return; } |
✓ Negative was executed (else) | }··· var keyToken = file.getFirstNodeToken(property.key); |
Branch LogicalExpression | |
✓ Was returned | property.type === 'SpreadProperty') { |
✓ Was returned | if (property.shorthand || property.method || |
Branch LogicalExpression | |
✓ Was returned | if (property.shorthand || property.method || |
✓ Was returned | if (property.shorthand || property.method || |
Function (anonymous_1142) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1143) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = defaultOperators; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = defaultOperators; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_1144) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceBeforePostfixUnaryOperators'; }, |
Function (anonymous_1145) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operatorIndex = this._operatorIndex; // 'UpdateExpression' involve only ++ and -- operators file.iterateNodesByType('UpdateExpression', function(node) { // "!node.prefix" means postfix type of (inc|dec)rement if (!node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getLastNodeToken(node); errors.assert.whitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } }); } |
Function (anonymous_1146) | |
---|---|
✓ Was called | file.iterateNodesByType('UpdateExpression', function(node) {··· // "!node.prefix" means postfix type of (inc|dec)rement if (!node.prefix && operatorIndex[node.operator]) { var operatorToken = file.getLastNodeToken(node); errors.assert.whitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!node.prefix && operatorIndex[node.operator]) {··· var operatorToken = file.getLastNodeToken(node); errors.assert.whitespaceBetween({ token: file.getPrevToken(operatorToken), nextToken: operatorToken, message: 'Operator ' + node.operator + ' should not stick to operand' }); } |
✗ Negative was not executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (!node.prefix && operatorIndex[node.operator]) { |
✗ Was not returned | if (!node.prefix && operatorIndex[node.operator]) { |
Function (anonymous_1147) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1148) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1149) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpaceBetweenArguments'; }, |
Function (anonymous_1150) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['CallExpression'], function(node) { node.arguments.forEach(function(param) { var punctuatorToken = file.getPrevToken(file.getFirstNodeToken(param)); if (punctuatorToken.value === ',') { errors.assert.whitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken) }); } }); }); } |
Function (anonymous_1151) | |
---|---|
✓ Was called | file.iterateNodesByType(['CallExpression'], function(node) {··· node.arguments.forEach(function(param) { var punctuatorToken = file.getPrevToken(file.getFirstNodeToken(param)); if (punctuatorToken.value === ',') { errors.assert.whitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken) }); } }); }); |
Function (anonymous_1152) | |
---|---|
✓ Was called | node.arguments.forEach(function(param) {··· var punctuatorToken = file.getPrevToken(file.getFirstNodeToken(param)); if (punctuatorToken.value === ',') { errors.assert.whitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken) }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (punctuatorToken.value === ',') {··· errors.assert.whitespaceBetween({ token: punctuatorToken, nextToken: file.getNextToken(punctuatorToken) }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1153) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1154) | |
---|---|
✓ Was called | configure: function(options) {··· this._exceptions = { 'shorthand': false }; assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } if ('allExcept' in options) { if (typeof options.allExcept === 'object') { assert( Array.isArray(options.allExcept), this.getOptionName() + ' option requires "allExcept" to be ' + 'an array' ); assert( options.allExcept.length > 0, this.getOptionName() + ' option requires "allExcept" to have ' + 'at least one item or be set to `true`' ); options.allExcept.forEach(function(except) { if (except === 'shorthand') { this._exceptions.shorthand = true; } else { assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } }, this); } else { assert( options.allExcept === true, this.getOptionName() + ' option requires a true value or array' ); this._exceptions.shorthand = true; } } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace ' + ' or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('allExcept' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('allExcept' in options) {··· if (typeof options.allExcept === 'object') { assert( Array.isArray(options.allExcept), this.getOptionName() + ' option requires "allExcept" to be ' + 'an array' ); assert( options.allExcept.length > 0, this.getOptionName() + ' option requires "allExcept" to have ' + 'at least one item or be set to `true`' ); options.allExcept.forEach(function(except) { if (except === 'shorthand') { this._exceptions.shorthand = true; } else { assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } }, this); } else { assert( options.allExcept === true, this.getOptionName() + ' option requires a true value or array' ); this._exceptions.shorthand = true; } } |
✓ Negative was executed (else) | }··· assert( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options.allExcept === 'object') {··· assert( Array.isArray(options.allExcept), this.getOptionName() + ' option requires "allExcept" to be ' + 'an array' ); assert( options.allExcept.length > 0, this.getOptionName() + ' option requires "allExcept" to have ' + 'at least one item or be set to `true`' ); options.allExcept.forEach(function(except) { if (except === 'shorthand') { this._exceptions.shorthand = true; } else { assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } }, this); } else { |
✓ Negative was executed (else) | } else {··· assert( options.allExcept === true, this.getOptionName() + ' option requires a true value or array' ); this._exceptions.shorthand = true; } |
Function (anonymous_1155) | |
---|---|
✓ Was called | options.allExcept.forEach(function(except) {··· if (except === 'shorthand') { this._exceptions.shorthand = true; } else { assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } }, this); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (except === 'shorthand') {··· this._exceptions.shorthand = true; } else { |
✓ Negative was executed (else) | } else {··· assert(false, this.getOptionName() + ' option requires ' + '"allExcept" to be an array containing "shorthand"'); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_1156) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInAnonymousFunctionExpression'; }, |
Function (anonymous_1157) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; var exceptions = this._exceptions; file.iterateNodesByType(['FunctionExpression'], function(node) { var functionNode = node; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; if (exceptions.shorthand) { return; } } // anonymous function expressions only if (node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); } |
Function (anonymous_1158) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· var functionNode = node; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; if (exceptions.shorthand) { return; } } // anonymous function expressions only if (node.id) { return; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
✓ Negative was executed (else) | }··· // shorthand or constructor methods |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; if (exceptions.shorthand) { return; } } |
✓ Negative was executed (else) | }··· // anonymous function expressions only |
Branch LogicalExpression | |
✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
✗ Was not returned | if (parent.method || parent.type === 'MethodDefinition') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (exceptions.shorthand) {··· return; } |
✗ Negative was not executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.id) {··· return; } |
✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
Branch LogicalExpression | |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Branch LogicalExpression | |
✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
✓ Was returned | if (node.generator && functionToken.value === 'function') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1159) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1160) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1161) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInCallExpression'; }, |
Function (anonymous_1162) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('CallExpression', function(node) { var lastCalleeToken = file.getLastNodeToken(node.callee); var roundBraceToken = file.findNextToken(lastCalleeToken, 'Punctuator', '('); errors.assert.whitespaceBetween({ token: file.getPrevToken(roundBraceToken), nextToken: roundBraceToken, message: 'Missing space before opening round brace' }); }); } |
Function (anonymous_1163) | |
---|---|
✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· var lastCalleeToken = file.getLastNodeToken(node.callee); var roundBraceToken = file.findNextToken(lastCalleeToken, 'Punctuator', '('); errors.assert.whitespaceBetween({ token: file.getPrevToken(roundBraceToken), nextToken: roundBraceToken, message: 'Missing space before opening round brace' }); }); |
Function (anonymous_1164) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1165) | |
---|---|
✓ Was called | configure: function(options) {··· var validProperties = [ 'afterTest', 'beforeConsequent', 'afterConsequent', 'beforeAlternate' ]; var optionName = this.getOptionName(); if (options === true) { options = { 'afterTest': true, 'beforeConsequent': true, 'afterConsequent': true, 'beforeAlternate': true }; } assert( typeof options === 'object', optionName + ' option requires a true value or an object' ); var isProperlyConfigured = validProperties.some(function(key) { var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } return isPresent; }); assert( isProperlyConfigured, optionName + ' must have at least 1 of the following properties: ' + validProperties.join(', ') ); validProperties.forEach(function(property) { this['_' + property] = Boolean(options[property]); }.bind(this)); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (options === true) {··· options = { 'afterTest': true, 'beforeConsequent': true, 'afterConsequent': true, 'beforeAlternate': true }; } |
✓ Negative was executed (else) | }··· assert( |
Function (anonymous_1166) | |
---|---|
✓ Was called | var isProperlyConfigured = validProperties.some(function(key) {··· var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } return isPresent; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isPresent) {··· assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· return isPresent; |
Function (anonymous_1167) | |
---|---|
✓ Was called | validProperties.forEach(function(property) {··· this['_' + property] = Boolean(options[property]); }.bind(this)); |
Function (anonymous_1168) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInConditionalExpression'; }, |
Function (anonymous_1169) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ConditionalExpression'], function(node) { var consequent = node.consequent; var alternate = node.alternate; var consequentToken = file.getFirstNodeToken(consequent); var alternateToken = file.getFirstNodeToken(alternate); var questionMarkToken = file.findPrevOperatorToken(consequentToken, '?'); var colonToken = file.findPrevOperatorToken(alternateToken, ':'); var token; if (this._afterTest) { token = file.getPrevToken(questionMarkToken); errors.assert.whitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Missing space after test' }); } if (this._beforeConsequent) { token = file.getNextToken(questionMarkToken); errors.assert.whitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Missing space before consequent' }); } if (this._afterConsequent) { token = file.getPrevToken(colonToken); errors.assert.whitespaceBetween({ token: token, nextToken: colonToken, message: 'Missing space after consequent' }); } if (this._beforeAlternate) { token = file.getNextToken(colonToken); errors.assert.whitespaceBetween({ token: colonToken, nextToken: token, message: 'Missing space before alternate' }); } }.bind(this)); } |
Function (anonymous_1170) | |
---|---|
✓ Was called | file.iterateNodesByType(['ConditionalExpression'], function(node) {··· var consequent = node.consequent; var alternate = node.alternate; var consequentToken = file.getFirstNodeToken(consequent); var alternateToken = file.getFirstNodeToken(alternate); var questionMarkToken = file.findPrevOperatorToken(consequentToken, '?'); var colonToken = file.findPrevOperatorToken(alternateToken, ':'); var token; if (this._afterTest) { token = file.getPrevToken(questionMarkToken); errors.assert.whitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Missing space after test' }); } if (this._beforeConsequent) { token = file.getNextToken(questionMarkToken); errors.assert.whitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Missing space before consequent' }); } if (this._afterConsequent) { token = file.getPrevToken(colonToken); errors.assert.whitespaceBetween({ token: token, nextToken: colonToken, message: 'Missing space after consequent' }); } if (this._beforeAlternate) { token = file.getNextToken(colonToken); errors.assert.whitespaceBetween({ token: colonToken, nextToken: token, message: 'Missing space before alternate' }); } }.bind(this)); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._afterTest) {··· token = file.getPrevToken(questionMarkToken); errors.assert.whitespaceBetween({ token: token, nextToken: questionMarkToken, message: 'Missing space after test' }); } |
✓ Negative was executed (else) | }··· if (this._beforeConsequent) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._beforeConsequent) {··· token = file.getNextToken(questionMarkToken); errors.assert.whitespaceBetween({ token: questionMarkToken, nextToken: token, message: 'Missing space before consequent' }); } |
✓ Negative was executed (else) | }··· if (this._afterConsequent) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._afterConsequent) {··· token = file.getPrevToken(colonToken); errors.assert.whitespaceBetween({ token: token, nextToken: colonToken, message: 'Missing space after consequent' }); } |
✓ Negative was executed (else) | }··· if (this._beforeAlternate) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._beforeAlternate) {··· token = file.getNextToken(colonToken); errors.assert.whitespaceBetween({ token: colonToken, nextToken: token, message: 'Missing space before alternate' }); } |
✓ Negative was executed (else) | }··· }.bind(this)); |
Function (anonymous_1171) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1172) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1173) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInForStatement'; }, |
Function (anonymous_1174) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('ForStatement', function(node) { if (node.test) { var testToken = file.getFirstNodeToken(node.test); var prevToken = file.getPrevToken(testToken); if (prevToken.value === '(' && TokenCategorizer.categorizeOpenParen(prevToken) === 'ParenthesizedExpression') { testToken = prevToken; prevToken = file.getPrevToken(prevToken); } errors.assert.spacesBetween({ token: prevToken, nextToken: testToken, exactly: 1, message: 'One space required after semicolon' }); } if (node.update) { var updateToken = file.getFirstNodeToken(node.update); errors.assert.spacesBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, exactly: 1, message: 'One space required after semicolon' }); } }); } |
Function (anonymous_1175) | |
---|---|
✓ Was called | file.iterateNodesByType('ForStatement', function(node) {··· if (node.test) { var testToken = file.getFirstNodeToken(node.test); var prevToken = file.getPrevToken(testToken); if (prevToken.value === '(' && TokenCategorizer.categorizeOpenParen(prevToken) === 'ParenthesizedExpression') { testToken = prevToken; prevToken = file.getPrevToken(prevToken); } errors.assert.spacesBetween({ token: prevToken, nextToken: testToken, exactly: 1, message: 'One space required after semicolon' }); } if (node.update) { var updateToken = file.getFirstNodeToken(node.update); errors.assert.spacesBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, exactly: 1, message: 'One space required after semicolon' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.test) {··· var testToken = file.getFirstNodeToken(node.test); var prevToken = file.getPrevToken(testToken); if (prevToken.value === '(' && TokenCategorizer.categorizeOpenParen(prevToken) === 'ParenthesizedExpression') { testToken = prevToken; prevToken = file.getPrevToken(prevToken); } errors.assert.spacesBetween({ token: prevToken, nextToken: testToken, exactly: 1, message: 'One space required after semicolon' }); } |
✓ Negative was executed (else) | }··· if (node.update) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | TokenCategorizer.categorizeOpenParen(prevToken) === 'ParenthesizedExpression') {··· testToken = prevToken; prevToken = file.getPrevToken(prevToken); } |
✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
Branch LogicalExpression | |
✓ Was returned | TokenCategorizer.categorizeOpenParen(prevToken) === 'ParenthesizedExpression') { |
✓ Was returned | if (prevToken.value === '(' && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.update) {··· var updateToken = file.getFirstNodeToken(node.update); errors.assert.spacesBetween({ token: file.getPrevToken(updateToken), nextToken: updateToken, exactly: 1, message: 'One space required after semicolon' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1176) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1177) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_1178) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInFunctionDeclaration'; }, |
Function (anonymous_1179) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionDeclaration'], function(node) { // Exception for `export default function` #1376 if (!node.id) { return; } if (beforeOpeningRoundBrace) { // for a named function, use node.id var functionToken = file.getFirstNodeToken(node.id || node); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); } |
Function (anonymous_1180) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionDeclaration'], function(node) {··· // Exception for `export default function` #1376 if (!node.id) { return; } if (beforeOpeningRoundBrace) { // for a named function, use node.id var functionToken = file.getFirstNodeToken(node.id || node); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!node.id) {··· return; } |
✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· // for a named function, use node.id var functionToken = file.getFirstNodeToken(node.id || node); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch LogicalExpression | |
---|---|
✗ Was not returned | var functionToken = file.getFirstNodeToken(node.id || node); |
✓ Was returned | var functionToken = file.getFirstNodeToken(node.id || node); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
Branch LogicalExpression | |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Branch LogicalExpression | |
✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
✓ Was returned | if (node.generator && functionToken.value === 'function') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1181) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1182) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_1183) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInFunctionExpression'; }, |
Function (anonymous_1184) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType('FunctionExpression', function(node) { // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); } |
Function (anonymous_1185) | |
---|---|
✓ Was called | file.iterateNodesByType('FunctionExpression', function(node) {··· // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | var functionNode = node.id || node; |
✓ Was returned | var functionNode = node.id || node; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
✓ Negative was executed (else) | }··· // shorthand or constructor methods |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
Branch LogicalExpression | |
✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
✗ Was not returned | if (parent.method || parent.type === 'MethodDefinition') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
Branch LogicalExpression | |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Branch LogicalExpression | |
✓ Was returned | if (node.generator && functionToken.value === 'function') { |
✓ Was returned | if (node.generator && functionToken.value === 'function') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1186) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1187) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_1188) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInFunction'; }, |
Function (anonymous_1189) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); } |
Function (anonymous_1190) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· // for a named function, use node.id var functionNode = node.id || node; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | var functionNode = node.id || node; |
✓ Was returned | var functionNode = node.id || node; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
✓ Negative was executed (else) | }··· // shorthand or constructor methods |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
✓ Negative was executed (else) | }··· if (beforeOpeningRoundBrace) { |
Branch LogicalExpression | |
✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
✗ Was not returned | if (parent.method || parent.type === 'MethodDefinition') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } // if generator, set token to be * instead if (node.generator && functionToken.value === 'function') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· // if generator, set token to be * instead |
Branch LogicalExpression | |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.generator && functionToken.value === 'function') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Branch LogicalExpression | |
✗ Was not returned | if (node.generator && functionToken.value === 'function') { |
✓ Was returned | if (node.generator && functionToken.value === 'function') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1191) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1192) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be an object' ); if ('beforeStar' in options) { assert( options.beforeStar === true, this.getOptionName() + '.beforeStar ' + 'property requires true value or should be removed' ); } if ('afterStar' in options) { assert( options.afterStar === true, this.getOptionName() + '.afterStar ' + 'property requires true value or should be removed' ); } assert( options.beforeStar || options.afterStar, this.getOptionName() + ' must have beforeStar or afterStar property' ); this._beforeStar = options.beforeStar; this._afterStar = options.afterStar; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeStar' in options) {··· assert( options.beforeStar === true, this.getOptionName() + '.beforeStar ' + 'property requires true value or should be removed' ); } |
✗ Negative was not executed (else) | }··· if ('afterStar' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('afterStar' in options) {··· assert( options.afterStar === true, this.getOptionName() + '.afterStar ' + 'property requires true value or should be removed' ); } |
✗ Negative was not executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✗ Was not returned | options.beforeStar || options.afterStar, |
✓ Was returned | options.beforeStar || options.afterStar, |
Function (anonymous_1193) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInGenerator'; }, |
Function (anonymous_1194) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeStar = this._beforeStar; var afterStar = this._afterStar; file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { if (!node.generator) { return; } var parent = node.parentElement; var shorthand = false; // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { shorthand = true; node = parent.key; } var currentToken = node.getFirstToken(); if (node.async && currentToken.value === 'async') { currentToken = file.getNextToken(currentToken); } if (beforeStar && !shorthand) { // currentToken assigned outside of function errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space before star' }); } if (afterStar) { if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space after star' }); } }); } |
Function (anonymous_1195) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· if (!node.generator) { return; } var parent = node.parentElement; var shorthand = false; // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { shorthand = true; node = parent.key; } var currentToken = node.getFirstToken(); if (node.async && currentToken.value === 'async') { currentToken = file.getNextToken(currentToken); } if (beforeStar && !shorthand) { // currentToken assigned outside of function errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space before star' }); } if (afterStar) { if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space after star' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!node.generator) {··· return; } |
✓ Negative was executed (else) | }··· var parent = node.parentElement; |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· shorthand = true; node = parent.key; } |
✓ Negative was executed (else) | }··· var currentToken = node.getFirstToken(); |
Branch LogicalExpression | |
✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
✗ Was not returned | if (parent.method || parent.type === 'MethodDefinition') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.async && currentToken.value === 'async') {··· currentToken = file.getNextToken(currentToken); } |
✓ Negative was executed (else) | }··· if (beforeStar && !shorthand) { |
Branch LogicalExpression | |
✓ Was returned | if (node.async && currentToken.value === 'async') { |
✓ Was returned | if (node.async && currentToken.value === 'async') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeStar && !shorthand) {··· // currentToken assigned outside of function errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space before star' }); } |
✗ Negative was not executed (else) | }··· if (afterStar) { |
Branch LogicalExpression | |
✓ Was returned | if (beforeStar && !shorthand) { |
✗ Was not returned | if (beforeStar && !shorthand) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (afterStar) {··· if (shorthand) { currentToken = file.getPrevToken(currentToken); } else { // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } errors.assert.whitespaceBetween({ token: currentToken, nextToken: file.getNextToken(currentToken), message: 'Missing space after star' }); } |
✗ Negative was not executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (shorthand) {··· currentToken = file.getPrevToken(currentToken); } else { |
✓ Negative was executed (else) | } else {··· // currentToken reassigned for star token currentToken = file.getNextToken(currentToken); } |
Function (anonymous_1196) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1197) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'object', this.getOptionName() + ' option must be the object' ); if ('beforeOpeningRoundBrace' in options) { assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } if ('beforeOpeningCurlyBrace' in options) { assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } assert( options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, this.getOptionName() + ' must have beforeOpeningCurlyBrace ' + 'or beforeOpeningRoundBrace property' ); this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningRoundBrace' in options) {··· assert( options.beforeOpeningRoundBrace === true, this.getOptionName() + '.beforeOpeningRoundBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· if ('beforeOpeningCurlyBrace' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('beforeOpeningCurlyBrace' in options) {··· assert( options.beforeOpeningCurlyBrace === true, this.getOptionName() + '.beforeOpeningCurlyBrace ' + 'property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
✓ Was returned | options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, |
Function (anonymous_1198) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInNamedFunctionExpression'; }, |
Function (anonymous_1199) | |
---|---|
✓ Was called | check: function(file, errors) {··· var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; file.iterateNodesByType(['FunctionExpression'], function(node) { var functionNode = node.id; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // named function expressions only if (node.id) { if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } } }); } |
Function (anonymous_1200) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionExpression'], function(node) {··· var functionNode = node.id; var parent = node.parentElement; // Ignore syntactic sugar for getters and setters. if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { return; } // shorthand or constructor methods if (parent.method || parent.type === 'MethodDefinition') { functionNode = parent.key; } // named function expressions only if (node.id) { if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } } }); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) {··· return; } |
✓ Negative was executed (else) | }··· // shorthand or constructor methods |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✓ Was returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch LogicalExpression | |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
✗ Was not returned | if (parent.type === 'Property' && (parent.kind === 'get' || parent.kind === 'set')) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (parent.method || parent.type === 'MethodDefinition') {··· functionNode = parent.key; } |
✓ Negative was executed (else) | }··· // named function expressions only |
Branch LogicalExpression | |
✓ Was returned | if (parent.method || parent.type === 'MethodDefinition') { |
✗ Was not returned | if (parent.method || parent.type === 'MethodDefinition') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.id) {··· if (beforeOpeningRoundBrace) { var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } if (beforeOpeningCurlyBrace) { var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } } |
✗ Negative was not executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningRoundBrace) {··· var functionToken = file.getFirstNodeToken(functionNode); if (node.async && functionToken.value === 'async') { functionToken = file.getNextToken(functionToken); } errors.assert.whitespaceBetween({ token: functionToken, nextToken: file.getNextToken(functionToken), message: 'Missing space before opening round brace' }); } |
✓ Negative was executed (else) | }··· if (beforeOpeningCurlyBrace) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (node.async && functionToken.value === 'async') {··· functionToken = file.getNextToken(functionToken); } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Branch LogicalExpression | |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
✓ Was returned | if (node.async && functionToken.value === 'async') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (beforeOpeningCurlyBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); errors.assert.whitespaceBetween({ token: file.getPrevToken(bodyToken), nextToken: bodyToken, message: 'Missing space before opening curly brace' }); } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_1201) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1202) | |
---|---|
✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'allButNested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string value "all" or "allButNested" or object'; if (typeof value === 'string') { assert(modes[value], error); } else if (isObject) { assert('allExcept' in value, error); } else { assert(false, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { mode = value; } if (mode === 'allButNested') { this._exceptions['['] = this._exceptions[']'] = true; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof value === 'string') {··· assert(modes[value], error); } else if (isObject) { |
✓ Negative was executed (else) | } else if (isObject) {··· assert('allExcept' in value, error); } else { assert(false, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (isObject) {··· assert('allExcept' in value, error); } else { |
✓ Negative was executed (else) | } else {··· assert(false, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { |
✓ Negative was executed (else) | } else {··· mode = value; } |
Function (anonymous_1203) | |
---|---|
✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (mode === 'allButNested') {··· this._exceptions['['] = this._exceptions[']'] = true; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_1204) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideArrayBrackets'; }, |
Function (anonymous_1205) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateNodesByType('ArrayExpression', function(node) { var openBracket = node.getFirstToken(); var afterOpen = file.getNextToken(openBracket, {includeComments: true}); var closeBracket = file.getLastNodeToken(node); var beforeClose = file.getPrevToken(closeBracket, {includeComments: true}); // Skip for empty array brackets if (afterOpen.value === ']') { return; } if (!(afterOpen.value in exceptions)) { errors.assert.spacesBetween({ token: openBracket, nextToken: afterOpen, exactly: 1, message: 'One space required after opening bracket' }); } if (!(beforeClose.value in exceptions)) { errors.assert.spacesBetween({ token: beforeClose, nextToken: closeBracket, exactly: 1, message: 'One space required before closing bracket' }); } }); } |
Function (anonymous_1206) | |
---|---|
✓ Was called | file.iterateNodesByType('ArrayExpression', function(node) {··· var openBracket = node.getFirstToken(); var afterOpen = file.getNextToken(openBracket, {includeComments: true}); var closeBracket = file.getLastNodeToken(node); var beforeClose = file.getPrevToken(closeBracket, {includeComments: true}); // Skip for empty array brackets if (afterOpen.value === ']') { return; } if (!(afterOpen.value in exceptions)) { errors.assert.spacesBetween({ token: openBracket, nextToken: afterOpen, exactly: 1, message: 'One space required after opening bracket' }); } if (!(beforeClose.value in exceptions)) { errors.assert.spacesBetween({ token: beforeClose, nextToken: closeBracket, exactly: 1, message: 'One space required before closing bracket' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (afterOpen.value === ']') {··· return; } |
✓ Negative was executed (else) | }··· if (!(afterOpen.value in exceptions)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!(afterOpen.value in exceptions)) {··· errors.assert.spacesBetween({ token: openBracket, nextToken: afterOpen, exactly: 1, message: 'One space required after opening bracket' }); } |
✓ Negative was executed (else) | }··· if (!(beforeClose.value in exceptions)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!(beforeClose.value in exceptions)) {··· errors.assert.spacesBetween({ token: beforeClose, nextToken: closeBracket, exactly: 1, message: 'One space required before closing bracket' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1207) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1208) | |
---|---|
✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_1209) | |
---|---|
✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
Function (anonymous_1210) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideBrackets'; }, |
Function (anonymous_1211) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokensByTypeAndValue('Punctuator', '[', function(token) { var nextToken = file.getNextToken(token, { includeComments: true }); var value = nextToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === ']') { return; } errors.assert.spacesBetween({ token: token, nextToken: nextToken, exactly: 1, message: 'One space required after opening bracket' }); }); file.iterateTokensByTypeAndValue('Punctuator', ']', function(token) { var prevToken = file.getPrevToken(token, { includeComments: true }); var value = prevToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === '[') { return; } errors.assert.spacesBetween({ token: prevToken, nextToken: token, exactly: 1, message: 'One space required before closing bracket' }); }); } |
Function (anonymous_1212) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', '[', function(token) {··· var nextToken = file.getNextToken(token, { includeComments: true }); var value = nextToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === ']') { return; } errors.assert.spacesBetween({ token: token, nextToken: nextToken, exactly: 1, message: 'One space required after opening bracket' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· // Skip for empty array brackets |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === ']') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
Function (anonymous_1213) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ']', function(token) {··· var prevToken = file.getPrevToken(token, { includeComments: true }); var value = prevToken.value; if (value in exceptions) { return; } // Skip for empty array brackets if (value === '[') { return; } errors.assert.spacesBetween({ token: prevToken, nextToken: token, exactly: 1, message: 'One space required before closing bracket' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· // Skip for empty array brackets |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === '[') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
Function (anonymous_1214) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1215) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1216) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideImportedObjectBraces'; }, |
Function (anonymous_1217) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['ImportDeclaration'], function(node) { if (!node.specifiers) { return; } node.specifiers.forEach(function(specifier) { if (specifier.type !== 'ImportSpecifier') { return; } var maybeOpeningBrace = file.getPrevToken(specifier.getFirstToken()); var maybeClosingBrace = file.getNextToken(specifier.getLastToken()); if (maybeOpeningBrace.value === '{') { errors.assert.spacesBetween({ token: maybeOpeningBrace, nextToken: specifier.getFirstToken(), exactly: 1, message: 'One space required after opening curly brace' }); } if (maybeClosingBrace.value === '}') { errors.assert.spacesBetween({ token: specifier.getLastToken(), nextToken: maybeClosingBrace, exactly: 1, message: 'One space required before closing curly brace' }); } }); }); } |
Function (anonymous_1218) | |
---|---|
✓ Was called | file.iterateNodesByType(['ImportDeclaration'], function(node) {··· if (!node.specifiers) { return; } node.specifiers.forEach(function(specifier) { if (specifier.type !== 'ImportSpecifier') { return; } var maybeOpeningBrace = file.getPrevToken(specifier.getFirstToken()); var maybeClosingBrace = file.getNextToken(specifier.getLastToken()); if (maybeOpeningBrace.value === '{') { errors.assert.spacesBetween({ token: maybeOpeningBrace, nextToken: specifier.getFirstToken(), exactly: 1, message: 'One space required after opening curly brace' }); } if (maybeClosingBrace.value === '}') { errors.assert.spacesBetween({ token: specifier.getLastToken(), nextToken: maybeClosingBrace, exactly: 1, message: 'One space required before closing curly brace' }); } }); }); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (!node.specifiers) {··· return; } |
✓ Negative was executed (else) | }··· node.specifiers.forEach(function(specifier) { |
Function (anonymous_1219) | |
---|---|
✓ Was called | node.specifiers.forEach(function(specifier) {··· if (specifier.type !== 'ImportSpecifier') { return; } var maybeOpeningBrace = file.getPrevToken(specifier.getFirstToken()); var maybeClosingBrace = file.getNextToken(specifier.getLastToken()); if (maybeOpeningBrace.value === '{') { errors.assert.spacesBetween({ token: maybeOpeningBrace, nextToken: specifier.getFirstToken(), exactly: 1, message: 'One space required after opening curly brace' }); } if (maybeClosingBrace.value === '}') { errors.assert.spacesBetween({ token: specifier.getLastToken(), nextToken: maybeClosingBrace, exactly: 1, message: 'One space required before closing curly brace' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (specifier.type !== 'ImportSpecifier') {··· return; } |
✓ Negative was executed (else) | }··· var maybeOpeningBrace = file.getPrevToken(specifier.getFirstToken()); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (maybeOpeningBrace.value === '{') {··· errors.assert.spacesBetween({ token: maybeOpeningBrace, nextToken: specifier.getFirstToken(), exactly: 1, message: 'One space required after opening curly brace' }); } |
✓ Negative was executed (else) | }··· if (maybeClosingBrace.value === '}') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (maybeClosingBrace.value === '}') {··· errors.assert.spacesBetween({ token: specifier.getLastToken(), nextToken: maybeClosingBrace, exactly: 1, message: 'One space required before closing curly brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1220) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1221) | |
---|---|
✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'allButNested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string value \'all\' or \'allButNested\' or object'; if (typeof value === 'string') { assert(modes[value], error); } else if (isObject) { assert('allExcept' in value, error); } else { assert(false, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { mode = value; } if (mode === 'allButNested') { this._exceptions['}'] = true; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof value === 'string') {··· assert(modes[value], error); } else if (isObject) { |
✓ Negative was executed (else) | } else if (isObject) {··· assert('allExcept' in value, error); } else { assert(false, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (isObject) {··· assert('allExcept' in value, error); } else { |
✓ Negative was executed (else) | } else {··· assert(false, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } else { |
✓ Negative was executed (else) | } else {··· mode = value; } |
Function (anonymous_1222) | |
---|---|
✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (mode === 'allButNested') {··· this._exceptions['}'] = true; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_1223) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideObjectBrackets'; }, |
Function (anonymous_1224) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateNodesByType(['ObjectExpression', 'ObjectPattern'], function(node) { var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket); // Don't check empty object if (nextToken.value === '}') { return; } errors.assert.spacesBetween({ token: openingBracket, nextToken: nextToken, exactly: 1, message: 'One space required after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket); if (prevToken.value in exceptions) { return; } errors.assert.spacesBetween({ token: prevToken, nextToken: closingBracket, exactly: 1, message: 'One space required before closing curly brace' }); }); } |
Function (anonymous_1225) | |
---|---|
✓ Was called | file.iterateNodesByType(['ObjectExpression', 'ObjectPattern'], function(node) {··· var openingBracket = node.getFirstToken(); var nextToken = file.getNextToken(openingBracket); // Don't check empty object if (nextToken.value === '}') { return; } errors.assert.spacesBetween({ token: openingBracket, nextToken: nextToken, exactly: 1, message: 'One space required after opening curly brace' }); var closingBracket = file.getLastNodeToken(node); var prevToken = file.getPrevToken(closingBracket); if (prevToken.value in exceptions) { return; } errors.assert.spacesBetween({ token: prevToken, nextToken: closingBracket, exactly: 1, message: 'One space required before closing curly brace' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nextToken.value === '}') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prevToken.value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.spacesBetween({ |
Function (anonymous_1226) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1227) | |
---|---|
✓ Was called | configure: function(value) {··· var mode; var modes = { 'all': true, 'allButNested': true }; var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule' + ' requires string value \'all\' or \'allButNested\' or object'; if (typeof value === 'string') { assert(modes[value], error); } else if (isObject) { assert( 'all' in value || 'allButNested' in value, error ); } else { assert(false, error); } this._exceptions = {}; this._exceptSingleQuote = false; this._exceptDoubleQuote = false; this._ignoreParenthesizedExpression = false; if (isObject) { mode = 'all' in value ? 'all' : 'allButNested'; (value.except || []).forEach(function(value) { if (value === '\'') { this._exceptSingleQuote = true; } if (value === '"') { this._exceptDoubleQuote = true; } this._exceptions[value] = true; }, this); if (value.ignoreParenthesizedExpression === true) { this._ignoreParenthesizedExpression = true; } } else { mode = value; } if (mode === 'allButNested') { this._exceptions[')'] = this._exceptions['('] = true; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof value === 'string') {··· assert(modes[value], error); } else if (isObject) { |
✓ Negative was executed (else) | } else if (isObject) {··· assert( 'all' in value || 'allButNested' in value, error ); } else { assert(false, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (isObject) {··· assert( 'all' in value || 'allButNested' in value, error ); } else { |
✓ Negative was executed (else) | } else {··· assert(false, error); } |
Branch LogicalExpression | |
---|---|
✗ Was not returned | 'all' in value || 'allButNested' in value, |
✓ Was returned | 'all' in value || 'allButNested' in value, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· mode = 'all' in value ? 'all' : 'allButNested'; (value.except || []).forEach(function(value) { if (value === '\'') { this._exceptSingleQuote = true; } if (value === '"') { this._exceptDoubleQuote = true; } this._exceptions[value] = true; }, this); if (value.ignoreParenthesizedExpression === true) { this._ignoreParenthesizedExpression = true; } } else { |
✓ Negative was executed (else) | } else {··· mode = value; } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | mode = 'all' in value ? 'all' : 'allButNested'; |
✗ Negative was not returned (: ...) | mode = 'all' in value ? 'all' : 'allButNested'; |
Function (anonymous_1228) | |
---|---|
✓ Was called | (value.except || []).forEach(function(value) {··· if (value === '\'') { this._exceptSingleQuote = true; } if (value === '"') { this._exceptDoubleQuote = true; } this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✓ Was returned | (value.except || []).forEach(function(value) { |
✓ Was returned | (value.except || []).forEach(function(value) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === '\'') {··· this._exceptSingleQuote = true; } |
✓ Negative was executed (else) | }··· if (value === '"') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === '"') {··· this._exceptDoubleQuote = true; } |
✓ Negative was executed (else) | }··· this._exceptions[value] = true; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value.ignoreParenthesizedExpression === true) {··· this._ignoreParenthesizedExpression = true; } |
✓ Negative was executed (else) | }··· } else { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (mode === 'allButNested') {··· this._exceptions[')'] = this._exceptions['('] = true; } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_1229) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideParentheses'; }, |
Function (anonymous_1230) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; var singleQuote = this._exceptSingleQuote; var doubleQuote = this._exceptDoubleQuote; var ignoreParenthesizedExpression = this._ignoreParenthesizedExpression; file.iterateTokensByTypeAndValue('Punctuator', '(', function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.getSourceCode(); if ( ignoreParenthesizedExpression && TokenCategorizer.categorizeOpenParen(token) === 'ParenthesizedExpression' ) { return; } if (value in exceptions) { return; } if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { return; } if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { return; } // Skip for empty parentheses if (value === ')') { return; } errors.assert.whitespaceBetween({ token: token, nextToken: nextToken, message: 'Missing space after opening round bracket' }); }); file.iterateTokensByTypeAndValue('Punctuator', ')', function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.getSourceCode(); if ( ignoreParenthesizedExpression && TokenCategorizer.categorizeCloseParen(token) === 'ParenthesizedExpression' ) { return; } if (value in exceptions) { // Special case - foo( object[i] ) if (!( value === ']' && prevToken.parentElement.type === 'MemberExpression' )) { return; } } if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { return; } if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { return; } // Skip for empty parentheses if (value === '(') { return; } errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before closing round bracket' }); }); } |
Function (anonymous_1231) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', '(', function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.getSourceCode(); if ( ignoreParenthesizedExpression && TokenCategorizer.categorizeOpenParen(token) === 'ParenthesizedExpression' ) { return; } if (value in exceptions) { return; } if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { return; } if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { return; } // Skip for empty parentheses if (value === ')') { return; } errors.assert.whitespaceBetween({ token: token, nextToken: nextToken, message: 'Missing space after opening round bracket' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· if (value in exceptions) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | TokenCategorizer.categorizeOpenParen(token) === 'ParenthesizedExpression' |
✓ Was returned | ignoreParenthesizedExpression && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') {··· return; } |
✓ Negative was executed (else) | }··· if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
Branch LogicalExpression | |
✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
Branch LogicalExpression | |
✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
✓ Was returned | if (doubleQuote && nextToken.type === 'String' && value[0] === '"') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') {··· return; } |
✓ Negative was executed (else) | }··· // Skip for empty parentheses |
Branch LogicalExpression | |
✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
Branch LogicalExpression | |
✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
✓ Was returned | if (singleQuote && nextToken.type === 'String' && value[0] === '\'') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === ')') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Function (anonymous_1232) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ')', function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.getSourceCode(); if ( ignoreParenthesizedExpression && TokenCategorizer.categorizeCloseParen(token) === 'ParenthesizedExpression' ) { return; } if (value in exceptions) { // Special case - foo( object[i] ) if (!( value === ']' && prevToken.parentElement.type === 'MemberExpression' )) { return; } } if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { return; } if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { return; } // Skip for empty parentheses if (value === '(') { return; } errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before closing round bracket' }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· if (value in exceptions) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | TokenCategorizer.categorizeCloseParen(token) === 'ParenthesizedExpression' |
✓ Was returned | ignoreParenthesizedExpression && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value in exceptions) {··· // Special case - foo( object[i] ) if (!( value === ']' && prevToken.parentElement.type === 'MemberExpression' )) { return; } } |
✓ Negative was executed (else) | }··· if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | )) {··· return; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
---|---|
✓ Was returned | prevToken.parentElement.type === 'MemberExpression' |
✓ Was returned | value === ']' && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') {··· return; } |
✓ Negative was executed (else) | }··· if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
Branch LogicalExpression | |
✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
Branch LogicalExpression | |
✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
✓ Was returned | if (doubleQuote && prevToken.type === 'String' && value[value.length - 1] === '"') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') {··· return; } |
✓ Negative was executed (else) | }··· // Skip for empty parentheses |
Branch LogicalExpression | |
✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
Branch LogicalExpression | |
✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
✓ Was returned | if (singleQuote && prevToken.type === 'String' && value[value.length - 1] === '\'') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === '(') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Function (anonymous_1233) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1234) | |
---|---|
✓ Was called | configure: function(value) {··· var isObject = typeof value === 'object'; var error = this.getOptionName() + ' rule requires string value true or object'; if (isObject) { assert('allExcept' in value, error); } else { assert(value === true, error); } this._exceptions = {}; if (isObject) { (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· assert('allExcept' in value, error); } else { |
✓ Negative was executed (else) | } else {··· assert(value === true, error); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isObject) {··· (value.allExcept || []).forEach(function(value) { this._exceptions[value] = true; }, this); } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_1235) | |
---|---|
✓ Was called | (value.allExcept || []).forEach(function(value) {··· this._exceptions[value] = true; }, this); |
Branch LogicalExpression | |
✗ Was not returned | (value.allExcept || []).forEach(function(value) { |
✓ Was returned | (value.allExcept || []).forEach(function(value) { |
Function (anonymous_1236) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpacesInsideParenthesizedExpression'; }, |
Function (anonymous_1237) | |
---|---|
✓ Was called | check: function(file, errors) {··· var exceptions = this._exceptions; file.iterateTokensByTypeAndValue('Punctuator', '(', function(token) { var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.isComment ? nextToken.type === 'CommentBlock' ? '/*' : '//' : nextToken.value; // Skip empty parentheses and explicit exceptions if (value === ')' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeOpenParen(token); if (type !== 'ParenthesizedExpression') { return; } errors.assert.whitespaceBetween({ token: token, nextToken: nextToken, message: 'Missing space after opening grouping parenthesis' }); }); file.iterateTokensByTypeAndValue('Punctuator', ')', function(token) { var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.isComment ? prevToken.type === 'CommentBlock' ? '*/' : '' : prevToken.value; // Skip empty parentheses and explicit exceptions if (value === '(' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeCloseParen(token); if (type !== 'ParenthesizedExpression') { return; } errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before closing grouping parenthesis' }); }); } |
Function (anonymous_1238) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', '(', function(token) {··· var nextToken = file.getNextToken(token, {includeComments: true}); var value = nextToken.isComment ? nextToken.type === 'CommentBlock' ? '/*' : '//' : nextToken.value; // Skip empty parentheses and explicit exceptions if (value === ')' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeOpenParen(token); if (type !== 'ParenthesizedExpression') { return; } errors.assert.whitespaceBetween({ token: token, nextToken: nextToken, message: 'Missing space after opening grouping parenthesis' }); }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | nextToken.type === 'CommentBlock' ? '/*' : '//' : |
✓ Negative was returned (: ...) | nextToken.value; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | nextToken.type === 'CommentBlock' ? '/*' : '//' : |
✓ Negative was returned (: ...) | nextToken.type === 'CommentBlock' ? '/*' : '//' : |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === ')' || value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· // Skip non-expression parentheses |
Branch LogicalExpression | |
✓ Was returned | if (value === ')' || value in exceptions) { |
✓ Was returned | if (value === ')' || value in exceptions) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (type !== 'ParenthesizedExpression') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Function (anonymous_1239) | |
---|---|
✓ Was called | file.iterateTokensByTypeAndValue('Punctuator', ')', function(token) {··· var prevToken = file.getPrevToken(token, {includeComments: true}); var value = prevToken.isComment ? prevToken.type === 'CommentBlock' ? '*/' : '' : prevToken.value; // Skip empty parentheses and explicit exceptions if (value === '(' || value in exceptions) { return; } // Skip non-expression parentheses var type = TokenCategorizer.categorizeCloseParen(token); if (type !== 'ParenthesizedExpression') { return; } errors.assert.whitespaceBetween({ token: prevToken, nextToken: token, message: 'Missing space before closing grouping parenthesis' }); }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | prevToken.type === 'CommentBlock' ? '*/' : '' : |
✓ Negative was returned (: ...) | prevToken.value; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | prevToken.type === 'CommentBlock' ? '*/' : '' : |
✓ Negative was returned (: ...) | prevToken.type === 'CommentBlock' ? '*/' : '' : |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (value === '(' || value in exceptions) {··· return; } |
✓ Negative was executed (else) | }··· // Skip non-expression parentheses |
Branch LogicalExpression | |
✓ Was returned | if (value === '(' || value in exceptions) { |
✓ Was returned | if (value === '(' || value in exceptions) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (type !== 'ParenthesizedExpression') {··· return; } |
✓ Negative was executed (else) | }··· errors.assert.whitespaceBetween({ |
Function (anonymous_1240) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1241) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); }, |
Function (anonymous_1242) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireSpread'; }, |
Function (anonymous_1243) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType('CallExpression', function(node) { var callee = node.callee; var firstParameter = node.arguments[0]; if (node.arguments.length === 2 && callee.property && callee.property.name === 'apply' && callee.object && callee.object.name === firstParameter.name) { errors.add( 'Illegal use of apply method. Use the spread operator instead', node.callee.property ); } }); } |
Function (anonymous_1244) | |
---|---|
✓ Was called | file.iterateNodesByType('CallExpression', function(node) {··· var callee = node.callee; var firstParameter = node.arguments[0]; if (node.arguments.length === 2 && callee.property && callee.property.name === 'apply' && callee.object && callee.object.name === firstParameter.name) { errors.add( 'Illegal use of apply method. Use the spread operator instead', node.callee.property ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | callee.object && callee.object.name === firstParameter.name) {··· errors.add( 'Illegal use of apply method. Use the spread operator instead', node.callee.property ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | callee.object && callee.object.name === firstParameter.name) { |
✓ Was returned | if (node.arguments.length === 2 &&··· callee.property && callee.property.name === 'apply' && callee.object && callee.object.name === firstParameter.name) { |
Branch LogicalExpression | |
✓ Was returned | callee.object && callee.object.name === firstParameter.name) { |
✓ Was returned | if (node.arguments.length === 2 &&··· callee.property && callee.property.name === 'apply' && |
Branch LogicalExpression | |
✓ Was returned | callee.property && callee.property.name === 'apply' && |
✓ Was returned | if (node.arguments.length === 2 &&··· callee.property && callee.property.name === 'apply' && |
Branch LogicalExpression | |
✓ Was returned | callee.property && callee.property.name === 'apply' && |
✓ Was returned | if (node.arguments.length === 2 && |
Function (anonymous_1245) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1246) | |
---|---|
✓ Was called | configure: function(options) {··· this._allowStringConcatenation = false; var optionName = this.getOptionName(); if (typeof options === 'object') { assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" ' + 'to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" ' + 'to have at least one item or be set to `true`'); options.allExcept.forEach(function(except) { if (except === 'stringConcatenation') { this._allowStringConcatenation = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + '"stringConcatenation"'); } }, this); } else { assert( options === true, optionName + ' option requires true value or object' ); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'object') {··· assert(Array.isArray(options.allExcept), optionName + ' option requires "allExcept" ' + 'to be an array'); assert(options.allExcept.length > 0, optionName + ' option requires "allExcept" ' + 'to have at least one item or be set to `true`'); options.allExcept.forEach(function(except) { if (except === 'stringConcatenation') { this._allowStringConcatenation = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + '"stringConcatenation"'); } }, this); } else { |
✓ Negative was executed (else) | } else {··· assert( options === true, optionName + ' option requires true value or object' ); } |
Function (anonymous_1247) | |
---|---|
✓ Was called | options.allExcept.forEach(function(except) {··· if (except === 'stringConcatenation') { this._allowStringConcatenation = true; } else { assert(false, optionName + ' option requires "allExcept" to only have ' + '"stringConcatenation"'); } }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (except === 'stringConcatenation') {··· this._allowStringConcatenation = true; } else { |
✓ Negative was executed (else) | } else {··· assert(false, optionName + ' option requires "allExcept" to only have ' + '"stringConcatenation"'); } |
Function (anonymous_1248) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireTemplateStrings'; }, |
Function (anonymous_1249) | |
---|---|
✓ Was called | check: function(file, errors) {··· var allowStringConcatenation = this._allowStringConcatenation; function add(node) { errors.add( 'Illegal use of string concatenation. Use template strings instead.', node.left ); } file.iterateNodesByType('BinaryExpression', function(node) { if (node.operator !== '+') { return; } var leftIsString = node.left; var rightIsString = node.right; // Left side could also be binary expression (See gh-2050), // but not the right one while (leftIsString.type === 'BinaryExpression') { leftIsString = leftIsString.left; } leftIsString = typeof leftIsString.value === 'string' || leftIsString.type === 'TemplateLiteral'; rightIsString = typeof rightIsString.value === 'string' || rightIsString.type === 'TemplateLiteral'; if (allowStringConcatenation && leftIsString && rightIsString) { return; } // At least one of the operands should be a string or template string, // otherwise this is not a concatenation if (leftIsString || rightIsString) { add(node); } }); } |
Function add | |
---|---|
✓ Was called | function add(node) {··· errors.add( 'Illegal use of string concatenation. Use template strings instead.', node.left ); } |
Function (anonymous_1251) | |
---|---|
✓ Was called | file.iterateNodesByType('BinaryExpression', function(node) {··· if (node.operator !== '+') { return; } var leftIsString = node.left; var rightIsString = node.right; // Left side could also be binary expression (See gh-2050), // but not the right one while (leftIsString.type === 'BinaryExpression') { leftIsString = leftIsString.left; } leftIsString = typeof leftIsString.value === 'string' || leftIsString.type === 'TemplateLiteral'; rightIsString = typeof rightIsString.value === 'string' || rightIsString.type === 'TemplateLiteral'; if (allowStringConcatenation && leftIsString && rightIsString) { return; } // At least one of the operands should be a string or template string, // otherwise this is not a concatenation if (leftIsString || rightIsString) { add(node); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.operator !== '+') {··· return; } |
✓ Negative was executed (else) | }··· var leftIsString = node.left; |
Branch LogicalExpression | |
---|---|
✓ Was returned | leftIsString.type === 'TemplateLiteral'; |
✓ Was returned | leftIsString = typeof leftIsString.value === 'string' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | rightIsString.type === 'TemplateLiteral'; |
✓ Was returned | rightIsString = typeof rightIsString.value === 'string' || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (allowStringConcatenation && leftIsString && rightIsString) {··· return; } |
✓ Negative was executed (else) | }··· // At least one of the operands should be a string or template string, |
Branch LogicalExpression | |
✓ Was returned | if (allowStringConcatenation && leftIsString && rightIsString) { |
✓ Was returned | if (allowStringConcatenation && leftIsString && rightIsString) { |
Branch LogicalExpression | |
✓ Was returned | if (allowStringConcatenation && leftIsString && rightIsString) { |
✓ Was returned | if (allowStringConcatenation && leftIsString && rightIsString) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (leftIsString || rightIsString) {··· add(node); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (leftIsString || rightIsString) { |
✓ Was returned | if (leftIsString || rightIsString) { |
Function (anonymous_1252) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1253) | |
---|---|
✓ Was called | configure: function(options) {··· if (typeof options === 'object') { if ('ignoreSingleValue' in options) { assert( options.ignoreSingleValue === true, this.getOptionName() + ' option ignoreSingleValue requires true value or should be removed' ); this._ignoreSingleValue = true; } if ('ignoreSingleLine' in options) { assert( options.ignoreSingleLine === true, this.getOptionName() + ' option ignoreSingleLine requires true value or should be removed' ); this._ignoreSingleLine = true; } } else { assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'object') {··· if ('ignoreSingleValue' in options) { assert( options.ignoreSingleValue === true, this.getOptionName() + ' option ignoreSingleValue requires true value or should be removed' ); this._ignoreSingleValue = true; } if ('ignoreSingleLine' in options) { assert( options.ignoreSingleLine === true, this.getOptionName() + ' option ignoreSingleLine requires true value or should be removed' ); this._ignoreSingleLine = true; } } else { |
✓ Negative was executed (else) | } else {··· assert( options === true, this.getOptionName() + ' option requires a true value or should be removed' ); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('ignoreSingleValue' in options) {··· assert( options.ignoreSingleValue === true, this.getOptionName() + ' option ignoreSingleValue requires true value or should be removed' ); this._ignoreSingleValue = true; } |
✓ Negative was executed (else) | }··· if ('ignoreSingleLine' in options) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('ignoreSingleLine' in options) {··· assert( options.ignoreSingleLine === true, this.getOptionName() + ' option ignoreSingleLine requires true value or should be removed' ); this._ignoreSingleLine = true; } |
✓ Negative was executed (else) | }··· } else { |
Function (anonymous_1254) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireTrailingComma'; }, |
Function (anonymous_1255) | |
---|---|
✓ Was called | check: function(file, errors) {··· var _this = this; file.iterateNodesByType([ 'ObjectExpression', 'ArrayExpression', 'ObjectPattern', 'ArrayPattern' ], function(node) { var isLikeObject = node.type === 'ObjectExpression' || node.type === 'ObjectPattern'; var entities = isLikeObject ? node.properties : node.elements; if (entities.length === 0) { return; } if (_this._ignoreSingleValue && entities.length === 1) { return; } if (_this._ignoreSingleLine && node.getNewlineCount() === 0) { return; } var possibleComma = file.getLastNodeToken(node).getPreviousCodeToken(); if (possibleComma.value !== ',') { errors.cast({ message: 'Missing comma before closing ' + (isLikeObject ? 'curly brace' : 'bracket'), element: possibleComma, additional: node }); } }); }, |
Function (anonymous_1256) | |
---|---|
✓ Was called | ], function(node) {··· var isLikeObject = node.type === 'ObjectExpression' || node.type === 'ObjectPattern'; var entities = isLikeObject ? node.properties : node.elements; if (entities.length === 0) { return; } if (_this._ignoreSingleValue && entities.length === 1) { return; } if (_this._ignoreSingleLine && node.getNewlineCount() === 0) { return; } var possibleComma = file.getLastNodeToken(node).getPreviousCodeToken(); if (possibleComma.value !== ',') { errors.cast({ message: 'Missing comma before closing ' + (isLikeObject ? 'curly brace' : 'bracket'), element: possibleComma, additional: node }); } }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | var isLikeObject = node.type === 'ObjectExpression' || node.type === 'ObjectPattern'; |
✓ Was returned | var isLikeObject = node.type === 'ObjectExpression' || node.type === 'ObjectPattern'; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var entities = isLikeObject ? node.properties : node.elements; |
✓ Negative was returned (: ...) | var entities = isLikeObject ? node.properties : node.elements; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (entities.length === 0) {··· return; } |
✓ Negative was executed (else) | }··· if (_this._ignoreSingleValue && entities.length === 1) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._ignoreSingleValue && entities.length === 1) {··· return; } |
✓ Negative was executed (else) | }··· if (_this._ignoreSingleLine && node.getNewlineCount() === 0) { |
Branch LogicalExpression | |
✓ Was returned | if (_this._ignoreSingleValue && entities.length === 1) { |
✓ Was returned | if (_this._ignoreSingleValue && entities.length === 1) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (_this._ignoreSingleLine && node.getNewlineCount() === 0) {··· return; } |
✓ Negative was executed (else) | }··· var possibleComma = file.getLastNodeToken(node).getPreviousCodeToken(); |
Branch LogicalExpression | |
✓ Was returned | if (_this._ignoreSingleLine && node.getNewlineCount() === 0) { |
✓ Was returned | if (_this._ignoreSingleLine && node.getNewlineCount() === 0) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (possibleComma.value !== ',') {··· errors.cast({ message: 'Missing comma before closing ' + (isLikeObject ? 'curly brace' : 'bracket'), element: possibleComma, additional: node }); } |
✓ Negative was executed (else) | }··· }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | message: 'Missing comma before closing ' + (isLikeObject ? 'curly brace' : 'bracket'), |
✓ Negative was returned (: ...) | message: 'Missing comma before closing ' + (isLikeObject ? 'curly brace' : 'bracket'), |
Function (anonymous_1257) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var parent = error.additional; var afterProp; // ArrayPattern/ArrayExpression if (parent.type.indexOf('Array') === 0) { afterProp = parent.elements[parent.elements.length - 1].lastChild.getNextToken(); // ObjectExpression/ObjectPattern } else { afterProp = parent.properties[parent.properties.length - 1].lastChild.getNextToken(); } parent.insertChildBefore(new Token('Punctuator', ','), afterProp); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parent.type.indexOf('Array') === 0) {··· afterProp = parent.elements[parent.elements.length - 1].lastChild.getNextToken(); // ObjectExpression/ObjectPattern } else { |
✓ Negative was executed (else) | } else {··· afterProp = parent.properties[parent.properties.length - 1].lastChild.getNextToken(); } |
Function (anonymous_1258) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1259) | |
---|---|
✓ Was called | configure: function(options) {··· if (typeof options !== 'object') { assert( options === true, this.getOptionName() + ' option requires either a true value or an object' ); var _options = {files: true}; return this.configure(_options); } this._checkFiles = (options.files === true); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options !== 'object') {··· assert( options === true, this.getOptionName() + ' option requires either a true value or an object' ); var _options = {files: true}; return this.configure(_options); } |
✓ Negative was executed (else) | }··· this._checkFiles = (options.files === true); |
Function (anonymous_1260) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireUseStrict'; }, |
Function (anonymous_1261) | |
---|---|
✓ Was called | check: function(file, errors) {··· var program = file.getProgram(); var directive = program.directives[0]; if (directive) { return; } errors.add( '`"use strict";` is required at the top of each file', program ); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (directive) {··· return; } |
✓ Negative was executed (else) | }··· errors.add( |
Function isScopeElement | |
---|---|
✓ Was called | function isScopeElement(elem) {··· return elem.type === 'Program' || elem.type === 'BlockStatement' && ( elem.parentElement.type === 'FunctionExpression' || elem.parentElement.type === 'FunctionDeclaration' || elem.parentElement.type === 'ArrowFunctionExpression' ); } |
Branch LogicalExpression | |
---|---|
✓ Was returned | elem.type === 'BlockStatement' && (··· elem.parentElement.type === 'FunctionExpression' || elem.parentElement.type === 'FunctionDeclaration' || elem.parentElement.type === 'ArrowFunctionExpression' ); |
✓ Was returned | return elem.type === 'Program' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | elem.parentElement.type === 'FunctionExpression' ||··· elem.parentElement.type === 'FunctionDeclaration' || elem.parentElement.type === 'ArrowFunctionExpression' |
✗ Was not returned | elem.type === 'BlockStatement' && ( |
Branch LogicalExpression | |
---|---|
✓ Was returned | elem.parentElement.type === 'ArrowFunctionExpression' |
✓ Was returned | elem.parentElement.type === 'FunctionExpression' ||··· elem.parentElement.type === 'FunctionDeclaration' || |
Branch LogicalExpression | |
✓ Was returned | elem.parentElement.type === 'FunctionDeclaration' || |
✓ Was returned | elem.parentElement.type === 'FunctionExpression' || |
Function isRelevantElement | |
---|---|
✓ Was called | function isRelevantElement(elem) {··· // Allow comments and whitespaces. var itIs = elem.isComment || elem.isWhitespace; // Variable declaration itself. itIs = itIs || elem.type === 'VariableDeclaration'; // For '{' in `function() { var a; }`. itIs = itIs || elem.type === 'Punctuator'; // Skip 'use strict' statements at the beginning. itIs = itIs || elem.type === 'Directive'; return itIs; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | var itIs = elem.isComment || elem.isWhitespace; |
✓ Was returned | var itIs = elem.isComment || elem.isWhitespace; |
Branch LogicalExpression | |
---|---|
✓ Was returned | itIs = itIs || elem.type === 'VariableDeclaration'; |
✓ Was returned | itIs = itIs || elem.type === 'VariableDeclaration'; |
Branch LogicalExpression | |
---|---|
✓ Was returned | itIs = itIs || elem.type === 'Punctuator'; |
✓ Was returned | itIs = itIs || elem.type === 'Punctuator'; |
Branch LogicalExpression | |
---|---|
✓ Was returned | itIs = itIs || elem.type === 'Directive'; |
✓ Was returned | itIs = itIs || elem.type === 'Directive'; |
Function isVarDeclFirst | |
---|---|
✓ Was called | function isVarDeclFirst(varDecl) {··· var elem = varDecl; // All elements should be relevant. while (elem && isRelevantElement(elem)) { elem = elem.previousSibling; } return elem === null; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | while (elem && isRelevantElement(elem)) { |
✓ Was returned | while (elem && isRelevantElement(elem)) { |
Function (anonymous_1265) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1266) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true, this.getOptionName() + ' option requires a true value' ); }, |
Function (anonymous_1267) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireVarDeclFirst'; }, |
Function (anonymous_1268) | |
---|---|
✓ Was called | check: function(file, errors) {··· file.iterateNodesByType(['VariableDeclaration'], function(varDecl) { // Ignore let and const for now #1783 if (varDecl.kind !== 'var') { return; } // Checking scope to not allow vars inside block statements. if (isScopeElement(varDecl.parentElement) && isVarDeclFirst(varDecl)) { return; } errors.add('Variable declarations must be the first statements of a function scope.', varDecl); }); } |
Function (anonymous_1269) | |
---|---|
✓ Was called | file.iterateNodesByType(['VariableDeclaration'], function(varDecl) {··· // Ignore let and const for now #1783 if (varDecl.kind !== 'var') { return; } // Checking scope to not allow vars inside block statements. if (isScopeElement(varDecl.parentElement) && isVarDeclFirst(varDecl)) { return; } errors.add('Variable declarations must be the first statements of a function scope.', varDecl); }); |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (varDecl.kind !== 'var') {··· return; } |
✓ Negative was executed (else) | }··· // Checking scope to not allow vars inside block statements. |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isScopeElement(varDecl.parentElement) && isVarDeclFirst(varDecl)) {··· return; } |
✓ Negative was executed (else) | }··· errors.add('Variable declarations must be the first statements of a function scope.', |
Branch LogicalExpression | |
✓ Was returned | if (isScopeElement(varDecl.parentElement) && isVarDeclFirst(varDecl)) { |
✓ Was returned | if (isScopeElement(varDecl.parentElement) && isVarDeclFirst(varDecl)) { |
Function (anonymous_1270) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1271) | |
---|---|
✓ Was called | configure: function(operators) {··· var isTrue = operators === true; assert( Array.isArray(operators) || isTrue, this.getOptionName() + ' option requires array or true value' ); if (isTrue) { operators = ['==', '===', '!=', '!==']; } this._operatorIndex = {}; for (var i = 0, l = operators.length; i < l; i++) { this._operatorIndex[operators[i]] = true; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(operators) || isTrue, |
✓ Was returned | Array.isArray(operators) || isTrue, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isTrue) {··· operators = ['==', '===', '!=', '!==']; } |
✓ Negative was executed (else) | }··· this._operatorIndex = {}; |
Function (anonymous_1272) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'requireYodaConditions'; }, |
Function (anonymous_1273) | |
---|---|
✓ Was called | check: function(file, errors) {··· var operators = this._operatorIndex; file.iterateNodesByType('BinaryExpression', function(node) { if (operators[node.operator]) { if ( node.right.type.indexOf('Literal') > -1 || (node.right.type === 'Identifier' && node.right.name === 'undefined') ) { errors.add('Not yoda condition', node.left); } } }); } |
Function (anonymous_1274) | |
---|---|
✓ Was called | file.iterateNodesByType('BinaryExpression', function(node) {··· if (operators[node.operator]) { if ( node.right.type.indexOf('Literal') > -1 || (node.right.type === 'Identifier' && node.right.name === 'undefined') ) { errors.add('Not yoda condition', node.left); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (operators[node.operator]) {··· if ( node.right.type.indexOf('Literal') > -1 || (node.right.type === 'Identifier' && node.right.name === 'undefined') ) { errors.add('Not yoda condition', node.left); } } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add('Not yoda condition', node.left); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.right.type === 'Identifier' && node.right.name === 'undefined') |
✓ Was returned | node.right.type.indexOf('Literal') > -1 || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.right.type === 'Identifier' && node.right.name === 'undefined') |
✓ Was returned | (node.right.type === 'Identifier' && node.right.name === 'undefined') |
Function (anonymous_1275) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1276) | |
---|---|
✓ Was called | configure: function(keywords) {··· assert( Array.isArray(keywords) || typeof keywords === 'string', this.getOptionName() + ' option requires string or array value' ); this._keywords = keywords; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | Array.isArray(keywords) || typeof keywords === 'string', |
✓ Was returned | Array.isArray(keywords) || typeof keywords === 'string', |
Function (anonymous_1277) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'safeContextKeyword'; }, |
Function (anonymous_1278) | |
---|---|
✓ Was called | check: function(file, errors) {··· var keywords = typeof this._keywords === 'string' ? [this._keywords] : this._keywords; // var that = this file.iterateNodesByType('VariableDeclaration', function(node) { for (var i = 0; i < node.declarations.length; i++) { var decl = node.declarations[i]; // Miss destructing assignment (#1699, #2119) if (decl.firstChild.type === 'ObjectPattern') { continue; } // decl.init === null in case of "var foo;" if (decl.init && (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) ) { errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node ); } } }); // that = this file.iterateNodesByType('AssignmentExpression', function(node) { if ( // filter property assignments "foo.bar = this" node.left.type === 'Identifier' && (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) ) { errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node ); } }); } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var keywords = typeof this._keywords === 'string' ? [this._keywords] : this._keywords; |
✓ Negative was returned (: ...) | var keywords = typeof this._keywords === 'string' ? [this._keywords] : this._keywords; |
Function (anonymous_1279) | |
---|---|
✓ Was called | file.iterateNodesByType('VariableDeclaration', function(node) {··· for (var i = 0; i < node.declarations.length; i++) { var decl = node.declarations[i]; // Miss destructing assignment (#1699, #2119) if (decl.firstChild.type === 'ObjectPattern') { continue; } // decl.init === null in case of "var foo;" if (decl.init && (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) ) { errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node ); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (decl.firstChild.type === 'ObjectPattern') {··· continue; } |
✓ Negative was executed (else) | }··· // decl.init === null in case of "var foo;" |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node ); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) |
✓ Was returned | if (decl.init && |
Branch LogicalExpression | |
---|---|
✓ Was returned | (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) |
✓ Was returned | (decl.init.type === 'ThisExpression' && checkKeywords(decl.id.name, keywords)) |
Function (anonymous_1280) | |
---|---|
✓ Was called | file.iterateNodesByType('AssignmentExpression', function(node) {··· if ( // filter property assignments "foo.bar = this" node.left.type === 'Identifier' && (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) ) { errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· errors.add( 'You should use "' + keywords.join('" or "') + '" to save a reference to "this"', node ); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) |
✓ Was returned | node.left.type === 'Identifier' && |
Branch LogicalExpression | |
---|---|
✓ Was returned | (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) |
✓ Was returned | (node.right.type === 'ThisExpression' && checkKeywords(node.left.name, keywords)) |
Function checkKeywords | |
---|---|
✓ Was called | function checkKeywords(name, keywords) {··· for (var i = 0; i < keywords.length; i++) { if (name === keywords[i]) { return false; } } return true; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (name === keywords[i]) {··· return false; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_1282) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1283) | |
---|---|
✓ Was called | configure: function(options) {··· var validProperties = [ 'lineBreakAfterOpeningBrace', 'lineBreakBeforeClosingBrace' ]; var optionName = this.getOptionName(); assert( typeof options === 'object' || options === true, optionName + ' option must be an object or boolean true' ); if (typeof options === 'object') { validProperties.forEach(function(key) { var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } }); validProperties.forEach(function(property) { this['_' + property] = Boolean(options[property]); }.bind(this)); } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof options === 'object' || options === true, |
✓ Was returned | typeof options === 'object' || options === true, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'object') {··· validProperties.forEach(function(key) { var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } }); validProperties.forEach(function(property) { this['_' + property] = Boolean(options[property]); }.bind(this)); } |
✓ Negative was executed (else) | }··· }, |
Function (anonymous_1284) | |
---|---|
✓ Was called | validProperties.forEach(function(key) {··· var isPresent = key in options; if (isPresent) { assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isPresent) {··· assert( options[key] === true, optionName + '.' + key + ' property requires true value or should be removed' ); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1285) | |
---|---|
✓ Was called | validProperties.forEach(function(property) {··· this['_' + property] = Boolean(options[property]); }.bind(this)); |
Function (anonymous_1286) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'validateAlignedFunctionParameters'; }, |
Function (anonymous_1287) | |
---|---|
✓ Was called | check: function(file, errors) {··· var lineBreakAfterOpeningBrace = this._lineBreakAfterOpeningBrace; var lineBreakBeforeClosingBrace = this._lineBreakBeforeClosingBrace; file.iterateNodesByType([ 'FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression' ], function(node) { // ignore this rule if there are no parameters if (node.params.length === 0) { return; } // ignore this rule if the parameters are not multi-line var firstParameter = file.getFirstNodeToken(node.params[0]); var lastParameter = node.params[node.params.length - 1]; if (file.isOnTheSameLine(firstParameter, lastParameter)) { return; } // look for the furthest parameter start position var maxParamStartPos = 0; node.params.forEach(function(parameter) { maxParamStartPos = Math.max(maxParamStartPos, parameter.getLoc().start.column); }); // make sure all parameters are lined up node.params.forEach(function(parameter) { if (parameter.getLoc().start.column !== maxParamStartPos) { errors.add('Multi-line parameters are not aligned.', parameter); } }); // make sure the first parameter is on a new line if (lineBreakAfterOpeningBrace) { var openingBrace = file.getPrevToken(firstParameter); errors.assert.differentLine({ token: openingBrace, nextToken: firstParameter, message: 'There is no line break after the opening brace' }); } // make sure the closing brace is on a new line if (lineBreakBeforeClosingBrace) { var bodyToken = file.getFirstNodeToken(node.body); var closingBrace = file.getPrevToken(bodyToken); errors.assert.differentLine({ token: lastParameter, nextToken: closingBrace, message: 'There is no line break before the closing brace' }); } }); } |
Function (anonymous_1288) | |
---|---|
✓ Was called | ], function(node) {··· // ignore this rule if there are no parameters if (node.params.length === 0) { return; } // ignore this rule if the parameters are not multi-line var firstParameter = file.getFirstNodeToken(node.params[0]); var lastParameter = node.params[node.params.length - 1]; if (file.isOnTheSameLine(firstParameter, lastParameter)) { return; } // look for the furthest parameter start position var maxParamStartPos = 0; node.params.forEach(function(parameter) { maxParamStartPos = Math.max(maxParamStartPos, parameter.getLoc().start.column); }); // make sure all parameters are lined up node.params.forEach(function(parameter) { if (parameter.getLoc().start.column !== maxParamStartPos) { errors.add('Multi-line parameters are not aligned.', parameter); } }); // make sure the first parameter is on a new line if (lineBreakAfterOpeningBrace) { var openingBrace = file.getPrevToken(firstParameter); errors.assert.differentLine({ token: openingBrace, nextToken: firstParameter, message: 'There is no line break after the opening brace' }); } // make sure the closing brace is on a new line if (lineBreakBeforeClosingBrace) { var bodyToken = file.getFirstNodeToken(node.body); var closingBrace = file.getPrevToken(bodyToken); errors.assert.differentLine({ token: lastParameter, nextToken: closingBrace, message: 'There is no line break before the closing brace' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (node.params.length === 0) {··· return; } |
✓ Negative was executed (else) | }··· // ignore this rule if the parameters are not multi-line |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (file.isOnTheSameLine(firstParameter, lastParameter)) {··· return; } |
✓ Negative was executed (else) | }··· // look for the furthest parameter start position |
Function (anonymous_1289) | |
---|---|
✓ Was called | node.params.forEach(function(parameter) {··· maxParamStartPos = Math.max(maxParamStartPos, parameter.getLoc().start.column); }); |
Function (anonymous_1290) | |
---|---|
✓ Was called | node.params.forEach(function(parameter) {··· if (parameter.getLoc().start.column !== maxParamStartPos) { errors.add('Multi-line parameters are not aligned.', parameter); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parameter.getLoc().start.column !== maxParamStartPos) {··· errors.add('Multi-line parameters are not aligned.', parameter); } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lineBreakAfterOpeningBrace) {··· var openingBrace = file.getPrevToken(firstParameter); errors.assert.differentLine({ token: openingBrace, nextToken: firstParameter, message: 'There is no line break after the opening brace' }); } |
✓ Negative was executed (else) | }··· // make sure the closing brace is on a new line |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lineBreakBeforeClosingBrace) {··· var bodyToken = file.getFirstNodeToken(node.body); var closingBrace = file.getPrevToken(bodyToken); errors.assert.differentLine({ token: lastParameter, nextToken: closingBrace, message: 'There is no line break before the closing brace' }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1291) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1292) | |
---|---|
✓ Was called | configure: function(options) {··· var validPositions = { 'above': 'above', 'beside': 'beside' }; var allExcept = options.allExcept; assert( typeof options === 'object' && validPositions[options.position], this.getOptionName() + ' requires one of the following values: ' + Object.keys(validPositions).join(', ') ); if (Array.isArray(allExcept)) { assert( allExcept.every(function(el) { return typeof el === 'string'; }), 'Property `allExcept` in ' + allExcept + ' should be an array of strings' ); this._isExcepted = isPragma(allExcept); } else { this._isExcepted = isPragma(); } this._position = options.position; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof options === 'object' && validPositions[options.position], |
✓ Was returned | typeof options === 'object' && validPositions[options.position], |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Array.isArray(allExcept)) {··· assert( allExcept.every(function(el) { return typeof el === 'string'; }), 'Property `allExcept` in ' + allExcept + ' should be an array of strings' ); this._isExcepted = isPragma(allExcept); } else { |
✓ Negative was executed (else) | } else {··· this._isExcepted = isPragma(); } |
Function (anonymous_1293) | |
---|---|
✓ Was called | allExcept.every(function(el) { return typeof el === 'string'; }), |
Function (anonymous_1294) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'validateCommentPosition'; }, |
Function (anonymous_1295) | |
---|---|
✓ Was called | check: function(file, errors) {··· var position = this._position; var isExcepted = this._isExcepted; file.iterateTokensByType('CommentLine', function(comment) { if (isExcepted(comment.value)) { return; } var isFirstToken = true; var currentToken = comment.getPreviousToken(); while (currentToken) { if (currentToken.isWhitespace) { if (currentToken.getNewlineCount() > 0) { break; } } else { isFirstToken = false; } currentToken = currentToken.getPreviousToken(); } if (position === 'above' && !isFirstToken) { errors.add('Expected comments to be above the code not beside', comment); } if (position === 'beside' && isFirstToken) { errors.add('Expected comments to be beside the code not above', comment); } }); } |
Function (anonymous_1296) | |
---|---|
✓ Was called | file.iterateTokensByType('CommentLine', function(comment) {··· if (isExcepted(comment.value)) { return; } var isFirstToken = true; var currentToken = comment.getPreviousToken(); while (currentToken) { if (currentToken.isWhitespace) { if (currentToken.getNewlineCount() > 0) { break; } } else { isFirstToken = false; } currentToken = currentToken.getPreviousToken(); } if (position === 'above' && !isFirstToken) { errors.add('Expected comments to be above the code not beside', comment); } if (position === 'beside' && isFirstToken) { errors.add('Expected comments to be beside the code not above', comment); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isExcepted(comment.value)) {··· return; } |
✓ Negative was executed (else) | }··· var isFirstToken = true; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken.isWhitespace) {··· if (currentToken.getNewlineCount() > 0) { break; } } else { |
✓ Negative was executed (else) | } else {··· isFirstToken = false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken.getNewlineCount() > 0) {··· break; } |
✓ Negative was executed (else) | }··· } else { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (position === 'above' && !isFirstToken) {··· errors.add('Expected comments to be above the code not beside', comment); } |
✓ Negative was executed (else) | }··· if (position === 'beside' && isFirstToken) { |
Branch LogicalExpression | |
✓ Was returned | if (position === 'above' && !isFirstToken) { |
✓ Was returned | if (position === 'above' && !isFirstToken) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (position === 'beside' && isFirstToken) {··· errors.add('Expected comments to be beside the code not above', comment); } |
✓ Negative was executed (else) | }··· }); |
Branch LogicalExpression | |
✓ Was returned | if (position === 'beside' && isFirstToken) { |
✓ Was returned | if (position === 'beside' && isFirstToken) { |
Function getLineData | |
---|---|
✓ Was called | function getLineData(code) {··· var lines = []; var lastPos = 0; LINE_SEPARATOR.lastIndex = 0; var match; while ((match = LINE_SEPARATOR.exec(code)) !== null) { var separatorLength = match[0].length; lines.push({ line: code.slice(lastPos, match.index), separator: code.substr(match.index, separatorLength), offset: lastPos }); lastPos = match.index + separatorLength; } lines.push({line: code.slice(lastPos), offset: lastPos, separator: ''}); return lines; } |
Function convertLinesToString | |
---|---|
✓ Was called | function convertLinesToString(lines) {··· return lines .map(function(lineItem) { return lineItem.line + lineItem.separator; }) .join(''); } |
Function (anonymous_1299) | |
---|---|
✓ Was called | .map(function(lineItem) {··· return lineItem.line + lineItem.separator; }) |
Function applyIndentationDiff | |
---|---|
✓ Was called | function applyIndentationDiff(code, diff, indentChar, includeEmptyLines) {··· var lines = getLineData(code); for (var i = 1; i < lines.length; i++) { var lineData = lines[i]; var currentIndent; if (lineData.line.length === 0 && i !== lines.length - 1 && !includeEmptyLines) { continue; } var match = NON_WHITESPACE.exec(lineData.line); if (match) { currentIndent = match.index; } else { currentIndent = lineData.line.length; } lineData.line = new Array(Math.max(currentIndent + diff, 0) + 1).join(indentChar) + lineData.line.slice(currentIndent); } return convertLinesToString(lines); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lineData.line.length === 0 && i !== lines.length - 1 && !includeEmptyLines) {··· continue; } |
✓ Negative was executed (else) | }··· var match = NON_WHITESPACE.exec(lineData.line); |
Branch LogicalExpression | |
✓ Was returned | if (lineData.line.length === 0 && i !== lines.length - 1 && !includeEmptyLines) { |
✓ Was returned | if (lineData.line.length === 0 && i !== lines.length - 1 && !includeEmptyLines) { |
Branch LogicalExpression | |
✓ Was returned | if (lineData.line.length === 0 && i !== lines.length - 1 && !includeEmptyLines) { |
✓ Was returned | if (lineData.line.length === 0 && i !== lines.length - 1 && !includeEmptyLines) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (match) {··· currentIndent = match.index; } else { |
✓ Negative was executed (else) | } else {··· currentIndent = lineData.line.length; } |
Function isFunctionExpression | |
---|---|
✓ Was called | function isFunctionExpression(node) {··· return node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression'; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | return node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression'; |
✓ Was returned | return node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression'; |
Function getModuleBody | |
---|---|
✓ Was called | function getModuleBody(program) {··· if (program.body.length !== 1) { return null; } if (program.body[0].type !== 'ExpressionStatement') { return null; } var expression = program.body[0].expression; if (expression.type === 'CallExpression') { var callee = expression.callee; var args = expression.arguments; // full file IIFE if (isFunctionExpression(callee)) { // detect UMD Shim, where the file body is the body of the factory, // which is the sole argument to the IIFE if (args.length === 1 && isFunctionExpression(args[0])) { return args[0].body; } else { return callee.body; } } // full file IIFE with call/apply if ( callee.type === 'MemberExpression' && callee.property.type === 'Identifier' && (callee.property.name === 'apply' || callee.property.name === 'call') ) { if (isFunctionExpression(callee.object)) { return callee.object.body; } } // require / define if (callee.type === 'Identifier' && (callee.name === 'define' || callee.name === 'require')) { for (var i = 0; i < args.length; i++) { var arg = args[i]; if (isFunctionExpression(arg)) { return arg.body; } } } } return null; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (program.body.length !== 1) {··· return null; } |
✓ Negative was executed (else) | }··· if (program.body[0].type !== 'ExpressionStatement') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (program.body[0].type !== 'ExpressionStatement') {··· return null; } |
✓ Negative was executed (else) | }··· var expression = program.body[0].expression; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (expression.type === 'CallExpression') {··· var callee = expression.callee; var args = expression.arguments; // full file IIFE if (isFunctionExpression(callee)) { // detect UMD Shim, where the file body is the body of the factory, // which is the sole argument to the IIFE if (args.length === 1 && isFunctionExpression(args[0])) { return args[0].body; } else { return callee.body; } } // full file IIFE with call/apply if ( callee.type === 'MemberExpression' && callee.property.type === 'Identifier' && (callee.property.name === 'apply' || callee.property.name === 'call') ) { if (isFunctionExpression(callee.object)) { return callee.object.body; } } // require / define if (callee.type === 'Identifier' && (callee.name === 'define' || callee.name === 'require')) { for (var i = 0; i < args.length; i++) { var arg = args[i]; if (isFunctionExpression(arg)) { return arg.body; } } } } |
✓ Negative was executed (else) | }··· return null; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isFunctionExpression(callee)) {··· // detect UMD Shim, where the file body is the body of the factory, // which is the sole argument to the IIFE if (args.length === 1 && isFunctionExpression(args[0])) { return args[0].body; } else { return callee.body; } } |
✓ Negative was executed (else) | }··· // full file IIFE with call/apply |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (args.length === 1 && isFunctionExpression(args[0])) {··· return args[0].body; } else { |
✓ Negative was executed (else) | } else {··· return callee.body; } |
Branch LogicalExpression | |
✓ Was returned | if (args.length === 1 && isFunctionExpression(args[0])) { |
✗ Was not returned | if (args.length === 1 && isFunctionExpression(args[0])) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· if (isFunctionExpression(callee.object)) { return callee.object.body; } } |
✓ Negative was executed (else) | }··· // require / define |
Branch LogicalExpression | |
---|---|
✓ Was returned | (callee.property.name === 'apply' || callee.property.name === 'call') |
✓ Was returned | callee.type === 'MemberExpression' &&··· callee.property.type === 'Identifier' && |
Branch LogicalExpression | |
✓ Was returned | callee.property.type === 'Identifier' && |
✓ Was returned | callee.type === 'MemberExpression' && |
Branch LogicalExpression | |
---|---|
✓ Was returned | (callee.property.name === 'apply' || callee.property.name === 'call') |
✓ Was returned | (callee.property.name === 'apply' || callee.property.name === 'call') |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isFunctionExpression(callee.object)) {··· return callee.object.body; } |
✗ Negative was not executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (callee.type === 'Identifier' && (callee.name === 'define' || callee.name === 'require')) {··· for (var i = 0; i < args.length; i++) { var arg = args[i]; if (isFunctionExpression(arg)) { return arg.body; } } } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (callee.type === 'Identifier' && (callee.name === 'define' || callee.name === 'require')) { |
✗ Was not returned | if (callee.type === 'Identifier' && (callee.name === 'define' || callee.name === 'require')) { |
Branch LogicalExpression | |
✓ Was returned | if (callee.type === 'Identifier' && (callee.name === 'define' || callee.name === 'require')) { |
✓ Was returned | if (callee.type === 'Identifier' && (callee.name === 'define' || callee.name === 'require')) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isFunctionExpression(arg)) {··· return arg.body; } |
✓ Negative was executed (else) | }··· } |
Function isBlockOnTheSameLineWithCase | |
---|---|
✓ Was called | function isBlockOnTheSameLineWithCase(element) {··· var currentSwitchElement = element.parentElement .consequent[0] .getPreviousCodeToken() .nextSibling; while (currentSwitchElement) { if (currentSwitchElement === element) { return true; } if (currentSwitchElement.getNewlineCount() > 0) { break; } currentSwitchElement = currentSwitchElement.nextSibling; } return false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentSwitchElement === element) {··· return true; } |
✓ Negative was executed (else) | }··· if (currentSwitchElement.getNewlineCount() > 0) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentSwitchElement.getNewlineCount() > 0) {··· break; } |
✓ Negative was executed (else) | }··· currentSwitchElement = currentSwitchElement.nextSibling; |
Function hasFollowingClause | |
---|---|
✓ Was called | function hasFollowingClause(blockStatement) {··· var parent = blockStatement.parentElement; if (parent.type === 'IfStatement') { return parent.consequent === blockStatement && parent.alternate; } if (parent.type === 'TryStatement') { return true; } if (parent.type === 'DoWhileStatement') { return true; } if (parent.type === 'CatchClause') { return parent.parentElement.finalizer; } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parent.type === 'IfStatement') {··· return parent.consequent === blockStatement && parent.alternate; } |
✓ Negative was executed (else) | }··· if (parent.type === 'TryStatement') { |
Branch LogicalExpression | |
---|---|
✓ Was returned | return parent.consequent === blockStatement && parent.alternate; |
✗ Was not returned | return parent.consequent === blockStatement && parent.alternate; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parent.type === 'TryStatement') {··· return true; } |
✓ Negative was executed (else) | }··· if (parent.type === 'DoWhileStatement') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parent.type === 'DoWhileStatement') {··· return true; } |
✓ Negative was executed (else) | }··· if (parent.type === 'CatchClause') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parent.type === 'CatchClause') {··· return parent.parentElement.finalizer; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_1305) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1306) | |
---|---|
✓ Was called | configure: function(options) {··· this._includeEmptyLines = false; this._exceptComments = false; if (typeof options === 'object') { this._includeEmptyLines = (options.includeEmptyLines === true); if (Array.isArray(options.allExcept)) { this._exceptComments = options.allExcept.indexOf('comments') > -1; this._includeEmptyLines = options.allExcept.indexOf('emptyLines') === -1; } options = options.value; } assert( options === '\t' || (typeof options === 'number' && options > 0), this.getOptionName() + ' option requires a positive number of spaces or "\\t"' + ' or options object with "value" property' ); if (typeof options === 'number') { this._indentChar = ' '; this._nonIndentChar = '\t'; this._indentSize = options; } else { this._nonIndentChar = ' '; this._indentChar = '\t'; this._indentSize = 1; } this._indentBreaks = null; this._indentModuleBodies = null; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'object') {··· this._includeEmptyLines = (options.includeEmptyLines === true); if (Array.isArray(options.allExcept)) { this._exceptComments = options.allExcept.indexOf('comments') > -1; this._includeEmptyLines = options.allExcept.indexOf('emptyLines') === -1; } options = options.value; } |
✓ Negative was executed (else) | }··· assert( |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (Array.isArray(options.allExcept)) {··· this._exceptComments = options.allExcept.indexOf('comments') > -1; this._includeEmptyLines = options.allExcept.indexOf('emptyLines') === -1; } |
✓ Negative was executed (else) | }··· options = options.value; |
Branch LogicalExpression | |
---|---|
✓ Was returned | (typeof options === 'number' && options > 0), |
✓ Was returned | options === '\t' || |
Branch LogicalExpression | |
---|---|
✓ Was returned | (typeof options === 'number' && options > 0), |
✓ Was returned | (typeof options === 'number' && options > 0), |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'number') {··· this._indentChar = ' '; this._nonIndentChar = '\t'; this._indentSize = options; } else { |
✓ Negative was executed (else) | } else {··· this._nonIndentChar = ' '; this._indentChar = '\t'; this._indentSize = 1; } |
Function (anonymous_1307) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'validateIndentation'; }, |
Function (anonymous_1308) | |
---|---|
✓ Was called | _getFunctionIndent: function(functionExpression, indent) {··· var functionIndent = 0; var indentBeforeClosingBrace = this._getElementDirectIndent(functionExpression.body.lastChild); if (indentBeforeClosingBrace !== null) { functionIndent = indentBeforeClosingBrace + 1; } var indentBeforeFunction = this._getElementDirectIndent(functionExpression); if (indentBeforeFunction !== null) { functionIndent = Math.min(functionIndent, indentBeforeFunction + 1); } return Math.max(indent, functionIndent); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (indentBeforeClosingBrace !== null) {··· functionIndent = indentBeforeClosingBrace + 1; } |
✓ Negative was executed (else) | }··· var indentBeforeFunction = this._getElementDirectIndent(functionExpression); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (indentBeforeFunction !== null) {··· functionIndent = Math.min(functionIndent, indentBeforeFunction + 1); } |
✓ Negative was executed (else) | }··· return Math.max(indent, functionIndent); |
Function (anonymous_1309) | |
---|---|
✓ Was called | _getObjectExpressionIndent: function(objectExpression, indent) {··· var objectIndent = 0; var properties = objectExpression.properties; // Handling nested one-line objects, i.e. `{prop: {\n` if (objectExpression.parentElement.type === 'ObjectProperty') { var parentObjectExpressionBrace = objectExpression.parentElement.parentElement.firstChild; var currentToken = objectExpression.getPreviousToken(); while (currentToken) { if (currentToken === parentObjectExpressionBrace) { indent--; break; } if (currentToken.getNewlineCount() > 0) { break; } currentToken = currentToken.getPreviousToken(); } } for (var i = 0; i < properties.length; i++) { var property = properties[i]; objectIndent = this._getElementDirectIndent(property); if (objectIndent !== null) { break; } } return Math.max(indent, objectIndent); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (objectExpression.parentElement.type === 'ObjectProperty') {··· var parentObjectExpressionBrace = objectExpression.parentElement.parentElement.firstChild; var currentToken = objectExpression.getPreviousToken(); while (currentToken) { if (currentToken === parentObjectExpressionBrace) { indent--; break; } if (currentToken.getNewlineCount() > 0) { break; } currentToken = currentToken.getPreviousToken(); } } |
✓ Negative was executed (else) | }··· for (var i = 0; i < properties.length; i++) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken === parentObjectExpressionBrace) {··· indent--; break; } |
✓ Negative was executed (else) | }··· if (currentToken.getNewlineCount() > 0) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken.getNewlineCount() > 0) {··· break; } |
✓ Negative was executed (else) | }··· currentToken = currentToken.getPreviousToken(); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (objectIndent !== null) {··· break; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_1310) | |
---|---|
✓ Was called | _getElementDirectIndent: function(node) {··· var whitespaceToken = node.getPreviousToken(); if (whitespaceToken.isWhitespace && whitespaceToken.getNewlineCount() > 0) { var endTokenLines = whitespaceToken.getSourceCodeLines(); return Math.floor(endTokenLines[endTokenLines.length - 1].length / this._indentSize); } return null; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (whitespaceToken.isWhitespace && whitespaceToken.getNewlineCount() > 0) {··· var endTokenLines = whitespaceToken.getSourceCodeLines(); return Math.floor(endTokenLines[endTokenLines.length - 1].length / this._indentSize); } |
✓ Negative was executed (else) | }··· return null; |
Branch LogicalExpression | |
✓ Was returned | if (whitespaceToken.isWhitespace && whitespaceToken.getNewlineCount() > 0) { |
✓ Was returned | if (whitespaceToken.isWhitespace && whitespaceToken.getNewlineCount() > 0) { |
Function (anonymous_1311) | |
---|---|
✓ Was called | _checkNode: function(parentElement, errors, initialIndent, options) {··· var moduleBody = options.moduleBody; var firstWhitespace = options.firstWhitespace; var isBlock = false; var isModuleBody = false; var checkBlockIndentation = false; var indent = initialIndent; var isSwitchStatement = parentElement.type === 'SwitchStatement'; var calculateFunctionExpressionIndent = null; var indentCases = null; if (isSwitchStatement) { indent++; isBlock = true; checkBlockIndentation = true; } if (parentElement.type === 'Program') { checkBlockIndentation = true; } if (parentElement.type === 'BlockStatement') { indent++; isBlock = true; checkBlockIndentation = true; isModuleBody = parentElement === moduleBody; if (isModuleBody && this._indentModuleBodies === false) { indent--; } else if (parentElement.parentElement.type === 'SwitchCase') { // Avoiding additional indentation if `{` is on the same line with case block start if (isBlockOnTheSameLineWithCase(parentElement)) { indent--; } } else { // Calculating indentation for function expressions. calculateFunctionExpressionIndent = isFunctionExpression(parentElement.parentElement); if (calculateFunctionExpressionIndent) { indent = this._getFunctionIndent(parentElement.parentElement, indent); } } } if (parentElement.type === 'ClassBody') { indent++; isBlock = true; checkBlockIndentation = true; } if (parentElement.type === 'SwitchCase') { indent++; checkBlockIndentation = true; } if (parentElement.type === 'ObjectExpression') { indent++; indent = this._getObjectExpressionIndent(parentElement, indent); isBlock = true; checkBlockIndentation = true; } var nonBlockChecks = nonBlockIndentChecks[parentElement.type]; var statementsToCheck; if (nonBlockChecks) { statementsToCheck = nonBlockChecks.filter(function(propName) { return parentElement[propName] && parentElement[propName].type !== 'BlockStatement'; }); } var element = parentElement.firstChild; while (element) { if (element.isToken) { var isFirstWhitespace = element === firstWhitespace; if (element.isWhitespace && (element.getNewlineCount() > 0 || isFirstWhitespace)) { var lines = getLineData(element.getSourceCode()); var lineOffset = this._includeEmptyLines ? (isFirstWhitespace ? 0 : 1) : lines.length - 1; lines = lines.slice(lineOffset); for (var i = 0; i < lines.length; i++) { var line = lines[i].line; if (line.indexOf(this._nonIndentChar) !== -1) { errors.add( 'Invalid indentation character: ' + this._nonIndentChar, element, lines[i].offset ); } var nextSibling = element.nextSibling; var checkForStatement = false; var checkForKeyword = false; if (!checkBlockIndentation) { if (statementsToCheck && statementsToCheck.length > 0) { if (statementsToCheck.indexOf(nextSibling) !== -1) { checkForStatement = true; } } var nextToken = element.getNextToken(); if (nextToken && nextToken.isToken && nextToken.type === 'Keyword' && keywordsToCheck[nextToken.value] ) { checkForKeyword = true; } } if (checkBlockIndentation || checkForStatement || checkForKeyword) { var isLastLine = i === lines.length - 1; var expectedIndent = indent; if (checkForStatement) { expectedIndent++; } // If it is the last line in the multiline indent if (isLastLine && nextSibling) { var hasExpectedIndent = expectedIndent * this._indentSize === line.length; if (isBlock) { // Handling "{" and "}" in block statements. if ( nextSibling === parentElement.lastChild || nextSibling === parentElement.firstChild ) { expectedIndent = Math.max(0, expectedIndent - 1); // Handling module bodies (i.e. require, define) } else if (isModuleBody) { if (this._indentModuleBodies === null) { this._indentModuleBodies = hasExpectedIndent; if (!this._indentModuleBodies) { indent--; expectedIndent--; } } // Handling switch statement cases } else if (isSwitchStatement) { if (indentCases === null) { indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } // Handling functions in expressions (with unclear initial indent). } else if (calculateFunctionExpressionIndent) { indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } } // Allowing "break" statement have lesser indentation. if (parentElement.type === 'SwitchCase' && nextSibling.type === 'BreakStatement') { if (this._indentBreaks === null) { this._indentBreaks = hasExpectedIndent; } if (!this._indentBreaks) { expectedIndent--; } } } var expectedLineLengths = [expectedIndent * this._indentSize]; // Excluding comments if necessary. if (isLastLine && nextSibling && nextSibling.isComment) { if (this._exceptComments) { break; } if (isSwitchStatement && indentCases) { expectedLineLengths.push(expectedLineLengths[0] + this._indentSize); } var brace = nextSibling.getNextNonWhitespaceToken(); if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) { expectedLineLengths.push(expectedLineLengths[0] - this._indentSize); } } if (expectedLineLengths.indexOf(line.length) === -1) { errors.cast({ message: 'Expected indentation of ' + expectedLineLengths[0] + ' characters', element: element, offset: lines[i].offset, additional: { line: lineOffset + i, indentDiff: expectedLineLengths[0] - line.length, adjustElement: isLastLine && nextSibling } }); } } } } } else { this._checkNode(element, errors, indent, options); } element = element.nextSibling; } }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isSwitchStatement) {··· indent++; isBlock = true; checkBlockIndentation = true; } |
✓ Negative was executed (else) | }··· if (parentElement.type === 'Program') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type === 'Program') {··· checkBlockIndentation = true; } |
✓ Negative was executed (else) | }··· if (parentElement.type === 'BlockStatement') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type === 'BlockStatement') {··· indent++; isBlock = true; checkBlockIndentation = true; isModuleBody = parentElement === moduleBody; if (isModuleBody && this._indentModuleBodies === false) { indent--; } else if (parentElement.parentElement.type === 'SwitchCase') { // Avoiding additional indentation if `{` is on the same line with case block start if (isBlockOnTheSameLineWithCase(parentElement)) { indent--; } } else { // Calculating indentation for function expressions. calculateFunctionExpressionIndent = isFunctionExpression(parentElement.parentElement); if (calculateFunctionExpressionIndent) { indent = this._getFunctionIndent(parentElement.parentElement, indent); } } } |
✓ Negative was executed (else) | }··· if (parentElement.type === 'ClassBody') { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (isModuleBody && this._indentModuleBodies === false) {··· indent--; } else if (parentElement.parentElement.type === 'SwitchCase') { |
✓ Negative was executed (else) | } else if (parentElement.parentElement.type === 'SwitchCase') {··· // Avoiding additional indentation if `{` is on the same line with case block start if (isBlockOnTheSameLineWithCase(parentElement)) { indent--; } } else { // Calculating indentation for function expressions. calculateFunctionExpressionIndent = isFunctionExpression(parentElement.parentElement); if (calculateFunctionExpressionIndent) { indent = this._getFunctionIndent(parentElement.parentElement, indent); } } |
Branch LogicalExpression | |
✓ Was returned | if (isModuleBody && this._indentModuleBodies === false) { |
✓ Was returned | if (isModuleBody && this._indentModuleBodies === false) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (parentElement.parentElement.type === 'SwitchCase') {··· // Avoiding additional indentation if `{` is on the same line with case block start if (isBlockOnTheSameLineWithCase(parentElement)) { indent--; } } else { |
✓ Negative was executed (else) | } else {··· // Calculating indentation for function expressions. calculateFunctionExpressionIndent = isFunctionExpression(parentElement.parentElement); if (calculateFunctionExpressionIndent) { indent = this._getFunctionIndent(parentElement.parentElement, indent); } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isBlockOnTheSameLineWithCase(parentElement)) {··· indent--; } |
✓ Negative was executed (else) | }··· } else { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (calculateFunctionExpressionIndent) {··· indent = this._getFunctionIndent(parentElement.parentElement, indent); } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type === 'ClassBody') {··· indent++; isBlock = true; checkBlockIndentation = true; } |
✓ Negative was executed (else) | }··· if (parentElement.type === 'SwitchCase') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type === 'SwitchCase') {··· indent++; checkBlockIndentation = true; } |
✓ Negative was executed (else) | }··· if (parentElement.type === 'ObjectExpression') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type === 'ObjectExpression') {··· indent++; indent = this._getObjectExpressionIndent(parentElement, indent); isBlock = true; checkBlockIndentation = true; } |
✓ Negative was executed (else) | }··· var nonBlockChecks = nonBlockIndentChecks[parentElement.type]; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (nonBlockChecks) {··· statementsToCheck = nonBlockChecks.filter(function(propName) { return parentElement[propName] && parentElement[propName].type !== 'BlockStatement'; }); } |
✓ Negative was executed (else) | }··· var element = parentElement.firstChild; |
Function (anonymous_1312) | |
---|---|
✓ Was called | statementsToCheck = nonBlockChecks.filter(function(propName) {··· return parentElement[propName] && parentElement[propName].type !== 'BlockStatement'; }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | return parentElement[propName] && parentElement[propName].type !== 'BlockStatement'; |
✓ Was returned | return parentElement[propName] && parentElement[propName].type !== 'BlockStatement'; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (element.isToken) {··· var isFirstWhitespace = element === firstWhitespace; if (element.isWhitespace && (element.getNewlineCount() > 0 || isFirstWhitespace)) { var lines = getLineData(element.getSourceCode()); var lineOffset = this._includeEmptyLines ? (isFirstWhitespace ? 0 : 1) : lines.length - 1; lines = lines.slice(lineOffset); for (var i = 0; i < lines.length; i++) { var line = lines[i].line; if (line.indexOf(this._nonIndentChar) !== -1) { errors.add( 'Invalid indentation character: ' + this._nonIndentChar, element, lines[i].offset ); } var nextSibling = element.nextSibling; var checkForStatement = false; var checkForKeyword = false; if (!checkBlockIndentation) { if (statementsToCheck && statementsToCheck.length > 0) { if (statementsToCheck.indexOf(nextSibling) !== -1) { checkForStatement = true; } } var nextToken = element.getNextToken(); if (nextToken && nextToken.isToken && nextToken.type === 'Keyword' && keywordsToCheck[nextToken.value] ) { checkForKeyword = true; } } if (checkBlockIndentation || checkForStatement || checkForKeyword) { var isLastLine = i === lines.length - 1; var expectedIndent = indent; if (checkForStatement) { expectedIndent++; } // If it is the last line in the multiline indent if (isLastLine && nextSibling) { var hasExpectedIndent = expectedIndent * this._indentSize === line.length; if (isBlock) { // Handling "{" and "}" in block statements. if ( nextSibling === parentElement.lastChild || nextSibling === parentElement.firstChild ) { expectedIndent = Math.max(0, expectedIndent - 1); // Handling module bodies (i.e. require, define) } else if (isModuleBody) { if (this._indentModuleBodies === null) { this._indentModuleBodies = hasExpectedIndent; if (!this._indentModuleBodies) { indent--; expectedIndent--; } } // Handling switch statement cases } else if (isSwitchStatement) { if (indentCases === null) { indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } // Handling functions in expressions (with unclear initial indent). } else if (calculateFunctionExpressionIndent) { indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } } // Allowing "break" statement have lesser indentation. if (parentElement.type === 'SwitchCase' && nextSibling.type === 'BreakStatement') { if (this._indentBreaks === null) { this._indentBreaks = hasExpectedIndent; } if (!this._indentBreaks) { expectedIndent--; } } } var expectedLineLengths = [expectedIndent * this._indentSize]; // Excluding comments if necessary. if (isLastLine && nextSibling && nextSibling.isComment) { if (this._exceptComments) { break; } if (isSwitchStatement && indentCases) { expectedLineLengths.push(expectedLineLengths[0] + this._indentSize); } var brace = nextSibling.getNextNonWhitespaceToken(); if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) { expectedLineLengths.push(expectedLineLengths[0] - this._indentSize); } } if (expectedLineLengths.indexOf(line.length) === -1) { errors.cast({ message: 'Expected indentation of ' + expectedLineLengths[0] + ' characters', element: element, offset: lines[i].offset, additional: { line: lineOffset + i, indentDiff: expectedLineLengths[0] - line.length, adjustElement: isLastLine && nextSibling } }); } } } } } else { |
✓ Negative was executed (else) | } else {··· this._checkNode(element, errors, indent, options); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (element.isWhitespace && (element.getNewlineCount() > 0 || isFirstWhitespace)) {··· var lines = getLineData(element.getSourceCode()); var lineOffset = this._includeEmptyLines ? (isFirstWhitespace ? 0 : 1) : lines.length - 1; lines = lines.slice(lineOffset); for (var i = 0; i < lines.length; i++) { var line = lines[i].line; if (line.indexOf(this._nonIndentChar) !== -1) { errors.add( 'Invalid indentation character: ' + this._nonIndentChar, element, lines[i].offset ); } var nextSibling = element.nextSibling; var checkForStatement = false; var checkForKeyword = false; if (!checkBlockIndentation) { if (statementsToCheck && statementsToCheck.length > 0) { if (statementsToCheck.indexOf(nextSibling) !== -1) { checkForStatement = true; } } var nextToken = element.getNextToken(); if (nextToken && nextToken.isToken && nextToken.type === 'Keyword' && keywordsToCheck[nextToken.value] ) { checkForKeyword = true; } } if (checkBlockIndentation || checkForStatement || checkForKeyword) { var isLastLine = i === lines.length - 1; var expectedIndent = indent; if (checkForStatement) { expectedIndent++; } // If it is the last line in the multiline indent if (isLastLine && nextSibling) { var hasExpectedIndent = expectedIndent * this._indentSize === line.length; if (isBlock) { // Handling "{" and "}" in block statements. if ( nextSibling === parentElement.lastChild || nextSibling === parentElement.firstChild ) { expectedIndent = Math.max(0, expectedIndent - 1); // Handling module bodies (i.e. require, define) } else if (isModuleBody) { if (this._indentModuleBodies === null) { this._indentModuleBodies = hasExpectedIndent; if (!this._indentModuleBodies) { indent--; expectedIndent--; } } // Handling switch statement cases } else if (isSwitchStatement) { if (indentCases === null) { indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } // Handling functions in expressions (with unclear initial indent). } else if (calculateFunctionExpressionIndent) { indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } } // Allowing "break" statement have lesser indentation. if (parentElement.type === 'SwitchCase' && nextSibling.type === 'BreakStatement') { if (this._indentBreaks === null) { this._indentBreaks = hasExpectedIndent; } if (!this._indentBreaks) { expectedIndent--; } } } var expectedLineLengths = [expectedIndent * this._indentSize]; // Excluding comments if necessary. if (isLastLine && nextSibling && nextSibling.isComment) { if (this._exceptComments) { break; } if (isSwitchStatement && indentCases) { expectedLineLengths.push(expectedLineLengths[0] + this._indentSize); } var brace = nextSibling.getNextNonWhitespaceToken(); if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) { expectedLineLengths.push(expectedLineLengths[0] - this._indentSize); } } if (expectedLineLengths.indexOf(line.length) === -1) { errors.cast({ message: 'Expected indentation of ' + expectedLineLengths[0] + ' characters', element: element, offset: lines[i].offset, additional: { line: lineOffset + i, indentDiff: expectedLineLengths[0] - line.length, adjustElement: isLastLine && nextSibling } }); } } } } |
✓ Negative was executed (else) | }··· } else { |
Branch LogicalExpression | |
✓ Was returned | if (element.isWhitespace && (element.getNewlineCount() > 0 || isFirstWhitespace)) { |
✓ Was returned | if (element.isWhitespace && (element.getNewlineCount() > 0 || isFirstWhitespace)) { |
Branch LogicalExpression | |
✓ Was returned | if (element.isWhitespace && (element.getNewlineCount() > 0 || isFirstWhitespace)) { |
✓ Was returned | if (element.isWhitespace && (element.getNewlineCount() > 0 || isFirstWhitespace)) { |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | (isFirstWhitespace ? 0 : 1) : |
✓ Negative was returned (: ...) | lines.length - 1; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | (isFirstWhitespace ? 0 : 1) : |
✓ Negative was returned (: ...) | (isFirstWhitespace ? 0 : 1) : |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (line.indexOf(this._nonIndentChar) !== -1) {··· errors.add( 'Invalid indentation character: ' + this._nonIndentChar, element, lines[i].offset ); } |
✓ Negative was executed (else) | }··· var nextSibling = element.nextSibling; |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!checkBlockIndentation) {··· if (statementsToCheck && statementsToCheck.length > 0) { if (statementsToCheck.indexOf(nextSibling) !== -1) { checkForStatement = true; } } var nextToken = element.getNextToken(); if (nextToken && nextToken.isToken && nextToken.type === 'Keyword' && keywordsToCheck[nextToken.value] ) { checkForKeyword = true; } } |
✓ Negative was executed (else) | }··· if (checkBlockIndentation || checkForStatement || checkForKeyword) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (statementsToCheck && statementsToCheck.length > 0) {··· if (statementsToCheck.indexOf(nextSibling) !== -1) { checkForStatement = true; } } |
✓ Negative was executed (else) | }··· var nextToken = element.getNextToken(); |
Branch LogicalExpression | |
✓ Was returned | if (statementsToCheck && statementsToCheck.length > 0) { |
✓ Was returned | if (statementsToCheck && statementsToCheck.length > 0) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (statementsToCheck.indexOf(nextSibling) !== -1) {··· checkForStatement = true; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· checkForKeyword = true; } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | keywordsToCheck[nextToken.value] |
✓ Was returned | if (nextToken &&··· nextToken.isToken && nextToken.type === 'Keyword' && |
Branch LogicalExpression | |
✓ Was returned | nextToken.type === 'Keyword' && |
✗ Was not returned | if (nextToken &&··· nextToken.isToken && |
Branch LogicalExpression | |
✓ Was returned | nextToken.isToken && |
✗ Was not returned | if (nextToken && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (checkBlockIndentation || checkForStatement || checkForKeyword) {··· var isLastLine = i === lines.length - 1; var expectedIndent = indent; if (checkForStatement) { expectedIndent++; } // If it is the last line in the multiline indent if (isLastLine && nextSibling) { var hasExpectedIndent = expectedIndent * this._indentSize === line.length; if (isBlock) { // Handling "{" and "}" in block statements. if ( nextSibling === parentElement.lastChild || nextSibling === parentElement.firstChild ) { expectedIndent = Math.max(0, expectedIndent - 1); // Handling module bodies (i.e. require, define) } else if (isModuleBody) { if (this._indentModuleBodies === null) { this._indentModuleBodies = hasExpectedIndent; if (!this._indentModuleBodies) { indent--; expectedIndent--; } } // Handling switch statement cases } else if (isSwitchStatement) { if (indentCases === null) { indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } // Handling functions in expressions (with unclear initial indent). } else if (calculateFunctionExpressionIndent) { indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } } // Allowing "break" statement have lesser indentation. if (parentElement.type === 'SwitchCase' && nextSibling.type === 'BreakStatement') { if (this._indentBreaks === null) { this._indentBreaks = hasExpectedIndent; } if (!this._indentBreaks) { expectedIndent--; } } } var expectedLineLengths = [expectedIndent * this._indentSize]; // Excluding comments if necessary. if (isLastLine && nextSibling && nextSibling.isComment) { if (this._exceptComments) { break; } if (isSwitchStatement && indentCases) { expectedLineLengths.push(expectedLineLengths[0] + this._indentSize); } var brace = nextSibling.getNextNonWhitespaceToken(); if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) { expectedLineLengths.push(expectedLineLengths[0] - this._indentSize); } } if (expectedLineLengths.indexOf(line.length) === -1) { errors.cast({ message: 'Expected indentation of ' + expectedLineLengths[0] + ' characters', element: element, offset: lines[i].offset, additional: { line: lineOffset + i, indentDiff: expectedLineLengths[0] - line.length, adjustElement: isLastLine && nextSibling } }); } } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (checkBlockIndentation || checkForStatement || checkForKeyword) { |
✓ Was returned | if (checkBlockIndentation || checkForStatement || checkForKeyword) { |
Branch LogicalExpression | |
✓ Was returned | if (checkBlockIndentation || checkForStatement || checkForKeyword) { |
✓ Was returned | if (checkBlockIndentation || checkForStatement || checkForKeyword) { |
Branch IfStatement | |
---|---|
✗ Positive was not executed (if) | if (checkForStatement) {··· expectedIndent++; } |
✓ Negative was executed (else) | }··· // If it is the last line in the multiline indent |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isLastLine && nextSibling) {··· var hasExpectedIndent = expectedIndent * this._indentSize === line.length; if (isBlock) { // Handling "{" and "}" in block statements. if ( nextSibling === parentElement.lastChild || nextSibling === parentElement.firstChild ) { expectedIndent = Math.max(0, expectedIndent - 1); // Handling module bodies (i.e. require, define) } else if (isModuleBody) { if (this._indentModuleBodies === null) { this._indentModuleBodies = hasExpectedIndent; if (!this._indentModuleBodies) { indent--; expectedIndent--; } } // Handling switch statement cases } else if (isSwitchStatement) { if (indentCases === null) { indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } // Handling functions in expressions (with unclear initial indent). } else if (calculateFunctionExpressionIndent) { indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } } // Allowing "break" statement have lesser indentation. if (parentElement.type === 'SwitchCase' && nextSibling.type === 'BreakStatement') { if (this._indentBreaks === null) { this._indentBreaks = hasExpectedIndent; } if (!this._indentBreaks) { expectedIndent--; } } } |
✓ Negative was executed (else) | }··· var expectedLineLengths = [expectedIndent * this._indentSize]; |
Branch LogicalExpression | |
✓ Was returned | if (isLastLine && nextSibling) { |
✓ Was returned | if (isLastLine && nextSibling) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isBlock) {··· // Handling "{" and "}" in block statements. if ( nextSibling === parentElement.lastChild || nextSibling === parentElement.firstChild ) { expectedIndent = Math.max(0, expectedIndent - 1); // Handling module bodies (i.e. require, define) } else if (isModuleBody) { if (this._indentModuleBodies === null) { this._indentModuleBodies = hasExpectedIndent; if (!this._indentModuleBodies) { indent--; expectedIndent--; } } // Handling switch statement cases } else if (isSwitchStatement) { if (indentCases === null) { indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } // Handling functions in expressions (with unclear initial indent). } else if (calculateFunctionExpressionIndent) { indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } } |
✓ Negative was executed (else) | }··· // Allowing "break" statement have lesser indentation. |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· expectedIndent = Math.max(0, expectedIndent - 1); // Handling module bodies (i.e. require, define) } else if (isModuleBody) { |
✓ Negative was executed (else) | } else if (isModuleBody) {··· if (this._indentModuleBodies === null) { this._indentModuleBodies = hasExpectedIndent; if (!this._indentModuleBodies) { indent--; expectedIndent--; } } // Handling switch statement cases } else if (isSwitchStatement) { if (indentCases === null) { indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } // Handling functions in expressions (with unclear initial indent). } else if (calculateFunctionExpressionIndent) { indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } |
Branch LogicalExpression | |
---|---|
✓ Was returned | nextSibling === parentElement.firstChild |
✓ Was returned | nextSibling === parentElement.lastChild || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (isModuleBody) {··· if (this._indentModuleBodies === null) { this._indentModuleBodies = hasExpectedIndent; if (!this._indentModuleBodies) { indent--; expectedIndent--; } } // Handling switch statement cases } else if (isSwitchStatement) { |
✓ Negative was executed (else) | } else if (isSwitchStatement) {··· if (indentCases === null) { indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } // Handling functions in expressions (with unclear initial indent). } else if (calculateFunctionExpressionIndent) { indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._indentModuleBodies === null) {··· this._indentModuleBodies = hasExpectedIndent; if (!this._indentModuleBodies) { indent--; expectedIndent--; } } |
✗ Negative was not executed (else) | }··· // Handling switch statement cases |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._indentModuleBodies) {··· indent--; expectedIndent--; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (isSwitchStatement) {··· if (indentCases === null) { indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } // Handling functions in expressions (with unclear initial indent). } else if (calculateFunctionExpressionIndent) { |
✓ Negative was executed (else) | } else if (calculateFunctionExpressionIndent) {··· indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (indentCases === null) {··· indentCases = hasExpectedIndent; if (!indentCases) { indent--; expectedIndent--; } } |
✓ Negative was executed (else) | }··· // Handling functions in expressions (with unclear initial indent). |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!indentCases) {··· indent--; expectedIndent--; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | } else if (calculateFunctionExpressionIndent) {··· indent = Math.max(indent, Math.floor(line.length / this._indentSize)); expectedIndent = indent; calculateFunctionExpressionIndent = false; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (parentElement.type === 'SwitchCase' && nextSibling.type === 'BreakStatement') {··· if (this._indentBreaks === null) { this._indentBreaks = hasExpectedIndent; } if (!this._indentBreaks) { expectedIndent--; } } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (parentElement.type === 'SwitchCase' && nextSibling.type === 'BreakStatement') { |
✓ Was returned | if (parentElement.type === 'SwitchCase' && nextSibling.type === 'BreakStatement') { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._indentBreaks === null) {··· this._indentBreaks = hasExpectedIndent; } |
✓ Negative was executed (else) | }··· if (!this._indentBreaks) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!this._indentBreaks) {··· expectedIndent--; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isLastLine && nextSibling && nextSibling.isComment) {··· if (this._exceptComments) { break; } if (isSwitchStatement && indentCases) { expectedLineLengths.push(expectedLineLengths[0] + this._indentSize); } var brace = nextSibling.getNextNonWhitespaceToken(); if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) { expectedLineLengths.push(expectedLineLengths[0] - this._indentSize); } } |
✓ Negative was executed (else) | }··· if (expectedLineLengths.indexOf(line.length) === -1) { |
Branch LogicalExpression | |
✓ Was returned | if (isLastLine && nextSibling && nextSibling.isComment) { |
✓ Was returned | if (isLastLine && nextSibling && nextSibling.isComment) { |
Branch LogicalExpression | |
✓ Was returned | if (isLastLine && nextSibling && nextSibling.isComment) { |
✓ Was returned | if (isLastLine && nextSibling && nextSibling.isComment) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (this._exceptComments) {··· break; } |
✓ Negative was executed (else) | }··· if (isSwitchStatement && indentCases) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isSwitchStatement && indentCases) {··· expectedLineLengths.push(expectedLineLengths[0] + this._indentSize); } |
✓ Negative was executed (else) | }··· var brace = nextSibling.getNextNonWhitespaceToken(); |
Branch LogicalExpression | |
✓ Was returned | if (isSwitchStatement && indentCases) { |
✓ Was returned | if (isSwitchStatement && indentCases) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) {··· expectedLineLengths.push(expectedLineLengths[0] - this._indentSize); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) { |
✓ Was returned | if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) { |
Branch LogicalExpression | |
✓ Was returned | if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) { |
✓ Was returned | if (isBlock && brace === parentElement.lastChild && hasFollowingClause(parentElement)) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (expectedLineLengths.indexOf(line.length) === -1) {··· errors.cast({ message: 'Expected indentation of ' + expectedLineLengths[0] + ' characters', element: element, offset: lines[i].offset, additional: { line: lineOffset + i, indentDiff: expectedLineLengths[0] - line.length, adjustElement: isLastLine && nextSibling } }); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
---|---|
✓ Was returned | adjustElement: isLastLine && nextSibling |
✓ Was returned | adjustElement: isLastLine && nextSibling |
Function (anonymous_1313) | |
---|---|
✓ Was called | check: function(file, errors) {··· var program = file.getProgram(); var firstWhitespace; if (program.getFirstToken().isWhitespace) { firstWhitespace = program.getFirstToken(); } this._checkNode(program, errors, 0, { moduleBody: getModuleBody(program), firstWhitespace: firstWhitespace }); }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (program.getFirstToken().isWhitespace) {··· firstWhitespace = program.getFirstToken(); } |
✓ Negative was executed (else) | }··· this._checkNode(program, errors, 0, { |
Function (anonymous_1314) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var indentChar = this._indentChar; var whitespaceToken = error.element; var fixData = error.additional; var indentDiff = fixData.indentDiff; var lineItemsData = getLineData(whitespaceToken.value); var lineItemToFix = lineItemsData[fixData.line]; if (lineItemToFix) { var originalIndentLength = lineItemToFix.line.length; var finalIndentLength = originalIndentLength + indentDiff; lineItemToFix.line = new Array(finalIndentLength + 1).join(indentChar); var newWhitespaceToken = new cst.Token( 'Whitespace', convertLinesToString(lineItemsData) ); whitespaceToken.parentElement.replaceChild(newWhitespaceToken, whitespaceToken); var adjustElement = fixData.adjustElement; if (adjustElement && adjustElement.getNewlineCount() > 0) { var currentToken = adjustElement.getFirstToken(); var lastToken = adjustElement.getLastToken(); while (true) { var nextToken = currentToken.getNextToken(); if (currentToken.isWhitespace && currentToken.getNewlineCount() > 0) { var newSubWhitespaceToken = new cst.Token( currentToken.type, applyIndentationDiff(currentToken.value, indentDiff, indentChar, this._includeEmptyLines) ); currentToken.parentElement.replaceChild(newSubWhitespaceToken, currentToken); } if (currentToken.isComment && currentToken.getNewlineCount() > 0) { var prev = currentToken.getPreviousToken(); var commentIndent = 0; if (prev.isWhitespace && prev.getNewlineCount() > 0) { commentIndent = prev.getSourceCodeLines().concat().pop().length; } var commentDiff = indentDiff < 0 && commentIndent < -indentDiff ? -commentIndent : indentDiff; var newCommentToken = new cst.Token( currentToken.type, applyIndentationDiff( currentToken.value, commentDiff, indentChar, this._includeEmptyLines ) ); currentToken.parentElement.replaceChild(newCommentToken, currentToken); } if (currentToken === lastToken) { break; } currentToken = nextToken; } } } } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lineItemToFix) {··· var originalIndentLength = lineItemToFix.line.length; var finalIndentLength = originalIndentLength + indentDiff; lineItemToFix.line = new Array(finalIndentLength + 1).join(indentChar); var newWhitespaceToken = new cst.Token( 'Whitespace', convertLinesToString(lineItemsData) ); whitespaceToken.parentElement.replaceChild(newWhitespaceToken, whitespaceToken); var adjustElement = fixData.adjustElement; if (adjustElement && adjustElement.getNewlineCount() > 0) { var currentToken = adjustElement.getFirstToken(); var lastToken = adjustElement.getLastToken(); while (true) { var nextToken = currentToken.getNextToken(); if (currentToken.isWhitespace && currentToken.getNewlineCount() > 0) { var newSubWhitespaceToken = new cst.Token( currentToken.type, applyIndentationDiff(currentToken.value, indentDiff, indentChar, this._includeEmptyLines) ); currentToken.parentElement.replaceChild(newSubWhitespaceToken, currentToken); } if (currentToken.isComment && currentToken.getNewlineCount() > 0) { var prev = currentToken.getPreviousToken(); var commentIndent = 0; if (prev.isWhitespace && prev.getNewlineCount() > 0) { commentIndent = prev.getSourceCodeLines().concat().pop().length; } var commentDiff = indentDiff < 0 && commentIndent < -indentDiff ? -commentIndent : indentDiff; var newCommentToken = new cst.Token( currentToken.type, applyIndentationDiff( currentToken.value, commentDiff, indentChar, this._includeEmptyLines ) ); currentToken.parentElement.replaceChild(newCommentToken, currentToken); } if (currentToken === lastToken) { break; } currentToken = nextToken; } } } |
✗ Negative was not executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (adjustElement && adjustElement.getNewlineCount() > 0) {··· var currentToken = adjustElement.getFirstToken(); var lastToken = adjustElement.getLastToken(); while (true) { var nextToken = currentToken.getNextToken(); if (currentToken.isWhitespace && currentToken.getNewlineCount() > 0) { var newSubWhitespaceToken = new cst.Token( currentToken.type, applyIndentationDiff(currentToken.value, indentDiff, indentChar, this._includeEmptyLines) ); currentToken.parentElement.replaceChild(newSubWhitespaceToken, currentToken); } if (currentToken.isComment && currentToken.getNewlineCount() > 0) { var prev = currentToken.getPreviousToken(); var commentIndent = 0; if (prev.isWhitespace && prev.getNewlineCount() > 0) { commentIndent = prev.getSourceCodeLines().concat().pop().length; } var commentDiff = indentDiff < 0 && commentIndent < -indentDiff ? -commentIndent : indentDiff; var newCommentToken = new cst.Token( currentToken.type, applyIndentationDiff( currentToken.value, commentDiff, indentChar, this._includeEmptyLines ) ); currentToken.parentElement.replaceChild(newCommentToken, currentToken); } if (currentToken === lastToken) { break; } currentToken = nextToken; } } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (adjustElement && adjustElement.getNewlineCount() > 0) { |
✓ Was returned | if (adjustElement && adjustElement.getNewlineCount() > 0) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken.isWhitespace && currentToken.getNewlineCount() > 0) {··· var newSubWhitespaceToken = new cst.Token( currentToken.type, applyIndentationDiff(currentToken.value, indentDiff, indentChar, this._includeEmptyLines) ); currentToken.parentElement.replaceChild(newSubWhitespaceToken, currentToken); } |
✓ Negative was executed (else) | }··· if (currentToken.isComment && currentToken.getNewlineCount() > 0) { |
Branch LogicalExpression | |
✓ Was returned | if (currentToken.isWhitespace && currentToken.getNewlineCount() > 0) { |
✓ Was returned | if (currentToken.isWhitespace && currentToken.getNewlineCount() > 0) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken.isComment && currentToken.getNewlineCount() > 0) {··· var prev = currentToken.getPreviousToken(); var commentIndent = 0; if (prev.isWhitespace && prev.getNewlineCount() > 0) { commentIndent = prev.getSourceCodeLines().concat().pop().length; } var commentDiff = indentDiff < 0 && commentIndent < -indentDiff ? -commentIndent : indentDiff; var newCommentToken = new cst.Token( currentToken.type, applyIndentationDiff( currentToken.value, commentDiff, indentChar, this._includeEmptyLines ) ); currentToken.parentElement.replaceChild(newCommentToken, currentToken); } |
✓ Negative was executed (else) | }··· if (currentToken === lastToken) { |
Branch LogicalExpression | |
✓ Was returned | if (currentToken.isComment && currentToken.getNewlineCount() > 0) { |
✓ Was returned | if (currentToken.isComment && currentToken.getNewlineCount() > 0) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (prev.isWhitespace && prev.getNewlineCount() > 0) {··· commentIndent = prev.getSourceCodeLines().concat().pop().length; } |
✗ Negative was not executed (else) | }··· var commentDiff = indentDiff < 0 && commentIndent < -indentDiff ? |
Branch LogicalExpression | |
✓ Was returned | if (prev.isWhitespace && prev.getNewlineCount() > 0) { |
✗ Was not returned | if (prev.isWhitespace && prev.getNewlineCount() > 0) { |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | -commentIndent : |
✓ Negative was returned (: ...) | indentDiff; |
Branch LogicalExpression | |
✓ Was returned | var commentDiff = indentDiff < 0 && commentIndent < -indentDiff ? |
✓ Was returned | var commentDiff = indentDiff < 0 && commentIndent < -indentDiff ? |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (currentToken === lastToken) {··· break; } |
✓ Negative was executed (else) | }··· currentToken = nextToken; |
Function (anonymous_1315) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1316) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'string' || typeof options === 'object', this.getOptionName() + ' option requires string or object value' ); if (typeof options === 'string') { options = { character: options }; } var lineBreaks = { CR: '\r', LF: '\n', CRLF: '\r\n' }; this._allowedLineBreak = lineBreaks[options.character]; this._reportOncePerFile = options.reportOncePerFile !== false; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof options === 'string' || typeof options === 'object', |
✓ Was returned | typeof options === 'string' || typeof options === 'object', |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof options === 'string') {··· options = { character: options }; } |
✓ Negative was executed (else) | }··· var lineBreaks = { |
Function (anonymous_1317) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'validateLineBreaks'; }, |
Function (anonymous_1318) | |
---|---|
✓ Was called | check: function(file, errors) {··· var lines = file.getLines(); if (lines.length < 2) { return; } file.getProgram().selectTokensByType('Whitespace').some(function(whitespace) { LINE_BREAKS.lastIndex = 0; var match; while ((match = LINE_BREAKS.exec(whitespace.value)) !== null) { if (match[0] !== this._allowedLineBreak) { errors.add('Invalid line break', whitespace, match.index); return this._reportOncePerFile; } } }, this); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lines.length < 2) {··· return; } |
✓ Negative was executed (else) | }··· file.getProgram().selectTokensByType('Whitespace').some(function(whitespace) { |
Function (anonymous_1319) | |
---|---|
✓ Was called | file.getProgram().selectTokensByType('Whitespace').some(function(whitespace) {··· LINE_BREAKS.lastIndex = 0; var match; while ((match = LINE_BREAKS.exec(whitespace.value)) !== null) { if (match[0] !== this._allowedLineBreak) { errors.add('Invalid line break', whitespace, match.index); return this._reportOncePerFile; } } }, this); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (match[0] !== this._allowedLineBreak) {··· errors.add('Invalid line break', whitespace, match.index); return this._reportOncePerFile; } |
✓ Negative was executed (else) | }··· } |
Function (anonymous_1320) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1321) | |
---|---|
✓ Was called | configure: function(opts) {··· assert( opts === true || typeof opts === 'number' && opts >= 1 || typeof opts === 'object', this.getOptionName() + ' option requires maximal number of items ' + 'or true value either should be removed' ); if (typeof opts === 'object') { this._options = { maximum: Infinity, ignoreBrackets: false }; if ('maximum' in opts) { assert(typeof opts.maximum === 'number' && opts.maximum >= 1, 'maximum property requires a positive number or should be removed'); this._options.maximum = opts.maximum; } if ('ignoreBrackets' in opts) { assert(opts.ignoreBrackets === true, 'ignoreBrackets property requires true value or should be removed'); this._options.ignoreBrackets = true; } } else { this._options = { maximum: opts === true ? Infinity : opts, ignoreBrackets: false }; } }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof opts === 'object', |
✓ Was returned | opts === true ||··· typeof opts === 'number' && opts >= 1 || |
Branch LogicalExpression | |
✓ Was returned | typeof opts === 'number' && opts >= 1 || |
✓ Was returned | opts === true || |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof opts === 'number' && opts >= 1 || |
✓ Was returned | typeof opts === 'number' && opts >= 1 || |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof opts === 'object') {··· this._options = { maximum: Infinity, ignoreBrackets: false }; if ('maximum' in opts) { assert(typeof opts.maximum === 'number' && opts.maximum >= 1, 'maximum property requires a positive number or should be removed'); this._options.maximum = opts.maximum; } if ('ignoreBrackets' in opts) { assert(opts.ignoreBrackets === true, 'ignoreBrackets property requires true value or should be removed'); this._options.ignoreBrackets = true; } } else { |
✓ Negative was executed (else) | } else {··· this._options = { maximum: opts === true ? Infinity : opts, ignoreBrackets: false }; } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('maximum' in opts) {··· assert(typeof opts.maximum === 'number' && opts.maximum >= 1, 'maximum property requires a positive number or should be removed'); this._options.maximum = opts.maximum; } |
✓ Negative was executed (else) | }··· if ('ignoreBrackets' in opts) { |
Branch LogicalExpression | |
---|---|
✓ Was returned | assert(typeof opts.maximum === 'number' && opts.maximum >= 1, |
✓ Was returned | assert(typeof opts.maximum === 'number' && opts.maximum >= 1, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if ('ignoreBrackets' in opts) {··· assert(opts.ignoreBrackets === true, 'ignoreBrackets property requires true value or should be removed'); this._options.ignoreBrackets = true; } |
✓ Negative was executed (else) | }··· } else { |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | maximum: opts === true ? Infinity : opts, |
✓ Negative was returned (: ...) | maximum: opts === true ? Infinity : opts, |
Function (anonymous_1322) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'validateNewlineAfterArrayElements'; }, |
Function (anonymous_1323) | |
---|---|
✓ Was called | check: function(file, errors) {··· var maximum = this._options.maximum; var ignoreBrackets = this._options.ignoreBrackets; file.iterateNodesByType(['ArrayExpression'], function(node) { var els = node.elements; var firstEl = els[0]; var lastEl = els[els.length - 1]; var bracket; var elToken; if (els.length <= maximum && node.getLoc().start.line === node.getLoc().end.line) { return; } if (!ignoreBrackets) { if (firstEl && firstEl.getLoc().start.line === node.getLoc().start.line) { bracket = file.getFirstNodeToken(node); elToken = file.getNextToken(bracket); errors.assert.differentLine({ token: bracket, nextToken: elToken, message: 'First element should be placed on new line' }); } if (lastEl && lastEl.getLoc().end.line === node.getLoc().end.line) { bracket = file.getLastNodeToken(node); elToken = file.getPrevToken(bracket); errors.assert.differentLine({ token: elToken, nextToken: bracket, message: 'Closing bracket should be placed on new line' }); } } els.forEach(function(elem) { var elToken; var comma; if (!elem) { // skip holes return; } if (firstEl !== elem) { elToken = file.getFirstNodeToken(elem); comma = file.getPrevToken(elToken); errors.assert.differentLine({ token: comma, nextToken: elToken, message: 'Multiple elements at a single line in multiline array' }); } }); }); } |
Function (anonymous_1324) | |
---|---|
✓ Was called | file.iterateNodesByType(['ArrayExpression'], function(node) {··· var els = node.elements; var firstEl = els[0]; var lastEl = els[els.length - 1]; var bracket; var elToken; if (els.length <= maximum && node.getLoc().start.line === node.getLoc().end.line) { return; } if (!ignoreBrackets) { if (firstEl && firstEl.getLoc().start.line === node.getLoc().start.line) { bracket = file.getFirstNodeToken(node); elToken = file.getNextToken(bracket); errors.assert.differentLine({ token: bracket, nextToken: elToken, message: 'First element should be placed on new line' }); } if (lastEl && lastEl.getLoc().end.line === node.getLoc().end.line) { bracket = file.getLastNodeToken(node); elToken = file.getPrevToken(bracket); errors.assert.differentLine({ token: elToken, nextToken: bracket, message: 'Closing bracket should be placed on new line' }); } } els.forEach(function(elem) { var elToken; var comma; if (!elem) { // skip holes return; } if (firstEl !== elem) { elToken = file.getFirstNodeToken(elem); comma = file.getPrevToken(elToken); errors.assert.differentLine({ token: comma, nextToken: elToken, message: 'Multiple elements at a single line in multiline array' }); } }); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (els.length <= maximum && node.getLoc().start.line === node.getLoc().end.line) {··· return; } |
✓ Negative was executed (else) | }··· if (!ignoreBrackets) { |
Branch LogicalExpression | |
✓ Was returned | if (els.length <= maximum && node.getLoc().start.line === node.getLoc().end.line) { |
✓ Was returned | if (els.length <= maximum && node.getLoc().start.line === node.getLoc().end.line) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!ignoreBrackets) {··· if (firstEl && firstEl.getLoc().start.line === node.getLoc().start.line) { bracket = file.getFirstNodeToken(node); elToken = file.getNextToken(bracket); errors.assert.differentLine({ token: bracket, nextToken: elToken, message: 'First element should be placed on new line' }); } if (lastEl && lastEl.getLoc().end.line === node.getLoc().end.line) { bracket = file.getLastNodeToken(node); elToken = file.getPrevToken(bracket); errors.assert.differentLine({ token: elToken, nextToken: bracket, message: 'Closing bracket should be placed on new line' }); } } |
✓ Negative was executed (else) | }··· els.forEach(function(elem) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (firstEl && firstEl.getLoc().start.line === node.getLoc().start.line) {··· bracket = file.getFirstNodeToken(node); elToken = file.getNextToken(bracket); errors.assert.differentLine({ token: bracket, nextToken: elToken, message: 'First element should be placed on new line' }); } |
✓ Negative was executed (else) | }··· if (lastEl && lastEl.getLoc().end.line === node.getLoc().end.line) { |
Branch LogicalExpression | |
✓ Was returned | if (firstEl && firstEl.getLoc().start.line === node.getLoc().start.line) { |
✓ Was returned | if (firstEl && firstEl.getLoc().start.line === node.getLoc().start.line) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lastEl && lastEl.getLoc().end.line === node.getLoc().end.line) {··· bracket = file.getLastNodeToken(node); elToken = file.getPrevToken(bracket); errors.assert.differentLine({ token: elToken, nextToken: bracket, message: 'Closing bracket should be placed on new line' }); } |
✓ Negative was executed (else) | }··· } |
Branch LogicalExpression | |
✓ Was returned | if (lastEl && lastEl.getLoc().end.line === node.getLoc().end.line) { |
✓ Was returned | if (lastEl && lastEl.getLoc().end.line === node.getLoc().end.line) { |
Function (anonymous_1325) | |
---|---|
✓ Was called | els.forEach(function(elem) {··· var elToken; var comma; if (!elem) { // skip holes return; } if (firstEl !== elem) { elToken = file.getFirstNodeToken(elem); comma = file.getPrevToken(elToken); errors.assert.differentLine({ token: comma, nextToken: elToken, message: 'Multiple elements at a single line in multiline array' }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!elem) {··· // skip holes return; } |
✓ Negative was executed (else) | }··· if (firstEl !== elem) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (firstEl !== elem) {··· elToken = file.getFirstNodeToken(elem); comma = file.getPrevToken(elToken); errors.assert.differentLine({ token: comma, nextToken: elToken, message: 'Multiple elements at a single line in multiline array' }); } |
✓ Negative was executed (else) | }··· }); |
Function asc | |
---|---|
✓ Was called | function asc(a, b) {··· return String(a) < String(b) ? -1 : 1; } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | return String(a) < String(b) ? -1 : 1; |
✓ Negative was returned (: ...) | return String(a) < String(b) ? -1 : 1; |
Function ascInsensitive | |
---|---|
✓ Was called | function ascInsensitive(a, b) {··· var lowercaseA = String(a).toLowerCase(); var lowercaseB = String(b).toLowerCase(); if (lowercaseA < lowercaseB) { return -1; } if (lowercaseA > lowercaseB) { return 1; } return asc(a, b); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lowercaseA < lowercaseB) {··· return -1; } |
✓ Negative was executed (else) | }··· if (lowercaseA > lowercaseB) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (lowercaseA > lowercaseB) {··· return 1; } |
✓ Negative was executed (else) | }··· return asc(a, b); |
Function ascNatural | |
---|---|
✓ Was called | function ascNatural(a, b) {··· return naturalSort(a, b); } |
Function desc | |
---|---|
✓ Was called | function desc(a, b) {··· return asc(a, b) * -1; } |
Function descInsensitive | |
---|---|
✓ Was called | function descInsensitive(a, b) {··· return ascInsensitive(a, b) * -1; } |
Function descNatural | |
---|---|
✓ Was called | function descNatural(a, b) {··· return naturalSort(a, b) * -1; } |
Function (anonymous_1332) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1333) | |
---|---|
✓ Was called | configure: function(options) {··· assert( options === true || Object.keys(methods).indexOf(options) !== -1, this.getOptionName() + ' option requires a true value or should be removed' ); this._sort = methods[options] || methods.asc; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | options === true || Object.keys(methods).indexOf(options) !== -1, |
✗ Was not returned | options === true || Object.keys(methods).indexOf(options) !== -1, |
Branch LogicalExpression | |
---|---|
✗ Was not returned | this._sort = methods[options] || methods.asc; |
✓ Was returned | this._sort = methods[options] || methods.asc; |
Function (anonymous_1334) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'validateOrderInObjectKeys'; }, |
Function (anonymous_1335) | |
---|---|
✓ Was called | check: function(file, errors) {··· var sort = this._sort; file.iterateNodesByType('ObjectExpression', function(node) { var keys = node.properties.map(function(property) { return (property.key.name || property.key.value); }); var sorted = keys.slice(0).sort(sort); var unsorted; for (var i = 0; i < keys.length; i++) { if (keys[i] !== sorted[i]) { unsorted = i; break; } } if (undefined !== unsorted) { errors.add( 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', node.properties[unsorted] ); } }); } |
Function (anonymous_1336) | |
---|---|
✓ Was called | file.iterateNodesByType('ObjectExpression', function(node) {··· var keys = node.properties.map(function(property) { return (property.key.name || property.key.value); }); var sorted = keys.slice(0).sort(sort); var unsorted; for (var i = 0; i < keys.length; i++) { if (keys[i] !== sorted[i]) { unsorted = i; break; } } if (undefined !== unsorted) { errors.add( 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', node.properties[unsorted] ); } }); |
Function (anonymous_1337) | |
---|---|
✓ Was called | var keys = node.properties.map(function(property) {··· return (property.key.name || property.key.value); }); |
Branch LogicalExpression | |
---|---|
✓ Was returned | return (property.key.name || property.key.value); |
✓ Was returned | return (property.key.name || property.key.value); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (keys[i] !== sorted[i]) {··· unsorted = i; break; } |
✓ Negative was executed (else) | }··· } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (undefined !== unsorted) {··· errors.add( 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', node.properties[unsorted] ); } |
✓ Negative was executed (else) | }··· }); |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', |
✓ Negative was returned (: ...) | 'Object keys must be in ' + (/asc/.test(sort.name) ? 'ascending' : 'descending') + ' order', |
Function (anonymous_1338) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1339) | |
---|---|
✓ Was called | configure: function(options) {··· assert( typeof options === 'string' && /^[ ]?,[ ]?$/.test(options), this.getOptionName() + ' option requires string value containing only a comma and optional spaces' ); this._separator = options; }, |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof options === 'string' && /^[ ]?,[ ]?$/.test(options), |
✓ Was returned | typeof options === 'string' && /^[ ]?,[ ]?$/.test(options), |
Function (anonymous_1340) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'validateParameterSeparator'; }, |
Function (anonymous_1341) | |
---|---|
✓ Was called | check: function(file, errors) {··· var separators = this._separator.split(','); var whitespaceBeforeComma = Boolean(separators.shift()); var whitespaceAfterComma = Boolean(separators.pop()); file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) { node.params.forEach(function(paramNode) { var prevParamToken = file.getFirstNodeToken(paramNode); var punctuatorToken = file.getNextToken(prevParamToken); if (punctuatorToken.value === ',') { if (whitespaceBeforeComma) { errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } var nextParamToken = file.getNextToken(punctuatorToken); if (whitespaceAfterComma) { errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } } }); }); } |
Function (anonymous_1342) | |
---|---|
✓ Was called | file.iterateNodesByType(['FunctionDeclaration', 'FunctionExpression'], function(node) {··· node.params.forEach(function(paramNode) { var prevParamToken = file.getFirstNodeToken(paramNode); var punctuatorToken = file.getNextToken(prevParamToken); if (punctuatorToken.value === ',') { if (whitespaceBeforeComma) { errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } var nextParamToken = file.getNextToken(punctuatorToken); if (whitespaceAfterComma) { errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } } }); }); |
Function (anonymous_1343) | |
---|---|
✓ Was called | node.params.forEach(function(paramNode) {··· var prevParamToken = file.getFirstNodeToken(paramNode); var punctuatorToken = file.getNextToken(prevParamToken); if (punctuatorToken.value === ',') { if (whitespaceBeforeComma) { errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } var nextParamToken = file.getNextToken(punctuatorToken); if (whitespaceAfterComma) { errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (punctuatorToken.value === ',') {··· if (whitespaceBeforeComma) { errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } var nextParamToken = file.getNextToken(punctuatorToken); if (whitespaceAfterComma) { errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (whitespaceBeforeComma) {··· errors.assert.spacesBetween({ token: prevParamToken, nextToken: punctuatorToken, exactly: 1, message: 'One space required after function parameter \'' + prevParamToken.value + '\'' }); } else { |
✓ Negative was executed (else) | } else {··· errors.assert.noWhitespaceBetween({ token: prevParamToken, nextToken: punctuatorToken, message: 'Unexpected space after function parameter \'' + prevParamToken.value + '\'' }); } |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (whitespaceAfterComma) {··· errors.assert.spacesBetween({ token: punctuatorToken, nextToken: nextParamToken, exactly: 1, message: 'One space required before function parameter \'' + nextParamToken.value + '\'' }); } else { |
✓ Negative was executed (else) | } else {··· errors.assert.noWhitespaceBetween({ token: punctuatorToken, nextToken: nextParamToken, message: 'Unexpected space before function parameter \'' + nextParamToken.value + '\'' }); } |
Function (anonymous_1344) | |
---|---|
✓ Was called | module.exports = function() {}; |
Function (anonymous_1345) | |
---|---|
✓ Was called | configure: function(quoteMark) {··· this._allowEscape = false; this._ignoreJSX = false; if (typeof quoteMark === 'object') { assert( typeof quoteMark.escape === 'boolean' && quoteMark.mark !== undefined, this.getOptionName() + ' option requires the "escape" and "mark" property to be defined' ); this._allowEscape = quoteMark.escape; if (quoteMark.ignoreJSX) { this._ignoreJSX = quoteMark.ignoreJSX; } quoteMark = quoteMark.mark; } assert( quoteMark === '"' || quoteMark === '\'' || quoteMark === true, this.getOptionName() + ' option requires \'"\', "\'", or boolean true' ); assert( quoteMark === '"' || quoteMark === '\'' || quoteMark === true, this.getOptionName() + ' option requires \'"\', "\'", or boolean true' ); this._quoteMark = quoteMark; }, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (typeof quoteMark === 'object') {··· assert( typeof quoteMark.escape === 'boolean' && quoteMark.mark !== undefined, this.getOptionName() + ' option requires the "escape" and "mark" property to be defined' ); this._allowEscape = quoteMark.escape; if (quoteMark.ignoreJSX) { this._ignoreJSX = quoteMark.ignoreJSX; } quoteMark = quoteMark.mark; } |
✓ Negative was executed (else) | }··· assert( |
Branch LogicalExpression | |
---|---|
✓ Was returned | typeof quoteMark.escape === 'boolean' && quoteMark.mark !== undefined, |
✓ Was returned | typeof quoteMark.escape === 'boolean' && quoteMark.mark !== undefined, |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (quoteMark.ignoreJSX) {··· this._ignoreJSX = quoteMark.ignoreJSX; } |
✓ Negative was executed (else) | }··· quoteMark = quoteMark.mark; |
Branch LogicalExpression | |
---|---|
✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
Branch LogicalExpression | |
✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
Branch LogicalExpression | |
---|---|
✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
Branch LogicalExpression | |
✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
✓ Was returned | quoteMark === '"' || quoteMark === '\'' || quoteMark === true, |
Function (anonymous_1346) | |
---|---|
✓ Was called | getOptionName: function() {··· return 'validateQuoteMarks'; }, |
Function (anonymous_1347) | |
---|---|
✓ Was called | check: function(file, errors) {··· var quoteMark = this._quoteMark; var allowEscape = this._allowEscape; var ignoreJSX = this._ignoreJSX; var opposite = { '"': '\'', '\'': '"' }; file.iterateTokensByType('String', function(token) { if ( ignoreJSX && token.parentElement.type === 'StringLiteral' && token.parentElement.parentElement.type === 'JSXAttribute' ) { return; } var str = token.getSourceCode(); var mark = str[0]; var stripped = str.substring(1, str.length - 1); if (quoteMark === true) { quoteMark = mark; } if (mark !== quoteMark) { if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { return; } errors.cast({ message: 'Invalid quote mark found', element: token, additional: token }); } }); }, |
Function (anonymous_1348) | |
---|---|
✓ Was called | file.iterateTokensByType('String', function(token) {··· if ( ignoreJSX && token.parentElement.type === 'StringLiteral' && token.parentElement.parentElement.type === 'JSXAttribute' ) { return; } var str = token.getSourceCode(); var mark = str[0]; var stripped = str.substring(1, str.length - 1); if (quoteMark === true) { quoteMark = mark; } if (mark !== quoteMark) { if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { return; } errors.cast({ message: 'Invalid quote mark found', element: token, additional: token }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | ) {··· return; } |
✓ Negative was executed (else) | }··· var str = token.getSourceCode(); |
Branch LogicalExpression | |
---|---|
✓ Was returned | token.parentElement.parentElement.type === 'JSXAttribute' |
✓ Was returned | ignoreJSX &&··· token.parentElement.type === 'StringLiteral' && |
Branch LogicalExpression | |
✓ Was returned | token.parentElement.type === 'StringLiteral' && |
✓ Was returned | ignoreJSX && |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (quoteMark === true) {··· quoteMark = mark; } |
✓ Negative was executed (else) | }··· if (mark !== quoteMark) { |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (mark !== quoteMark) {··· if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { return; } errors.cast({ message: 'Invalid quote mark found', element: token, additional: token }); } |
✓ Negative was executed (else) | }··· }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (allowEscape && stripped.indexOf(opposite[mark]) > -1) {··· return; } |
✓ Negative was executed (else) | }··· errors.cast({ |
Branch LogicalExpression | |
✓ Was returned | if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { |
✓ Was returned | if (allowEscape && stripped.indexOf(opposite[mark]) > -1) { |
Function (anonymous_1349) | |
---|---|
✓ Was called | _fix: function(file, error) {··· var token = error.additional; var fixer = require(this._quoteMark === '"' ? 'to-double-quotes' : 'to-single-quotes'); var newToken = cst.Token.createFromToken({ type: 'String', value: token.value, sourceCode: fixer(token.getSourceCode()) }); token.parentElement.replaceChild(newToken, token); } |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | var fixer = require(this._quoteMark === '"' ? 'to-double-quotes' : 'to-single-quotes'); |
✓ Negative was returned (: ...) | var fixer = require(this._quoteMark === '"' ? 'to-double-quotes' : 'to-single-quotes'); |
Function (anonymous_1350) | |
---|---|
✓ Was called | module.exports = function(errorsCollection) {··· var Table = require('cli-table'); var hasError = false; var errorsByRule = {}; var style = { 'padding-left': 0, 'padding-right': 0, 'head': ['yellow'], 'border': ['red'], 'compact': false }; var errorsByFileTable = new Table({ 'head': ['Path', 'Total Errors'], 'colAligns': [ 'middle', 'middle', 'middle' ], 'colWidths': [62, 18], 'style': style }); var errorsByRuleTable = new Table({ 'head': ['Rule', 'Total Errors', 'Files With Errors'], 'colAligns': [ 'middle', 'middle', 'middle' ], 'colWidths': [49, 12, 18], 'style': style }); errorsCollection.forEach(function(errors) { var fileName = errors.getFilename(); if (!errors.isEmpty()) { hasError = true; errorsByFileTable.push([fileName, errors.getErrorCount()]); errors.getErrorList().forEach(function(error) { if (error.rule in errorsByRule) { errorsByRule[error.rule] .count += 1; } else { errorsByRule[error.rule] = { count: 1, files: {} }; } errorsByRule[error.rule].files[fileName] = 1; }); } }); var totalErrors = 0; var totalFilesWithErrors = 0; Object.getOwnPropertyNames(errorsByRule).forEach(function(ruleName) { var fileCount = Object.getOwnPropertyNames(errorsByRule[ruleName].files).length; errorsByRuleTable.push([ruleName, errorsByRule[ruleName].count, fileCount]); totalErrors += errorsByRule[ruleName].count; totalFilesWithErrors += fileCount; }); errorsByRuleTable.push(['All', totalErrors, totalFilesWithErrors]); if (hasError === false) { console.log('No code style errors found.'); } else { console.log(errorsByFileTable.toString()); console.log(errorsByRuleTable.toString()); } }; |
Function (anonymous_1351) | |
---|---|
✓ Was called | errorsCollection.forEach(function(errors) {··· var fileName = errors.getFilename(); if (!errors.isEmpty()) { hasError = true; errorsByFileTable.push([fileName, errors.getErrorCount()]); errors.getErrorList().forEach(function(error) { if (error.rule in errorsByRule) { errorsByRule[error.rule] .count += 1; } else { errorsByRule[error.rule] = { count: 1, files: {} }; } errorsByRule[error.rule].files[fileName] = 1; }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!errors.isEmpty()) {··· hasError = true; errorsByFileTable.push([fileName, errors.getErrorCount()]); errors.getErrorList().forEach(function(error) { if (error.rule in errorsByRule) { errorsByRule[error.rule] .count += 1; } else { errorsByRule[error.rule] = { count: 1, files: {} }; } errorsByRule[error.rule].files[fileName] = 1; }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1352) | |
---|---|
✓ Was called | errors.getErrorList().forEach(function(error) {··· if (error.rule in errorsByRule) { errorsByRule[error.rule] .count += 1; } else { errorsByRule[error.rule] = { count: 1, files: {} }; } errorsByRule[error.rule].files[fileName] = 1; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (error.rule in errorsByRule) {··· errorsByRule[error.rule] .count += 1; } else { |
✓ Negative was executed (else) | } else {··· errorsByRule[error.rule] = { count: 1, files: {} }; } |
Function (anonymous_1353) | |
---|---|
✓ Was called | Object.getOwnPropertyNames(errorsByRule).forEach(function(ruleName) {··· var fileCount = Object.getOwnPropertyNames(errorsByRule[ruleName].files).length; errorsByRuleTable.push([ruleName, errorsByRule[ruleName].count, fileCount]); totalErrors += errorsByRule[ruleName].count; totalFilesWithErrors += fileCount; }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (hasError === false) {··· console.log('No code style errors found.'); } else { |
✓ Negative was executed (else) | } else {··· console.log(errorsByFileTable.toString()); console.log(errorsByRuleTable.toString()); } |
Function (anonymous_1354) | |
---|---|
✓ Was called | module.exports = function(errorsCollection) {··· var errorCount = 0; /** * Formatting every error set. */ errorsCollection.forEach(function(errors) { if (!errors.isEmpty()) { /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error) + '\n'); }); } }); if (errorCount) { /** * Printing summary. */ console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); } }; |
Function (anonymous_1355) | |
---|---|
✓ Was called | errorsCollection.forEach(function(errors) {··· if (!errors.isEmpty()) { /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error) + '\n'); }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!errors.isEmpty()) {··· /** * Formatting every single error. */ errors.getErrorList().forEach(function(error) { errorCount++; console.log(errors.explainError(error) + '\n'); }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1356) | |
---|---|
✓ Was called | errors.getErrorList().forEach(function(error) {··· errorCount++; console.log(errors.explainError(error) + '\n'); }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (errorCount) {··· /** * Printing summary. */ console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); } |
✓ Negative was executed (else) | }··· }; |
Branch ConditionalExpression | |
---|---|
✓ Positive was returned (? ...) | console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); |
✓ Negative was returned (: ...) | console.log('\n' + errorCount + ' code style ' + (errorCount === 1 ? 'error' : 'errors') + ' found.'); |
Function (anonymous_1357) | |
---|---|
✓ Was called | module.exports = function(errorsCollection) {··· errorsCollection.forEach(function(errors) { var file = errors.getFilename(); if (!errors.isEmpty()) { errors.getErrorList().forEach(function(error) { console.log(util.format('%s:%d:%d: %s', file, error.line, error.column, error.message)); }); } }); }; |
Function (anonymous_1358) | |
---|---|
✓ Was called | errorsCollection.forEach(function(errors) {··· var file = errors.getFilename(); if (!errors.isEmpty()) { errors.getErrorList().forEach(function(error) { console.log(util.format('%s:%d:%d: %s', file, error.line, error.column, error.message)); }); } }); |
Branch IfStatement | |
---|---|
✓ Positive was executed (if) | if (!errors.isEmpty()) {··· errors.getErrorList().forEach(function(error) { console.log(util.format('%s:%d:%d: %s', file, error.line, error.column, error.message)); }); } |
✓ Negative was executed (else) | }··· }); |
Function (anonymous_1359) | |
---|---|
✓ Was called | errors.getErrorList().forEach(function(error) {··· console.log(util.format('%s:%d:%d: %s', file, error.line, error.column, error.message)); }); |