From: Stas Vilchik Date: Thu, 11 May 2017 08:04:50 +0000 (+0200) Subject: SONAR-9174 Display issue box on the last line of its primary location (#2047) X-Git-Tag: 6.4-RC1~51 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1633511736e086e20e303dae82136f4506646ed4;p=sonarqube.git SONAR-9174 Display issue box on the last line of its primary location (#2047) --- diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.js b/server/sonar-web/src/main/js/apps/issues/components/App.js index 4a9dca21d04..e56811d72c3 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.js +++ b/server/sonar-web/src/main/js/apps/issues/components/App.js @@ -453,7 +453,7 @@ export default class App extends React.PureComponent { if (lastIssue.component !== openIssue.component) { return true; } - return lastIssue.line != null && lastIssue.line > to; + return lastIssue.textRange != null && lastIssue.textRange.endLine > to; }; if (done(issues, paging)) { diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js index 062d8530e6d..8580fcff5b6 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js @@ -78,7 +78,7 @@ export default class IssuesSourceViewer extends React.PureComponent { return (
(this.node = node)}> 0; - const hasFileIssues = hasIssues && this.props.issues.some(issue => !issue.line); + const hasFileIssues = hasIssues && this.props.issues.some(issue => !issue.textRange); return (
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.js b/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.js index 0047ee41fef..eac2170df15 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.js @@ -46,7 +46,7 @@ export type IndexedIssueLocationMessage = { export const issuesByLine = (issues: Array) => { const index = {}; issues.forEach(issue => { - const line = issue.line || 0; + const line = issue.textRange ? issue.textRange.endLine : 0; if (!(line in index)) { index[line] = []; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js index 0e56ceab7b9..737b9acedda 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js @@ -62,7 +62,10 @@ export const loadPageAndNext = ( const lastIssue = issues[issues.length - 1]; - if ((lastIssue.line != null && lastIssue.line > toLine) || issues.length < pageSize) { + if ( + (lastIssue.textRange != null && lastIssue.textRange.endLine > toLine) || + issues.length < pageSize + ) { return issues; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js index 8621fce9439..6e0fe943f07 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js @@ -86,10 +86,10 @@ export default function IssueTitleBar(props: Props) { onFail={props.onFail} /> - {issue.line != null && + {issue.textRange != null &&
  • - L{issue.line} + L{issue.textRange.endLine}
  • } {locationsCount > 0 && diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js index f09d709908f..407b05eb189 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js @@ -22,7 +22,13 @@ import React from 'react'; import IssueTitleBar from '../IssueTitleBar'; const issue = { - line: 26, + line: 25, + textRange: { + startLine: 25, + endLine: 26, + startOffset: 0, + endOffset: 15 + }, creationDate: '2017-03-01T09:36:01+0100', organization: 'myorg', project: 'myproject', diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap index 2a7d3bdbcea..5d61fbfb7d2 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap @@ -30,12 +30,18 @@ exports[`should render the titlebar correctly 1`] = ` "creationDate": "2017-03-01T09:36:01+0100", "flows": Array [], "key": "AVsae-CQS-9G3txfbFN2", - "line": 26, + "line": 25, "message": "Reduce the number of conditional operators (4) used in the expression", "organization": "myorg", "project": "myproject", "rule": "javascript:S1067", "secondaryLocations": Array [], + "textRange": Object { + "endLine": 26, + "endOffset": 15, + "startLine": 25, + "startOffset": 0, + }, } } onFail={[Function]} @@ -111,12 +117,18 @@ exports[`should render the titlebar with the filter 1`] = ` "creationDate": "2017-03-01T09:36:01+0100", "flows": Array [], "key": "AVsae-CQS-9G3txfbFN2", - "line": 26, + "line": 25, "message": "Reduce the number of conditional operators (4) used in the expression", "organization": "myorg", "project": "myproject", "rule": "javascript:S1067", "secondaryLocations": Array [], + "textRange": Object { + "endLine": 26, + "endOffset": 15, + "startLine": 25, + "startOffset": 0, + }, } } onFail={[Function]} @@ -165,12 +177,18 @@ exports[`should render the titlebar with the filter 1`] = ` "creationDate": "2017-03-01T09:36:01+0100", "flows": Array [], "key": "AVsae-CQS-9G3txfbFN2", - "line": 26, + "line": 25, "message": "Reduce the number of conditional operators (4) used in the expression", "organization": "myorg", "project": "myproject", "rule": "javascript:S1067", "secondaryLocations": Array [], + "textRange": Object { + "endLine": 26, + "endOffset": 15, + "startLine": 25, + "startOffset": 0, + }, } } onFail={[Function]} diff --git a/server/sonar-web/src/main/js/components/issue/types.js b/server/sonar-web/src/main/js/components/issue/types.js index 45fb150ad30..8788dc4d206 100644 --- a/server/sonar-web/src/main/js/components/issue/types.js +++ b/server/sonar-web/src/main/js/components/issue/types.js @@ -77,7 +77,7 @@ export type Issue = { subProjectName?: string, subProjectUuid?: string, tags?: Array, - textRange: TextRange, + textRange?: TextRange, transitions?: Array, type: string };