Skip to content

Commit

Permalink
Fix all eslint failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstange committed May 13, 2016
1 parent 7b774e1 commit b2fe257
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 47 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ module.exports = {
"comma-dangle": [
"error",
"always-multiline"
],
"no-console": [
"error",
{ allow: ["log", "warn", "error"] }
]
},
"settings": {
Expand Down
17 changes: 16 additions & 1 deletion src/components/VirtualList.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ class VirtualListRow extends Component {
}
}

VirtualListRow.propTypes = {
renderItem: PropTypes.func.isRequired,
item: PropTypes.any.isRequired,
index: PropTypes.number.isRequired,
};

class VirtualList extends Component {

constructor(props) {
super(props);
this._scrollListener = e => this.forceUpdate();
this._scrollListener = () => this.forceUpdate();
}

componentDidMount() {
Expand Down Expand Up @@ -98,4 +104,13 @@ class VirtualList extends Component {

}

VirtualList.propTypes = {
itemHeight: PropTypes.number.isRequired,
className: PropTypes.string,
renderItem: PropTypes.func.isRequired,
items: PropTypes.array.isRequired,
focusable: PropTypes.bool.isRequired,
onKeyDown: PropTypes.func.isRequired,
};

export default VirtualList;
11 changes: 10 additions & 1 deletion src/containers/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { preprocessProfile } from '../preprocess-profile';
import { getTimeRangeIncludingAllThreads } from '../profile-data';
import { symbolicateProfile } from '../symbolication';
import { SymbolStore } from '../symbol-store';
import * as Actions from '../actions';
Expand Down Expand Up @@ -60,4 +59,14 @@ class App extends Component {
);
}
}

App.propTypes = {
view: PropTypes.string.isRequired,
profileView: PropTypes.shape({
profile: PropTypes.object.isRequired,
viewOptions: PropTypes.object.isRequired,
}).isRequired,
dispatch: PropTypes.func.isRequired,
};

export default connect(state => state)(App);
6 changes: 5 additions & 1 deletion src/containers/Root.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { Component, PropTypes } from 'react';
import { Provider } from 'react-redux';
import App from './App';

Expand All @@ -12,3 +12,7 @@ export default class Root extends Component {
);
}
}

Root.propTypes = {
store: PropTypes.any.isRequired,
};
6 changes: 3 additions & 3 deletions src/function-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ function cleanFunctionName(functionName) {
}

