diff options
author | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-03-17 09:10:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-17 09:10:48 +0100 |
commit | de4365079bad2df3bdee2133576dc913ffbf1ab2 (patch) | |
tree | a522ccb952f0d37f454e8188e13b3dec3f731912 /server/sonar-web/src/main/js/components/SourceViewer | |
parent | 6a03df65cc0c91a26150ea172a2c480e07326ea1 (diff) | |
download | sonarqube-de4365079bad2df3bdee2133576dc913ffbf1ab2.tar.gz sonarqube-de4365079bad2df3bdee2133576dc913ffbf1ab2.zip |
format code using prettier (#1774)
Diffstat (limited to 'server/sonar-web/src/main/js/components/SourceViewer')
28 files changed, 202 insertions, 189 deletions
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.js index e7b999e3231..0acd2dc123d 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewer.js @@ -39,9 +39,10 @@ const onReceiveComponent = (component: { key: string, canMarkAsFavorite: boolean } }; -const onReceiveIssues = (issues: Array<*>) => dispatch => { - dispatch(receiveIssues(issues)); -}; +const onReceiveIssues = (issues: Array<*>) => + dispatch => { + dispatch(receiveIssues(issues)); + }; const mapDispatchToProps = { onReceiveComponent, onReceiveIssues }; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js index 96e7641e525..d902f2c4b7f 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js @@ -136,7 +136,7 @@ export default class SourceViewerBase extends React.Component { loadSources }; - constructor (props: Props) { + constructor(props: Props) { super(props); this.state = { displayDuplications: false, @@ -161,18 +161,18 @@ export default class SourceViewerBase extends React.Component { }; } - componentDidMount () { + componentDidMount() { this.mounted = true; this.fetchComponent(); } - componentWillReceiveProps (nextProps: Props) { + componentWillReceiveProps(nextProps: Props) { if (nextProps.onIssueSelect != null && nextProps.selectedIssue !== this.props.selectedIssue) { this.setState({ selectedIssue: nextProps.selectedIssue, selectedIssueLocation: null }); } } - componentDidUpdate (prevProps: Props, prevState: State) { + componentDidUpdate(prevProps: Props, prevState: State) { if (prevProps.component !== this.props.component) { this.fetchComponent(); } else if ( @@ -191,11 +191,11 @@ export default class SourceViewerBase extends React.Component { } } - componentWillUnmount () { + componentWillUnmount() { this.mounted = false; } - scrollToLine (line: number) { + scrollToLine(line: number) { const lineElement = this.node.querySelector( `.source-line-code[data-line-number="${line}"] .source-line-issue-locations` ); @@ -204,11 +204,11 @@ export default class SourceViewerBase extends React.Component { } } - computeCoverageStatus (lines: Array<SourceLine>): Array<SourceLine> { + computeCoverageStatus(lines: Array<SourceLine>): Array<SourceLine> { return lines.map(line => ({ ...line, coverageStatus: getCoverageStatus(line) })); } - isLineOutsideOfRange (lineNumber: number) { + isLineOutsideOfRange(lineNumber: number) { const { sources } = this.state; if (sources != null && sources.length > 0) { const firstLine = sources[0]; @@ -219,7 +219,7 @@ export default class SourceViewerBase extends React.Component { } } - fetchComponent () { + fetchComponent() { this.setState({ loading: true }); const loadIssues = (component, sources) => { @@ -277,7 +277,7 @@ export default class SourceViewerBase extends React.Component { this.props.loadComponent(this.props.component).then(onResolve, onFailLoadComponent); } - fetchSources () { + fetchSources() { this.loadSources().then(sources => { if (this.mounted) { const finalSources = sources.slice(0, LINES); @@ -297,7 +297,7 @@ export default class SourceViewerBase extends React.Component { }); } - loadSources () { + loadSources() { return new Promise((resolve, reject) => { const onFailLoadSources = ({ response }) => { // TODO handle other statuses @@ -315,8 +315,8 @@ export default class SourceViewerBase extends React.Component { const to = this.props.aroundLine ? this.props.aroundLine + LINES / 2 + 1 : LINES + 1; return this.props - .loadSources(this.props.component, from, to) - .then(sources => resolve(sources), onFailLoadSources); + .loadSources(this.props.component, from, to) + .then(sources => resolve(sources), onFailLoadSources); }); } @@ -388,7 +388,7 @@ export default class SourceViewerBase extends React.Component { }); }; - getInitialLocationsPanelHeight () { + getInitialLocationsPanelHeight() { try { const rawValue = window.localStorage.getItem(LOCATIONS_PANEL_HEIGHT_LOCAL_STORAGE_KEY); if (!rawValue) { @@ -401,7 +401,7 @@ export default class SourceViewerBase extends React.Component { } } - storeLocationsPanelHeight (height: number) { + storeLocationsPanelHeight(height: number) { window.localStorage.setItem(LOCATIONS_PANEL_HEIGHT_LOCAL_STORAGE_KEY, height); } @@ -461,7 +461,7 @@ export default class SourceViewerBase extends React.Component { } }; - displayLinePopup (line: number, element: HTMLElement) { + displayLinePopup(line: number, element: HTMLElement) { const popup = new LineActionsPopupView({ line, triggerEl: element, @@ -532,7 +532,7 @@ export default class SourceViewerBase extends React.Component { })); }; - renderCode (sources: Array<SourceLine>) { + renderCode(sources: Array<SourceLine>) { const hasSourcesBefore = sources.length > 0 && sources[0].line > 1; return ( <SourceViewerCode @@ -571,11 +571,12 @@ export default class SourceViewerBase extends React.Component { selectedIssue={this.state.selectedIssue} selectedIssueLocation={this.state.selectedIssueLocation} sources={sources} - symbolsByLine={this.state.symbolsByLine}/> + symbolsByLine={this.state.symbolsByLine} + /> ); } - render () { + render() { const { component, loading } = this.state; if (loading) { @@ -607,7 +608,8 @@ export default class SourceViewerBase extends React.Component { <SourceViewerHeader component={this.state.component} openNewWindow={this.openNewWindow} - showMeasures={this.showMeasures}/> + showMeasures={this.showMeasures} + /> {this.state.notAccessible && <div className="alert alert-warning spacer-top"> {translate('code_viewer.no_source_code_displayed_due_to_security')} @@ -620,7 +622,8 @@ export default class SourceViewerBase extends React.Component { issue={selectedIssueObj} onResize={this.handleLocationsPanelResize} onSelectLocation={this.handleSelectIssueLocation} - selectedLocation={this.state.selectedIssueLocation}/>} + selectedLocation={this.state.selectedIssueLocation} + />} </div> ); } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js index d0b5eff25b0..9f709829891 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js @@ -76,19 +76,19 @@ export default class SourceViewerCode extends React.PureComponent { symbolsByLine: { [number]: Array<string> } }; - getDuplicationsForLine (line: SourceLine) { + getDuplicationsForLine(line: SourceLine) { return this.props.duplicationsByLine[line.line] || EMPTY_ARRAY; } - getIssuesForLine (line: SourceLine): Array<string> { + getIssuesForLine(line: SourceLine): Array<string> { return this.props.issuesByLine[line.line] || EMPTY_ARRAY; } - getIssueLocationsForLine (line: SourceLine) { + getIssueLocationsForLine(line: SourceLine) { return this.props.issueLocationsByLine[line.line] || EMPTY_ARRAY; } - getSecondaryIssueLocationsForLine (line: SourceLine, issueKey: string) { + getSecondaryIssueLocationsForLine(line: SourceLine, issueKey: string) { const index = this.props.issueSecondaryLocationsByIssueByLine; if (index[issueKey] == null) { return EMPTY_ARRAY; @@ -96,7 +96,7 @@ export default class SourceViewerCode extends React.PureComponent { return index[issueKey][line.line] || EMPTY_ARRAY; } - getSecondaryIssueLocationMessagesForLine (line: SourceLine, issueKey: string) { + getSecondaryIssueLocationMessagesForLine(line: SourceLine, issueKey: string) { return this.props.issueSecondaryLocationMessagesByIssueByLine[issueKey][line.line] || EMPTY_ARRAY; } @@ -176,11 +176,12 @@ export default class SourceViewerCode extends React.PureComponent { secondaryIssueLocations={secondaryIssueLocations} secondaryIssueLocationMessages={secondaryIssueLocationMessages} selectedIssue={optimizedSelectedIssue} - selectedIssueLocation={optimizedSelectedIssueLocation}/> + selectedIssueLocation={optimizedSelectedIssueLocation} + /> ); }; - render () { + render() { const { sources } = this.props; const hasCoverage = sources.some(s => s.coverageStatus != null); @@ -196,14 +197,15 @@ export default class SourceViewerCode extends React.PureComponent { <div className="source-viewer-more-code"> {this.props.loadingSourcesBefore ? <div className="js-component-viewer-loading-before"> - <i className="spinner"/> + <i className="spinner" /> <span className="note spacer-left"> {translate('source_viewer.loading_more_code')} </span> </div> : <button className="js-component-viewer-source-before" - onClick={this.props.loadSourcesBefore}> + onClick={this.props.loadSourcesBefore} + > {translate('source_viewer.load_more_code')} </button>} </div>} @@ -235,14 +237,15 @@ export default class SourceViewerCode extends React.PureComponent { <div className="source-viewer-more-code"> {this.props.loadingSourcesAfter ? <div className="js-component-viewer-loading-after"> - <i className="spinner"/> + <i className="spinner" /> <span className="note spacer-left"> {translate('source_viewer.loading_more_code')} </span> </div> : <button className="js-component-viewer-source-after" - onClick={this.props.loadSourcesAfter}> + onClick={this.props.loadSourcesAfter} + > {translate('source_viewer.load_more_code')} </button>} </div>} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.js index af05c46d954..97ccf3a15bf 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.js @@ -67,7 +67,7 @@ export default class SourceViewerHeader extends React.PureComponent { Workspace.openComponent({ key }); }; - render () { + render() { const { key, measures, @@ -90,25 +90,25 @@ export default class SourceViewerHeader extends React.PureComponent { <div className="component-name"> <div className="component-name-parent"> <Link to={getProjectUrl(project)} className="link-with-icon"> - <QualifierIcon qualifier="TRK"/> <span>{projectName}</span> + <QualifierIcon qualifier="TRK" /> <span>{projectName}</span> </Link> </div> {subProject != null && <div className="component-name-parent"> <Link to={getProjectUrl(subProject)} className="link-with-icon"> - <QualifierIcon qualifier="BRC"/> <span>{subProjectName}</span> + <QualifierIcon qualifier="BRC" /> <span>{subProjectName}</span> </Link> </div>} <div className="component-name-path"> - <QualifierIcon qualifier={q}/> + <QualifierIcon qualifier={q} /> {' '} <span>{collapsedDirFromPath(path)}</span> <span className="component-name-file">{fileFromPath(path)}</span> {this.props.component.canMarkAsFavorite && - <FavoriteContainer className="component-name-favorite" componentKey={key}/>} + <FavoriteContainer className="component-name-favorite" componentKey={key} />} </div> </div> </div> @@ -117,7 +117,8 @@ export default class SourceViewerHeader extends React.PureComponent { <a className="js-actions icon-list dropdown-toggle" data-toggle="dropdown" - title={translate('component_viewer.more_actions')}/> + title={translate('component_viewer.more_actions')} + /> <ul className="dropdown-menu dropdown-menu-right"> <li> <a className="js-measures" href="#" onClick={this.showMeasures}> @@ -169,10 +170,11 @@ export default class SourceViewerHeader extends React.PureComponent { <Link to={getIssuesUrl({ resolved: 'false', componentKeys: key })} className="source-viewer-header-external-link" - target="_blank"> + target="_blank" + > {measures.issues != null ? formatMeasure(measures.issues, 'SHORT_INT') : 0} {' '} - <i className="icon-detach"/> + <i className="icon-detach" /> </Link> </span> <span className="source-viewer-header-measure-label"> diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerIssueLocations.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerIssueLocations.js index abe72568770..acd8abb398b 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerIssueLocations.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerIssueLocations.js @@ -49,24 +49,24 @@ export default class SourceViewerIssueLocations extends React.Component { rootNode: HTMLElement; state: State; - constructor (props: Props) { + constructor(props: Props) { super(props); this.state = { fixed: true, locationBlink: false }; this.handleScroll = throttle(this.handleScroll, 50); } - componentDidMount () { + componentDidMount() { this.bindShortcuts(); this.listenScroll(); } - componentWillReceiveProps (nextProps: Props) { + componentWillReceiveProps(nextProps: Props) { if (nextProps.selectedLocation !== this.props.selectedLocation) { this.setState({ locationBlink: false }); } } - componentDidUpdate (prevProps: Props) { + componentDidUpdate(prevProps: Props) { if ( prevProps.selectedLocation !== this.props.selectedLocation && this.props.selectedLocation != null @@ -75,24 +75,24 @@ export default class SourceViewerIssueLocations extends React.Component { } } - componentWillUnmount () { + componentWillUnmount() { this.unbindShortcuts(); this.unlistenScroll(); } - bindShortcuts () { + bindShortcuts() { document.addEventListener('keydown', this.handleKeyPress); } - unbindShortcuts () { + unbindShortcuts() { document.removeEventListener('keydown', this.handleKeyPress); } - listenScroll () { + listenScroll() { window.addEventListener('scroll', this.handleScroll); } - unlistenScroll () { + unlistenScroll() { window.removeEventListener('scroll', this.handleScroll); } @@ -128,7 +128,7 @@ export default class SourceViewerIssueLocations extends React.Component { this.props.onResize(height); }; - scrollToLocation () { + scrollToLocation() { const { selectedLocation } = this.props; if (selectedLocation != null) { const key = `${selectedLocation.flowIndex}-${selectedLocation.locationIndex}`; @@ -139,7 +139,7 @@ export default class SourceViewerIssueLocations extends React.Component { } } - handleSelectPrev () { + handleSelectPrev() { const { issue, selectedLocation } = this.props; if (!selectedLocation) { if (issue.flows.length > 0) { @@ -163,7 +163,7 @@ export default class SourceViewerIssueLocations extends React.Component { } } - handleSelectNext () { + handleSelectNext() { const { issue, selectedLocation } = this.props; if (!selectedLocation) { if (issue.flows.length > 0) { @@ -207,11 +207,11 @@ export default class SourceViewerIssueLocations extends React.Component { } }; - reverseLocations (locations: Array<*>) { + reverseLocations(locations: Array<*>) { return [...locations].reverse(); } - isLocationSelected (flowIndex: number, locationIndex: number) { + isLocationSelected(flowIndex: number, locationIndex: number) { const { selectedLocation } = this.props; if (selectedLocation == null) { return false; @@ -221,7 +221,7 @@ export default class SourceViewerIssueLocations extends React.Component { } } - handleLocationClick (flowIndex: number, locationIndex: number, e: SyntheticInputEvent) { + handleLocationClick(flowIndex: number, locationIndex: number, e: SyntheticInputEvent) { e.preventDefault(); this.props.onSelectLocation(flowIndex, locationIndex); } @@ -251,7 +251,8 @@ export default class SourceViewerIssueLocations extends React.Component { this, flowIndex, locations.length - locationIndex - 1 - )}> + )} + > {displayIndex && <strong>{locationIndex + 1}: </strong>} {location.msg} </a> @@ -259,7 +260,7 @@ export default class SourceViewerIssueLocations extends React.Component { ); }; - render () { + render() { const { flows } = this.props.issue; const { height } = this.props; @@ -271,12 +272,14 @@ export default class SourceViewerIssueLocations extends React.Component { <div ref={node => this.rootNode = node} className="source-issue-locations" - style={{ width, height }}> + style={{ width, height }} + > <div ref={node => this.fixedNode = node} className={className} - style={{ width, height }}> - <header className="source-issue-locations-header"/> + style={{ width, height }} + > + <header className="source-issue-locations-header" /> <div className="source-issue-locations-shortcuts"> <span className="shortcut-button">Alt</span> {' + '} @@ -289,18 +292,17 @@ export default class SourceViewerIssueLocations extends React.Component { <ul ref={node => this.node = node} className="source-issue-locations-list" - style={{ height: height - 15 }}> + style={{ height: height - 15 }} + > {flows.map( (flow, flowIndex) => flow.locations != null && - this.reverseLocations( - flow.locations - ).map((location, locationIndex) => + this.reverseLocations(flow.locations).map((location, locationIndex) => this.renderLocation(location, flowIndex, locationIndex, flow.locations || [])) )} </ul> <DraggableCore axis="y" onDrag={this.handleDrag} offsetParent={document.body}> - <div className="workspace-viewer-resize"/> + <div className="workspace-viewer-resize" /> </DraggableCore> </div> </div> diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js index c9da31d1cf8..9303cfa53c2 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js @@ -87,7 +87,7 @@ export default class Line extends React.PureComponent { } }; - render () { + render() { const { line, duplications, duplicationsCount, filtered } = this.props; const className = classNames('source-line', { 'source-line-highlighted': this.props.highlighted, @@ -98,18 +98,19 @@ export default class Line extends React.PureComponent { return ( <TooltipsContainer> <tr className={className} data-line-number={line.line}> - <LineNumber line={line} onClick={this.props.onClick}/> + <LineNumber line={line} onClick={this.props.onClick} /> <LineSCM line={line} onClick={this.props.onSCMClick} - previousLine={this.props.previousLine}/> + previousLine={this.props.previousLine} + /> {this.props.displayCoverage && - <LineCoverage line={line} onClick={this.props.onCoverageClick}/>} + <LineCoverage line={line} onClick={this.props.onCoverageClick} />} {this.props.displayDuplications && - <LineDuplications line={line} onClick={this.props.loadDuplications}/>} + <LineDuplications line={line} onClick={this.props.loadDuplications} />} {times(duplicationsCount).map(index => ( <LineDuplicationBlock @@ -117,7 +118,8 @@ export default class Line extends React.PureComponent { index={index} key={index} line={this.props.line} - onClick={this.props.onDuplicationClick}/> + onClick={this.props.onDuplicationClick} + /> ))} {this.props.displayIssues && @@ -125,11 +127,12 @@ export default class Line extends React.PureComponent { <LineIssuesIndicatorContainer issueKeys={this.props.issues} line={line} - onClick={this.handleIssuesIndicatorClick}/>} + onClick={this.handleIssuesIndicatorClick} + />} {this.props.displayFiltered && <td className="source-meta source-line-filtered-container" data-line-number={line.line}> - <div className="source-line-bar"/> + <div className="source-line-bar" /> </td>} <LineCode @@ -144,7 +147,8 @@ export default class Line extends React.PureComponent { secondaryIssueLocations={this.props.secondaryIssueLocations} selectedIssue={this.props.selectedIssue} selectedIssueLocation={this.props.selectedIssueLocation} - showIssues={this.props.openIssues || this.props.displayAllIssues}/> + showIssues={this.props.openIssues || this.props.displayAllIssues} + /> </tr> </TooltipsContainer> ); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js index 840623fed9f..f6cbb5f1446 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js @@ -61,18 +61,18 @@ export default class LineCode extends React.PureComponent { state: State; symbols: NodeList<HTMLElement>; - constructor (props: Props) { + constructor(props: Props) { super(props); this.state = { tokens: splitByTokens(props.line.code || '') }; } - componentDidMount () { + componentDidMount() { this.attachEvents(); } - componentWillReceiveProps (nextProps: Props) { + componentWillReceiveProps(nextProps: Props) { if (nextProps.line.code !== this.props.line.code) { this.setState({ tokens: splitByTokens(nextProps.line.code || '') @@ -80,26 +80,26 @@ export default class LineCode extends React.PureComponent { } } - componentWillUpdate () { + componentWillUpdate() { this.detachEvents(); } - componentDidUpdate () { + componentDidUpdate() { this.attachEvents(); } - componentWillUnmount () { + componentWillUnmount() { this.detachEvents(); } - attachEvents () { + attachEvents() { this.symbols = this.codeNode.querySelectorAll('.sym'); for (const symbol of this.symbols) { symbol.addEventListener('click', this.handleSymbolClick); } } - detachEvents () { + detachEvents() { if (this.symbols) { for (const symbol of this.symbols) { symbol.removeEventListener('click', this.handleSymbolClick); @@ -124,7 +124,7 @@ export default class LineCode extends React.PureComponent { this.props.onLocationSelect(flowIndex, locationIndex); }; - isSecondaryIssueLocationSelected (location: IndexedIssueLocation | IndexedIssueLocationMessage) { + isSecondaryIssueLocationSelected(location: IndexedIssueLocation | IndexedIssueLocationMessage) { const { selectedIssueLocation } = this.props; if (selectedIssueLocation == null) { return false; @@ -148,14 +148,15 @@ export default class LineCode extends React.PureComponent { className={className} title={location.msg} onClick={e => - this.handleLocationMessageClick(e, location.flowIndex, location.locationIndex)}> + this.handleLocationMessageClick(e, location.flowIndex, location.locationIndex)} + > {location.index && <strong>{location.index}: </strong>} {location.msg ? limitString(location.msg) : ''} </a> ); }; - renderSecondaryIssueLocationMessages (locations: Array<IndexedIssueLocationMessage>) { + renderSecondaryIssueLocationMessages(locations: Array<IndexedIssueLocationMessage>) { return ( <div className="source-line-issue-locations"> {locations.map(this.renderSecondaryIssueLocationMessage)} @@ -163,7 +164,7 @@ export default class LineCode extends React.PureComponent { ); } - render () { + render() { const { highlightedSymbol, issueKeys, @@ -207,7 +208,7 @@ export default class LineCode extends React.PureComponent { return ( <td className={className} data-line-number={line.line}> <div className="source-line-code-inner"> - <pre ref={node => this.codeNode = node} dangerouslySetInnerHTML={{ __html: finalCode }}/> + <pre ref={node => this.codeNode = node} dangerouslySetInnerHTML={{ __html: finalCode }} /> {secondaryIssueLocationMessages != null && secondaryIssueLocationMessages.length > 0 && this.renderSecondaryIssueLocationMessages(secondaryIssueLocationMessages)} @@ -217,7 +218,8 @@ export default class LineCode extends React.PureComponent { <LineIssuesList issueKeys={issueKeys} onIssueClick={onIssueSelect} - selectedIssue={selectedIssue}/>} + selectedIssue={selectedIssue} + />} </td> ); } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.js index 55e7aad96cd..76b8502548b 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.js @@ -35,7 +35,7 @@ export default class LineCoverage extends React.PureComponent { this.props.onClick(this.props.line, e.target); }; - render () { + render() { const { line } = this.props; const className = 'source-meta source-line-coverage' + (line.coverageStatus != null ? ` source-line-${line.coverageStatus}` : ''); @@ -51,8 +51,9 @@ export default class LineCoverage extends React.PureComponent { data-toggle={line.coverageStatus != null ? 'tooltip' : undefined} role={line.coverageStatus != null ? 'button' : undefined} tabIndex={line.coverageStatus != null ? 0 : undefined} - onClick={line.coverageStatus != null ? this.handleClick : undefined}> - <div className="source-line-bar"/> + onClick={line.coverageStatus != null ? this.handleClick : undefined} + > + <div className="source-line-bar" /> </td> ); } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.js index 021be8e1e7c..bfe7029f601 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.js @@ -38,7 +38,7 @@ export default class LineDuplicationBlock extends React.PureComponent { this.props.onClick(this.props.index, this.props.line.line); }; - render () { + render() { const { duplicated, index, line } = this.props; const className = classNames('source-meta', 'source-line-duplications-extra', { 'source-line-duplicated': duplicated @@ -55,8 +55,9 @@ export default class LineDuplicationBlock extends React.PureComponent { data-toggle={duplicated ? 'tooltip' : undefined} role={duplicated ? 'button' : undefined} tabIndex={duplicated ? '0' : undefined} - onClick={duplicated ? this.handleClick : undefined}> - <div className="source-line-bar"/> + onClick={duplicated ? this.handleClick : undefined} + > + <div className="source-line-bar" /> </td> ); } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplications.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplications.js index 941227de0dc..5828a48ff60 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplications.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplications.js @@ -36,7 +36,7 @@ export default class LineDuplications extends React.PureComponent { this.props.onClick(this.props.line, e.target); }; - render () { + render() { const { line } = this.props; const className = classNames('source-meta', 'source-line-duplications', { 'source-line-duplicated': line.duplicated @@ -51,8 +51,9 @@ export default class LineDuplications extends React.PureComponent { data-toggle={line.duplicated ? 'tooltip' : undefined} role={line.duplicated ? 'button' : undefined} tabIndex={line.duplicated ? 0 : undefined} - onClick={line.duplicated ? this.handleClick : undefined}> - <div className="source-line-bar"/> + onClick={line.duplicated ? this.handleClick : undefined} + > + <div className="source-line-bar" /> </td> ); } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.js index 200174283cc..9e8f3eec05d 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.js @@ -38,7 +38,7 @@ export default class LineIssuesIndicator extends React.PureComponent { this.props.onClick(); }; - render () { + render() { const { issues, line } = this.props; const hasIssues = issues.length > 0; const className = classNames('source-meta', 'source-line-issues', { @@ -52,8 +52,9 @@ export default class LineIssuesIndicator extends React.PureComponent { data-line-number={line.line} role={hasIssues ? 'button' : undefined} tabIndex={hasIssues ? '0' : undefined} - onClick={hasIssues ? this.handleClick : undefined}> - {mostImportantIssue != null && <SeverityIcon severity={mostImportantIssue.severity}/>} + onClick={hasIssues ? this.handleClick : undefined} + > + {mostImportantIssue != null && <SeverityIcon severity={mostImportantIssue.severity} />} {issues.length > 1 && <span className="source-line-issues-counter">{issues.length}</span>} </td> ); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js index 0238b021891..ca89ab51fae 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js @@ -30,7 +30,7 @@ type Props = { export default class LineIssuesList extends React.PureComponent { props: Props; - render () { + render() { const { issueKeys, onIssueClick, selectedIssue } = this.props; return ( @@ -40,7 +40,8 @@ export default class LineIssuesList extends React.PureComponent { issueKey={issueKey} key={issueKey} onClick={onIssueClick} - selected={selectedIssue === issueKey}/> + selected={selectedIssue === issueKey} + /> ))} </div> ); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineNumber.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineNumber.js index a477bfbad6b..6222d6335c1 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineNumber.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineNumber.js @@ -34,7 +34,7 @@ export default class LineNumber extends React.PureComponent { this.props.onClick(this.props.line, e.target); }; - render () { + render() { const { line } = this.props.line; return ( @@ -44,7 +44,8 @@ export default class LineNumber extends React.PureComponent { data-line-number={line ? line : undefined} role={line ? 'button' : undefined} tabIndex={line ? 0 : undefined} - onClick={line ? this.handleClick : undefined}/> + onClick={line ? this.handleClick : undefined} + /> ); } } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.js index b856b23bb53..2613f1756a5 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.js @@ -35,7 +35,7 @@ export default class LineSCM extends React.PureComponent { this.props.onClick(this.props.line, e.target); }; - isSCMChanged (s: SourceLine, p?: SourceLine) { + isSCMChanged(s: SourceLine, p?: SourceLine) { let changed = true; if (p != null && s.scmAuthor != null && p.scmAuthor != null) { changed = s.scmAuthor !== p.scmAuthor || s.scmDate !== p.scmDate; @@ -43,7 +43,7 @@ export default class LineSCM extends React.PureComponent { return changed; } - render () { + render() { const { line, previousLine } = this.props; const clickable = !!line.line; return ( @@ -52,9 +52,10 @@ export default class LineSCM extends React.PureComponent { data-line-number={line.line} role={clickable ? 'button' : undefined} tabIndex={clickable ? 0 : undefined} - onClick={clickable ? this.handleClick : undefined}> + onClick={clickable ? this.handleClick : undefined} + > {this.isSCMChanged(line, previousLine) && - <div className="source-line-scm-inner" data-author={line.scmAuthor}/>} + <div className="source-line-scm-inner" data-author={line.scmAuthor} />} </td> ); } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.js b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.js index c174394c33e..fa78dfa5afb 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.js @@ -44,7 +44,8 @@ it('render code', () => { secondaryIssueLocationMessages={secondaryIssueLocationMessages} selectedIssue="issue-1" selectedIssueLocation={selectedIssueLocation} - showIssues={true}/> + showIssues={true} + /> ); expect(wrapper).toMatchSnapshot(); }); @@ -71,7 +72,8 @@ it('should handle empty location message', () => { secondaryIssueLocationMessages={secondaryIssueLocationMessages} selectedIssue="issue-1" selectedIssueLocation={selectedIssueLocation} - showIssues={true}/> + showIssues={true} + /> ); expect(wrapper.find('.source-line-issue-locations')).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCoverage-test.js b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCoverage-test.js index 5dcee39a040..aacd16d7866 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCoverage-test.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCoverage-test.js @@ -25,7 +25,7 @@ import LineCoverage from '../LineCoverage'; it('render covered line', () => { const line = { line: 3, coverageStatus: 'covered' }; const onClick = jest.fn(); - const wrapper = shallow(<LineCoverage line={line} onClick={onClick}/>); + const wrapper = shallow(<LineCoverage line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); click(wrapper); expect(onClick).toHaveBeenCalled(); @@ -34,7 +34,7 @@ it('render covered line', () => { it('render uncovered line', () => { const line = { line: 3, coverageStatus: 'uncovered' }; const onClick = jest.fn(); - const wrapper = shallow(<LineCoverage line={line} onClick={onClick}/>); + const wrapper = shallow(<LineCoverage line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); click(wrapper); expect(onClick).toHaveBeenCalled(); @@ -43,6 +43,6 @@ it('render uncovered line', () => { it('render line with unknown coverage', () => { const line = { line: 3 }; const onClick = jest.fn(); - const wrapper = shallow(<LineCoverage line={line} onClick={onClick}/>); + const wrapper = shallow(<LineCoverage line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineDuplicationBlock-test.js b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineDuplicationBlock-test.js index e16dd8b6c0b..cd0baf595d0 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineDuplicationBlock-test.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineDuplicationBlock-test.js @@ -26,7 +26,7 @@ it('render duplicated line', () => { const line = { line: 3, duplicated: true }; const onClick = jest.fn(); const wrapper = shallow( - <LineDuplicationBlock index={1} duplicated={true} line={line} onClick={onClick}/> + <LineDuplicationBlock index={1} duplicated={true} line={line} onClick={onClick} /> ); expect(wrapper).toMatchSnapshot(); click(wrapper); @@ -37,7 +37,7 @@ it('render not duplicated line', () => { const line = { line: 3, duplicated: false }; const onClick = jest.fn(); const wrapper = shallow( - <LineDuplicationBlock index={1} duplicated={false} line={line} onClick={onClick}/> + <LineDuplicationBlock index={1} duplicated={false} line={line} onClick={onClick} /> ); expect(wrapper).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineDuplications-test.js b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineDuplications-test.js index 1f11c8b9e37..b2aa124a64a 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineDuplications-test.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineDuplications-test.js @@ -25,7 +25,7 @@ import LineDuplications from '../LineDuplications'; it('render duplicated line', () => { const line = { line: 3, duplicated: true }; const onClick = jest.fn(); - const wrapper = shallow(<LineDuplications line={line} onClick={onClick}/>); + const wrapper = shallow(<LineDuplications line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); click(wrapper); expect(onClick).toHaveBeenCalled(); @@ -34,6 +34,6 @@ it('render duplicated line', () => { it('render not duplicated line', () => { const line = { line: 3, duplicated: false }; const onClick = jest.fn(); - const wrapper = shallow(<LineDuplications line={line} onClick={onClick}/>); + const wrapper = shallow(<LineDuplications line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesIndicator-test.js b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesIndicator-test.js index c2bb88ec66b..65ec7a2fcc6 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesIndicator-test.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesIndicator-test.js @@ -26,7 +26,7 @@ it('render highest severity', () => { const line = { line: 3 }; const issues = [{ severity: 'MINOR' }, { severity: 'CRITICAL' }]; const onClick = jest.fn(); - const wrapper = shallow(<LineIssuesIndicator issues={issues} line={line} onClick={onClick}/>); + const wrapper = shallow(<LineIssuesIndicator issues={issues} line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); click(wrapper); @@ -41,6 +41,6 @@ it('no issues', () => { const line = { line: 3 }; const issues = []; const onClick = jest.fn(); - const wrapper = shallow(<LineIssuesIndicator issues={issues} line={line} onClick={onClick}/>); + const wrapper = shallow(<LineIssuesIndicator issues={issues} line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesList-test.js b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesList-test.js index 8f60222fb55..ede9d50241c 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesList-test.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesList-test.js @@ -30,7 +30,8 @@ it('render issues list', () => { issueKeys={issueKeys} line={line} onIssueClick={onIssueClick} - selectedIssue="foo"/> + selectedIssue="foo" + /> ); expect(wrapper).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineNumber-test.js b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineNumber-test.js index eb120a25a06..e63328623da 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineNumber-test.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineNumber-test.js @@ -25,7 +25,7 @@ import LineNumber from '../LineNumber'; it('render line 3', () => { const line = { line: 3 }; const onClick = jest.fn(); - const wrapper = shallow(<LineNumber line={line} onClick={onClick}/>); + const wrapper = shallow(<LineNumber line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); click(wrapper); expect(onClick).toHaveBeenCalled(); @@ -34,6 +34,6 @@ it('render line 3', () => { it('render line 0', () => { const line = { line: 0 }; const onClick = jest.fn(); - const wrapper = shallow(<LineNumber line={line} onClick={onClick}/>); + const wrapper = shallow(<LineNumber line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.js b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.js index f1a812d302a..c8d17120169 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.js @@ -26,7 +26,7 @@ it('render scm details', () => { const line = { line: 3, scmAuthor: 'foo', scmDate: '2017-01-01' }; const previousLine = { line: 2, scmAuthor: 'bar', scmDate: '2017-01-02' }; const onClick = jest.fn(); - const wrapper = shallow(<LineSCM line={line} onClick={onClick} previousLine={previousLine}/>); + const wrapper = shallow(<LineSCM line={line} onClick={onClick} previousLine={previousLine} />); expect(wrapper).toMatchSnapshot(); click(wrapper); expect(onClick).toHaveBeenCalled(); @@ -35,7 +35,7 @@ it('render scm details', () => { it('render scm details for the first line', () => { const line = { line: 3, scmAuthor: 'foo', scmDate: '2017-01-01' }; const onClick = jest.fn(); - const wrapper = shallow(<LineSCM line={line} onClick={onClick}/>); + const wrapper = shallow(<LineSCM line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); }); @@ -43,13 +43,13 @@ it('does not render scm details', () => { const line = { line: 3, scmAuthor: 'foo', scmDate: '2017-01-01' }; const previousLine = { line: 2, scmAuthor: 'foo', scmDate: '2017-01-01' }; const onClick = jest.fn(); - const wrapper = shallow(<LineSCM line={line} onClick={onClick} previousLine={previousLine}/>); + const wrapper = shallow(<LineSCM line={line} onClick={onClick} previousLine={previousLine} />); expect(wrapper).toMatchSnapshot(); }); it('does not allow to click', () => { const line = { scmAuthor: 'foo', scmDate: '2017-01-01' }; const onClick = jest.fn(); - const wrapper = shallow(<LineSCM line={line} onClick={onClick}/>); + const wrapper = shallow(<LineSCM line={line} onClick={onClick} />); expect(wrapper).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.js b/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.js index c448c519b56..c742f2b0d4c 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.js @@ -118,6 +118,6 @@ export const highlightIssueLocations = ( export const generateHTML = (tokens: Tokens): string => { return tokens - .map(token => `<span class="${token.className}">${escapeHtml(token.text)}</span>`) - .join(''); + .map(token => `<span class="${token.className}">${escapeHtml(token.text)}</span>`) + .join(''); }; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/popups/coverage-popup.js b/server/sonar-web/src/main/js/components/SourceViewer/popups/coverage-popup.js index 145d5dbeb47..e8dd4f0f23c 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/popups/coverage-popup.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/popups/coverage-popup.js @@ -29,19 +29,19 @@ export default Popup.extend({ 'click a[data-key]': 'goToFile' }, - onRender () { + onRender() { Popup.prototype.onRender.apply(this, arguments); this.$('.bubble-popup-container').isolatedScroll(); }, - goToFile (e) { + goToFile(e) { e.stopPropagation(); const key = $(e.currentTarget).data('key'); const Workspace = require('../../workspace/main').default; Workspace.openComponent({ key }); }, - serializeData () { + serializeData() { const row = this.options.line || {}; const tests = groupBy(this.options.tests, 'fileKey'); const testFiles = Object.keys(tests).map(fileKey => { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/popups/duplication-popup.js b/server/sonar-web/src/main/js/components/SourceViewer/popups/duplication-popup.js index d8ef03e1009..3ca962bca6c 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/popups/duplication-popup.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/popups/duplication-popup.js @@ -30,7 +30,7 @@ export default Popup.extend({ 'click a[data-key]': 'goToFile' }, - goToFile (e) { + goToFile(e) { e.stopPropagation(); const key = $(e.currentTarget).data('key'); const line = $(e.currentTarget).data('line'); @@ -38,7 +38,7 @@ export default Popup.extend({ Workspace.openComponent({ key, line }); }, - serializeData () { + serializeData() { const that = this; const groupedBlocks = groupBy(this.options.blocks, '_ref'); let duplications = Object.keys(groupedBlocks).map(fileRef => { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/popups/line-actions-popup.js b/server/sonar-web/src/main/js/components/SourceViewer/popups/line-actions-popup.js index e65d748e0d1..a191971e936 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/popups/line-actions-popup.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/popups/line-actions-popup.js @@ -27,7 +27,7 @@ export default Popup.extend({ 'click .js-get-permalink': 'getPermalink' }, - getPermalink (e) { + getPermalink(e) { e.preventDefault(); const { component, line } = this.options; const url = `${window.baseUrl}/component/index?id=${encodeURIComponent(component.key)}&line=${line}`; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/popups/scm-popup.js b/server/sonar-web/src/main/js/components/SourceViewer/popups/scm-popup.js index 06cbf45e182..04524f9ce9d 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/popups/scm-popup.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/popups/scm-popup.js @@ -24,19 +24,19 @@ export default Popup.extend({ template: Template, events: { - 'click': 'onClick' + click: 'onClick' }, - onRender () { + onRender() { Popup.prototype.onRender.apply(this, arguments); this.$('.bubble-popup-container').isolatedScroll(); }, - onClick (e) { + onClick(e) { e.stopPropagation(); }, - serializeData () { + serializeData() { return { ...Popup.prototype.serializeData.apply(this, arguments), line: this.options.line diff --git a/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js b/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js index 6dee58b4c80..0ceca9b9952 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/views/measures-overlay.js @@ -31,7 +31,7 @@ export default ModalView.extend({ template: Template, testsOrder: ['ERROR', 'FAILURE', 'OK', 'SKIPPED'], - initialize () { + initialize() { this.testsScroll = 0; const requests = [this.requestMeasures(), this.requestIssues()]; if (this.options.component.q === 'UTS') { @@ -40,7 +40,7 @@ export default ModalView.extend({ Promise.all(requests).then(() => this.render()); }, - events () { + events() { return { ...ModalView.prototype.events.apply(this, arguments), 'click .js-sort-tests-by-duration': 'sortTestsByDuration', @@ -51,8 +51,8 @@ export default ModalView.extend({ }; }, - initPieChart () { - const trans = function (left, top) { + initPieChart() { + const trans = function(left, top) { return `translate(${left}, ${top})`; }; @@ -63,46 +63,32 @@ export default ModalView.extend({ baseColor: '#e6e6e6' }; - this.$('.js-pie-chart').each(function () { - const data = [ - $(this).data('value'), - $(this).data('max') - $(this).data('value') - ]; + this.$('.js-pie-chart').each(function() { + const data = [$(this).data('value'), $(this).data('max') - $(this).data('value')]; const options = { ...defaults, ...$(this).data() }; const radius = options.size / 2; const container = d3.select(this); - const svg = container.append('svg') - .attr('width', options.size) - .attr('height', options.size); - const plot = svg.append('g') - .attr('transform', trans(radius, radius)); - const arc = d3.svg.arc() - .innerRadius(radius - options.thickness) - .outerRadius(radius); - const pie = d3.layout.pie() - .sort(null) - .value(d => d); - const colors = function (i) { + const svg = container.append('svg').attr('width', options.size).attr('height', options.size); + const plot = svg.append('g').attr('transform', trans(radius, radius)); + const arc = d3.svg.arc().innerRadius(radius - options.thickness).outerRadius(radius); + const pie = d3.layout.pie().sort(null).value(d => d); + const colors = function(i) { return i === 0 ? options.color : options.baseColor; }; - const sectors = plot.selectAll('path') - .data(pie(data)); + const sectors = plot.selectAll('path').data(pie(data)); - sectors.enter() - .append('path') - .style('fill', (d, i) => colors(i)) - .attr('d', arc); + sectors.enter().append('path').style('fill', (d, i) => colors(i)).attr('d', arc); }); }, - onRender () { + onRender() { ModalView.prototype.onRender.apply(this, arguments); this.initPieChart(); this.$('.js-test-list').scrollTop(this.testsScroll); }, - getMetrics () { + getMetrics() { let metrics = ''; const url = window.baseUrl + '/api/metrics/search'; $.ajax({ @@ -116,11 +102,10 @@ export default ModalView.extend({ return metrics; }, - calcAdditionalMeasures (measures) { - measures.issuesRemediationEffort = - (Number(measures.sqale_index_raw) || 0) + - (Number(measures.reliability_remediation_effort_raw) || 0) + - (Number(measures.security_remediation_effort_raw) || 0); + calcAdditionalMeasures(measures) { + measures.issuesRemediationEffort = (Number(measures.sqale_index_raw) || 0) + + (Number(measures.reliability_remediation_effort_raw) || 0) + + (Number(measures.security_remediation_effort_raw) || 0); if (measures.lines_to_cover && measures.uncovered_lines) { measures.covered_lines = measures.lines_to_cover_raw - measures.uncovered_lines_raw; @@ -131,7 +116,7 @@ export default ModalView.extend({ return measures; }, - prepareMetrics (metrics) { + prepareMetrics(metrics) { metrics = metrics.filter(metric => metric.value != null); return sortBy( toPairs(groupBy(metrics, 'domain')).map(domain => { @@ -144,11 +129,11 @@ export default ModalView.extend({ ); }, - requestMeasures () { + requestMeasures() { return getMetrics().then(metrics => { const metricsToRequest = metrics - .filter(metric => metric.type !== 'DATA' && !metric.hidden) - .map(metric => metric.key); + .filter(metric => metric.type !== 'DATA' && !metric.hidden) + .map(metric => metric.key); return getMeasures(this.options.component.key, metricsToRequest).then(measures => { let nextMeasures = this.options.component.measures || {}; @@ -165,7 +150,7 @@ export default ModalView.extend({ }); }, - requestIssues () { + requestIssues() { return new Promise(resolve => { const url = window.baseUrl + '/api/issues/search'; const options = { @@ -181,7 +166,8 @@ export default ModalView.extend({ const sortedTypesFacet = sortBy(typesFacet, v => typesOrder.indexOf(v.val)); const severitiesFacet = data.facets.find(facet => facet.property === 'severities').values; - const sortedSeveritiesFacet = sortBy(severitiesFacet, facet => window.severityComparator(facet.val)); + const sortedSeveritiesFacet = sortBy(severitiesFacet, facet => + window.severityComparator(facet.val)); const tagsFacet = data.facets.find(facet => facet.property === 'tags').values; @@ -195,7 +181,7 @@ export default ModalView.extend({ }); }, - requestTests () { + requestTests() { return new Promise(resolve => { const url = window.baseUrl + '/api/tests/list'; const options = { testFileKey: this.options.component.key }; @@ -210,7 +196,7 @@ export default ModalView.extend({ }); }, - sortTests (condition) { + sortTests(condition) { let tests = this.tests; if (Array.isArray(tests)) { tests = sortBy(tests, condition); @@ -221,7 +207,7 @@ export default ModalView.extend({ } }, - sortTestsByDuration () { + sortTestsByDuration() { if (this.testSorting === 'duration') { this.testAsc = !this.testAsc; } @@ -230,7 +216,7 @@ export default ModalView.extend({ this.render(); }, - sortTestsByName () { + sortTestsByName() { if (this.testSorting === 'name') { this.testAsc = !this.testAsc; } @@ -239,7 +225,7 @@ export default ModalView.extend({ this.render(); }, - sortTestsByStatus () { + sortTestsByStatus() { if (this.testSorting === 'status') { this.testAsc = !this.testAsc; } @@ -248,7 +234,7 @@ export default ModalView.extend({ this.render(); }, - showTest (e) { + showTest(e) { const testId = $(e.currentTarget).data('id'); const url = window.baseUrl + '/api/tests/covered_files'; const options = { testId }; @@ -260,12 +246,12 @@ export default ModalView.extend({ }); }, - showAllMeasures () { + showAllMeasures() { this.$('.js-all-measures').removeClass('hidden'); this.$('.js-show-all-measures').remove(); }, - serializeData () { + serializeData() { return { ...ModalView.prototype.serializeData.apply(this, arguments), ...this.options.component, |