Skip to content

Commit

Permalink
Fix non auto-fixable errors
Browse files Browse the repository at this point in the history
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
  • Loading branch information
tahini committed Jul 7, 2020
1 parent 870a21d commit 0fceb09
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 47 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"download:server": "curl -o trace-compass-server.tar.gz https://download.eclipse.org/tracecompass.incubator/trace-server/rcp/trace-compass-server-latest-linux.gtk.x86_64.tar.gz; tar -xf trace-compass-server.tar.gz",
"start:server": "./trace-compass-server/tracecompass-server",
"start-all:browser": "yarn start:server & yarn start:browser",
"start-all:electron": "yarn start:server & yarn start:electron"
"start-all:electron": "yarn start:server & yarn start:electron",
"lint": "yarn workspace trace-viewer run lint"
},
"devDependencies": {
"lerna": "2.4.0"
Expand Down
3 changes: 2 additions & 1 deletion viewer-prototype/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"
"watch": "tsc -w",
"lint": "eslint ."
},
"theiaExtensions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class TraceExplorerWidget extends ReactWidget {

private renderTooltip() {
this.handleSourcecodeLockup = this.handleSourcecodeLockup.bind(this);
const tooltipArray: any[] = [];
const tooltipArray: JSX.Element[] = [];
if (this.tooltip) {
const keys = Object.keys(this.tooltip);
keys.forEach(key => {
Expand All @@ -169,7 +169,9 @@ export class TraceExplorerWidget extends ReactWidget {
fileLocation = matches[1];
line = matches[2];
}
tooltipArray.push(<p className='source-code-tooltip' key={key} onClick={this.handleSourcecodeLockup.bind(this, fileLocation, line)}>{key + ': ' + sourceCodeInfo}</p>);
tooltipArray.push(<p className='source-code-tooltip'
key={key}
onClick={this.handleSourcecodeLockup.bind(this, fileLocation, line)}>{key + ': ' + sourceCodeInfo}</p>);
} else {
tooltipArray.push(<p key={key}>{key + ': ' + this.tooltip[key]}</p>);
}
Expand Down Expand Up @@ -262,7 +264,7 @@ export class TraceExplorerWidget extends ReactWidget {
}
}
let traceContainerClassName = 'trace-element-container';
if (props.index == this.selectedExperimentIndex) {
if (props.index === this.selectedExperimentIndex) {
traceContainerClassName = traceContainerClassName + ' theia-mod-selected';
}
this.handleShareButtonClick = this.handleShareButtonClick.bind(this);
Expand Down Expand Up @@ -316,7 +318,7 @@ export class TraceExplorerWidget extends ReactWidget {
}
}
let traceContainerClassName = 'outputs-list-container';
if (props.index == this.lastSelectedOutputIndex) {
if (props.index === this.lastSelectedOutputIndex) {
traceContainerClassName = traceContainerClassName + ' theia-mod-selected';
}
return <div className={traceContainerClassName} key={props.key} style={props.style} onClick={this.outputClicked.bind(this, props.index)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export abstract class AbstractTreeOutputComponent<P extends AbstractOutputProps,
renderMainArea(): React.ReactNode {
const treeWidth = this.props.style.width - this.props.style.chartWidth - this.getHandleWidth();
return <React.Fragment>
<div ref={this.treeRef} className='output-component-tree' onScroll={ev => { this.synchronizeTreeScroll(); }} style={{ width: treeWidth, height: this.props.style.height }}>
<div ref={this.treeRef} className='output-component-tree'
onScroll={ev => { this.synchronizeTreeScroll(); }}
style={{ width: treeWidth, height: this.props.style.height }}
>
{this.renderTree()}
</div>
<div className='output-component-chart' style={{ width: this.props.style.chartWidth, backgroundColor: '#3f3f3f' }}>
Expand All @@ -17,8 +20,7 @@ export abstract class AbstractTreeOutputComponent<P extends AbstractOutputProps,
</React.Fragment>;
}

treeRef = React.createRef<any>();
chartRef = React.createRef<any>();
treeRef: React.RefObject<HTMLDivElement> = React.createRef();

abstract renderTree(): React.ReactNode;

Expand All @@ -45,8 +47,7 @@ export abstract class AbstractTreeOutputComponent<P extends AbstractOutputProps,

componentWillUnmount() {
// fix Warning: Can't perform a React state update on an unmounted component
this.setState = (state,callback)=>{
return;
};
this.setState = (state,callback) => undefined;

}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { TspClient } from 'tsp-typescript-client/lib/protocol/tsp-client';
import { QueryHelper } from 'tsp-typescript-client/lib/models/query/query-helper';
import { OutputElementStyle } from 'tsp-typescript-client/lib/models/styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { TspClient } from 'tsp-typescript-client/lib/protocol/tsp-client';
import { TimeGraphEntry, TimeGraphRow, TimeGraphModel, TimeGraphState } from 'tsp-typescript-client/lib/models/timegraph';
import { TimelineChart } from 'timeline-chart/lib/time-graph-model';
Expand Down Expand Up @@ -27,7 +28,8 @@ export class TspDataProvider {
}

async getData(viewRange?: TimelineChart.TimeGraphRange, resolution?: number): Promise<TimelineChart.TimeGraphModel> {
const resourcesTreeParameters = QueryHelper.timeQuery([0, 1]); // QueryHelper.timeQuery(QueryHelper.splitRangeIntoEqualParts(1332170682440133097, 1332170682540133097, 1120));
// QueryHelper.timeQuery(QueryHelper.splitRangeIntoEqualParts(1332170682440133097, 1332170682540133097, 1120));
const resourcesTreeParameters = QueryHelper.timeQuery([0, 1]);
const treeResponse = (await this.client.fetchTimeGraphTree<TimeGraphEntry, EntryHeader>(
this.traceUUID,
this.outputId,
Expand Down Expand Up @@ -57,7 +59,7 @@ export class TspDataProvider {
const rows: TimelineChart.TimeGraphRowModel[] = [];
this.timeGraphRows.forEach((row: TimeGraphRow) => {
const rowId: number = (row as any).entryID;
const entry = this.timeGraphEntries.find(entry => entry.id === rowId);
const entry = this.timeGraphEntries.find(tgEntry => tgEntry.id === rowId);
if (entry) {
const states = this.getStateModelByRow(row, chartStart);
rows.push({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { AbstractOutputComponent, AbstractOutputProps, AbstractOutputState } from './abstract-output-component';
import * as React from 'react';
import { AgGridReact } from 'ag-grid-react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
this.vscrollLayer = new TimeGraphVerticalScrollbar('timeGraphVerticalScrollbar', this.rowController);

this.rowController.onVerticalOffsetChangedHandler(()=>{
this.treeRef.current.scrollTop=this.rowController.verticalOffset;
if (this.treeRef.current) {
this.treeRef.current.scrollTop=this.rowController.verticalOffset;
}
});

this.chartLayer.onSelectedRowElementChanged(model => {
Expand All @@ -79,7 +81,9 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
}

synchronizeTreeScroll(): void {
this.rowController.verticalOffset=this.treeRef.current.scrollTop;
if (this.treeRef.current) {
this.rowController.verticalOffset=this.treeRef.current.scrollTop;
}
}

async componentDidMount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class TraceContextComponent extends React.Component<TraceContextProps, Tr
return milli + ':' + micro + ':' + nano; // THAT IS TOO LONG, need to find better format
};
this.unitController.onSelectionRangeChange(range => { this.handleTimeSelectionChange(range); });
this.unitController.onViewRangeChanged(viewRange => { this.handleViewRangeChange(viewRange); });
this.unitController.onViewRangeChanged(viewRangeParam => { this.handleViewRangeChange(viewRangeParam); });
this.traceContextContainer = React.createRef();
this.initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface TreeNode {
id: number;
parentId: number;
name: string;
children: [];
children: Array<TreeNode>;
isRoot: boolean;
}

Expand All @@ -25,7 +25,7 @@ interface TreeNodeComponentProps {
padding: number;
isCheckable: boolean;
collapsed: boolean;
children: JSX.Element | null;
children: JSX.Element | undefined;
onCollapsed: (id: number) => void;
onChecked: (id: number) => void;
}
Expand All @@ -37,14 +37,14 @@ export class TreeNodeComponent extends React.Component<TreeNodeComponentProps> {

private isLeaf = (): boolean => this.props.node.children.length === 0;

renderChildren = (): JSX.Element | null => {
renderChildren = (): JSX.Element | undefined => {
if (this.props.collapsed) {
return null;
return undefined;
}
return this.props.children;
};

render() {
render(): JSX.Element {
return (
<li style={{paddingLeft:this.props.padding}}>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface FilterTreeProps {
export class FilterTree extends React.Component<FilterTreeProps> {
static defaultProps: Partial<FilterTreeProps> = {
checkedSeries: [],
onChecked: () => {},
onChecked: () => { /* Nothing to do */ },
};

constructor(props: FilterTreeProps) {
Expand All @@ -26,7 +26,7 @@ export class FilterTree extends React.Component<FilterTreeProps> {
return nodes.filter((node: TreeNode) => node.isRoot === true);
};

getNode = (id: number): TreeNode | null => {
getNode = (id: number): TreeNode | undefined => {
const nodes: TreeNode[] = [...this.props.nodes];
let currentNode: TreeNode;
while(nodes.length) {
Expand All @@ -41,7 +41,7 @@ export class FilterTree extends React.Component<FilterTreeProps> {
}
}
}
return null;
return undefined;
};

handleCollapse = (id: number): void => {
Expand Down Expand Up @@ -77,7 +77,7 @@ export class FilterTree extends React.Component<FilterTreeProps> {
if (this.isNodeChecked(id)) {
checkedIds = checkedIds.concat(childrenIds);
} else {
const childIdsToCheck = childrenIds.filter(id => !this.isNodeChecked(id));
const childIdsToCheck = childrenIds.filter(childId => !this.isNodeChecked(childId));
checkedIds = checkedIds.concat(childIdsToCheck);
}
} else {
Expand Down Expand Up @@ -114,13 +114,13 @@ export class FilterTree extends React.Component<FilterTreeProps> {

isCollapsed = (id: number): boolean => this.props.collapsedNodes.includes(id);

renderTreeNodes = (nodes: TreeNode[], parent: TreeNode = defaultTreeNode, level = 0): JSX.Element | null => {
renderTreeNodes = (nodes: TreeNode[], parent: TreeNode = defaultTreeNode, level = 0): JSX.Element | undefined => {
const treeNodes = nodes.map((node: TreeNode) => {
const children = node.children.length > 0 ? this.renderTreeNodes(node.children, node, level+1) : null;
const children = node.children.length > 0 ? this.renderTreeNodes(node.children, node, level+1) : undefined;
const checkedStatus = this.getCheckedStatus(node.id);

if (!node.isRoot && this.isCollapsed(node.parentId)) {
return null;
return undefined;
}
return (
<TreeNodeComponent
Expand All @@ -145,8 +145,8 @@ export class FilterTree extends React.Component<FilterTreeProps> {
);
};

render() {
if (!this.props.nodes) {return null;}
render(): JSX.Element | undefined {
if (!this.props.nodes) {return undefined;}
const rootNodes = this.getRootNodes();
if (rootNodes && rootNodes.length) {
return this.renderTreeNodes(rootNodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const entryToTreeNode = (entry: Entry) => ({

export const listToTree = (list: Entry[]) => {
const rootNodes: TreeNode[] = [];
const lookup: any = {};
const lookup: { [key: string]: TreeNode } = {};
list.forEach(entry => {
lookup[entry.id] = entryToTreeNode(entry);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export class ReactTimeGraphContainer extends React.Component<ReactTimeGraphConta
componentDidMount() {
this.container = new TimeGraphContainer(this.props.options, this.props.unitController, this.ref);
this.props.layer.forEach(l => {
this.container && this.container.addLayer(l);
if (this.container) { this.container.addLayer(l); }
});

this.props.onWidgetResize(() => {
this.container && this.container.reInitCanvasSize(this.props.options.width);
if (this.container) { this.container.reInitCanvasSize(this.props.options.width); }
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { AbstractOutputProps, AbstractOutputState } from './abstract-output-component';
import { AbstractTreeOutputComponent } from './abstract-tree-output-component';
import * as React from 'react';
Expand Down Expand Up @@ -64,7 +65,7 @@ export class XYOutputComponent extends AbstractTreeOutputComponent<AbstractOutpu
}
}

synchronizeTreeScroll(): void {}
synchronizeTreeScroll(): void { /* Nothing to do by default */ }

renderTree(): React.ReactNode {
this.onSeriesChecked = this.onSeriesChecked.bind(this);
Expand Down
12 changes: 6 additions & 6 deletions viewer-prototype/src/common/experiment-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ export class ExperimentManager {
'name': name,
'traces': traceURIs
}));
const experiment = experimentResponse.getModel();
if (experiment && experimentResponse.isOk()) {
this.addExperiment(experiment);
this.experimentOpenedEmitter.fire(experiment);
return experiment;
} else if (experiment && experimentResponse.getStatusCode() === 409) {
const opendExperiment = experimentResponse.getModel();
if (opendExperiment && experimentResponse.isOk()) {
this.addExperiment(opendExperiment);
this.experimentOpenedEmitter.fire(opendExperiment);
return opendExperiment;
} else if (opendExperiment && experimentResponse.getStatusCode() === 409) {
// Repost with a suffix as long as there are conflicts
const handleConflict = async function (tspClient: TspClient, tryNb: number): Promise<TspClientResponse<Experiment>> {
const suffix = '(' + tryNb + ')';
Expand Down
12 changes: 6 additions & 6 deletions viewer-prototype/src/common/trace-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ export class TraceManager {
'name': name,
'uri': tracePath
}));
const trace = traceResponse.getModel();
if (trace && traceResponse.isOk()) {
this.addTrace(trace);
this.traceOpenedEmitter.fire(trace);
return trace;
} else if (trace && traceResponse.getStatusCode() === 409) {
const openedTrace = traceResponse.getModel();
if (openedTrace && traceResponse.isOk()) {
this.addTrace(openedTrace);
this.traceOpenedEmitter.fire(openedTrace);
return openedTrace;
} else if (openedTrace && traceResponse.getStatusCode() === 409) {
// Repost with a suffix as long as there are conflicts
const handleConflict = async function (tspClient: TspClient, tryNb: number): Promise<TspClientResponse<Trace>> {
const suffix = '(' + tryNb + ')';
Expand Down

0 comments on commit 0fceb09

Please sign in to comment.