function addonWithID(addonID) {
return firstMatch(meta.addons, function addonHasID(addon) {
return meta.addons.find(function addonHasID(addon) {
return addon.id.toLowerCase() == addonID.toLowerCase();
});
}

function findAddonForChromeURIHost(host) {
return firstMatch(meta.addons, function addonUsesChromeURIHost(addon) {
return meta.addons.find(function addonUsesChromeURIHost(addon) {
return addon.chromeURIHosts && addon.chromeURIHosts.indexOf(host) != -1;
});
}
Expand All @@ -41,7 +41,7 @@ function getAddonForScriptURI(url, host) {
if (!meta || !meta.addons)
return null;

if (url.startsWith('resource:') && endsWith(host, '-at-jetpack')) {
if (url.startsWith('resource:') && host.endsWith('-at-jetpack')) {
// Assume this is a jetpack url
var jetpackID = host.substring(0, host.length - 11) + '@jetpack';
return addonWithID(jetpackID);
Expand Down
6 changes: 1 addition & 5 deletions src/preprocess-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function preprocessThread(thread, libs) {
function addURLResource(url) {
const index = resourceTable.length++;
resourceTable.type[index] = resourceTypes.url;
resourceTable.name[index] = name;
resourceTable.name[index] = url;
}

const stringTable = new UniqueStringArray(thread.stringTable);
Expand Down Expand Up @@ -152,10 +152,6 @@ function preprocessSharedLibraries(libs) {
* Adjust the "time" field by the given delta.
*/
function adjustTimestamps(samplesOrMarkers, delta) {
if (!samplesOrMarkers.time) {
console.log('don\'t have samplesOrMarkers.time!');
console.log(samplesOrMarkers);
}
return Object.assign({}, samplesOrMarkers, {
time: samplesOrMarkers.time.map(time => time === undefined ? undefined : time + delta),
});
Expand Down
1 change: 0 additions & 1 deletion src/profile-tree.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { timeCode } from './time-code';
import { getFuncStackInfo } from './profile-data';

class ProfileTree {
constructor(funcStackTable, funcStackTimes, funcStackChildCount, funcTable, stringTable, rootTotalTime, rootCount) {
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function selectedThread(state = 0, action) {
function viewOptionsThreads(state = [], action) {
switch (action.type) {
case 'RECEIVE_PROFILE_FROM_ADDON':
return action.profile.threads.map(thread => ({
return action.profile.threads.map(() => ({
selectedFuncStack: [],
expandedFuncStacks: [],
}));
Expand Down
3 changes: 1 addition & 2 deletions src/symbol-store-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export class SymbolStoreDB {

return new Promise((resolve, reject) => {
let transaction = this._db.transaction('symbol-tables', 'readwrite');
let libKey = null;
transaction.onerror = reject;
let tableStore = transaction.objectStore('symbol-tables');
let putReq = tableStore.put({ pdbName, breakpadId, addrs, index, buffer });
Expand Down Expand Up @@ -110,7 +109,7 @@ export class SymbolStoreDB {
reject(new Error('unexpected null result'));
return;
}
const { addrs, index, buffer } = req.result;
const { index, buffer } = req.result;
const decoder = new TextDecoder();
resolve(requestedAddressesIndices.map(addrIndex => {
const startOffset = index[addrIndex];
Expand Down
2 changes: 1 addition & 1 deletion src/symbol-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class SymbolStore {
if (this._failedRequests.has(libid)) {
return Promise.reject(new Error('We\'ve tried to request a symbol table for this library before and failed, so we\'re not trying again.'));
}
return this._db.getLibKey(pdbName, breakpadId).catch(error => {
return this._db.getLibKey(pdbName, breakpadId).catch(() => {
if (this._importingLibs.has(libid)) {
// We've already requested a symbol table for this library and are
// waiting for the result, so just return the promise for the existing
Expand Down
29 changes: 5 additions & 24 deletions src/symbolication.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import bisection from 'bisection';
import { resourceTypes } from './profile-data';
import { UniqueStringArray } from './unique-string-array';

/**
* Return the library object that contains address.
Expand Down Expand Up @@ -125,7 +124,8 @@ function findFunctionsToMergeAndSymbolicationAddresses(funcAddressTable, funcsTo
// inside of.
let funcAddressIndex = bisection.right(funcAddressTable, funcAddress, nextFuncAddressIndex) - 1;
if (funcAddressIndex >= 0) {
const realFuncAddress = funcAddressTable[funcAddressIndex];
// TODO: Take realFuncAddress and put it into the func table.
// const realFuncAddress = funcAddressTable[funcAddressIndex];
nextFuncAddressIndex = funcAddressIndex + 1;
nextFuncAddress = (nextFuncAddressIndex < funcAddressTable.length) ? funcAddressTable[nextFuncAddressIndex] : Infinity;
lastFuncIndex = funcIndex;
Expand Down Expand Up @@ -191,23 +191,6 @@ export function applyFunctionMerging(thread, oldFuncToNewFuncMap) {
* @return Promise A promise that resolves (with nothing) once symbolication of the thread has completed.
*/
function symbolicateThread(thread, threadIndex, symbolStore, cbo) {
let updatedThread = thread;

let scheduledThreadUpdate = false;
function scheduleThreadUpdate() {
if (!scheduledThreadUpdate) {
setTimeout(callOnUpdateThread, 0);
scheduledThreadUpdate = true;
}
}

function callOnUpdateThread() {
updatedThread = applyFunctionMerging(updatedThread, oldFuncToNewFuncMap);
cbo.onUpdateThread(updatedThread, oldFuncToNewFuncMap);
oldFuncToNewFuncMap = new Map();
scheduledThreadUpdate = false;
}

let foundFuncs = gatherFuncsInThread(thread);
return Promise.all(Array.from(foundFuncs).map(function ([lib, funcsToSymbolicate]) {
// lib is a lib object from thread.libs.
Expand All @@ -218,16 +201,15 @@ function symbolicateThread(thread, threadIndex, symbolStore, cbo) {
// We don't have any symbols yet. We'll request those after we've merged
// the functions.
const { funcAddrIndices, funcIndices, oldFuncToNewFuncMap } =
findFunctionsToMergeAndSymbolicationAddresses(funcAddressTable, funcsToSymbolicate, updatedThread.funcTable);
findFunctionsToMergeAndSymbolicationAddresses(funcAddressTable, funcsToSymbolicate, thread.funcTable);
cbo.onMergeFunctions(threadIndex, oldFuncToNewFuncMap);

// Now list the func addresses that we want symbols for, and request them.
return symbolStore.getSymbolsForAddressesInLib(funcAddrIndices, lib).then(funcNames => {
cbo.onGotFuncNames(threadIndex, funcIndices, funcNames);
});
}).catch(error => {
console.log(`Couldn't get symbols for library ${lib.pdbName} ${lib.breakpadId}`);
console.error(error);
}).catch(() => {
// We could not find symbols for this library.
// Don't throw, so that the resulting promise will be resolved, thereby
// indicating that we're done symbolicating with lib.
});
Expand All @@ -243,7 +225,6 @@ function symbolicateThread(thread, threadIndex, symbolStore, cbo) {
* @return Promise A promise that resolves (with nothing) once symbolication has completed.
*/
export function symbolicateProfile(profile, symbolStore, cbo) {
let updatedProfile = profile;
return Promise.all(profile.threads.map((thread, threadIndex) => {
return symbolicateThread(thread, threadIndex, symbolStore, cbo);
}));
Expand Down
15 changes: 8 additions & 7 deletions src/time-code.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export function timeCode(label, codeAsACallback) {
if (typeof performance === 'undefined') {
return codeAsACallback();
if (typeof performance !== 'undefined' &&
process.env.NODE_ENV === 'development') {
const start = performance.now();
const result = codeAsACallback();
const elapsed = Math.round(performance.now() - start);
console.log(`${label} took ${elapsed}ms to execute.`);
return result;
}
const start = performance.now();
const result = codeAsACallback();
const elapsed = Math.round(performance.now() - start);
console.log(`${label} took ${elapsed}ms to execute.`);
return result;
return codeAsACallback();
}

0 comments on commit b2fe257

Please sign in to comment.