aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components
diff options
context:
space:
mode:
authorStas Vilchik <stas-vilchik@users.noreply.github.com>2017-05-11 10:04:50 +0200
committerGitHub <noreply@github.com>2017-05-11 10:04:50 +0200
commit1633511736e086e20e303dae82136f4506646ed4 (patch)
treea5bfe0003ee75f0e6a73931125aba0de217d4a63 /server/sonar-web/src/main/js/components
parent133d5af9c0d39429334a140b9ead77bda2b4fe98 (diff)
downloadsonarqube-1633511736e086e20e303dae82136f4506646ed4.tar.gz
sonarqube-1633511736e086e20e303dae82136f4506646ed4.zip
SONAR-9174 Display issue box on the last line of its primary location (#2047)
Diffstat (limited to 'server/sonar-web/src/main/js/components')
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js2
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.js2
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js5
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js4
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js8
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap24
-rw-r--r--server/sonar-web/src/main/js/components/issue/types.js2
7 files changed, 37 insertions, 10 deletions
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 59a21aa332d..69af047648c 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
@@ -189,7 +189,7 @@ export default class SourceViewerCode extends React.PureComponent {
const displayFiltered = this.props.filterLine != null;
const hasIssues = this.props.issues.length > 0;
- const hasFileIssues = hasIssues && this.props.issues.some(issue => !issue.line);
+ const hasFileIssues = hasIssues && this.props.issues.some(issue => !issue.textRange);
return (
<div>
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<Issue>) => {
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}
/>
</li>
- {issue.line != null &&
+ {issue.textRange != null &&
<li className="issue-meta">
<span className="issue-meta-label" title={translate('line_number')}>
- L{issue.line}
+ L{issue.textRange.endLine}
</span>
</li>}
{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<string>,
- textRange: TextRange,
+ textRange?: TextRange,
transitions?: Array<string>,
type: string
};