]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9686 Secondary locations without messages should not be numbered
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 12 Oct 2017 09:50:43 +0000 (11:50 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 16 Oct 2017 09:08:02 +0000 (11:08 +0200)
server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js
server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocationsNavigator.js
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
server/sonar-web/src/main/js/components/SourceViewer/components/Line.js
server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js

index 9e00d1e57f7f7615bea8007fdee5c651790a39a1..1ee76bad894d5864ad7971e2ac6b937282baca06 100644 (file)
@@ -101,6 +101,8 @@ export default class IssuesSourceViewer extends React.PureComponent {
     // otherwise show code around the open issue
     const aroundLine = locationLine || (openIssue.textRange && openIssue.textRange.endLine);
 
+    const allMessagesEmpty = locations != null && locations.every(location => !location.msg);
+
     return (
       <div ref={node => (this.node = node)}>
         <SourceViewer
@@ -110,6 +112,7 @@ export default class IssuesSourceViewer extends React.PureComponent {
           displayAllIssues={true}
           displayIssueLocationsCount={false}
           displayIssueLocationsLink={false}
+          displayLocationMarkers={!allMessagesEmpty}
           highlightedLocations={locations}
           highlightedLocationMessage={locationMessage}
           loadIssues={this.props.loadIssues}
index ce9285318c84da06cf003f239136bb4cd8dd7268..6be26e9191a1d84c2af9e4bc898112fb94b823da 100644 (file)
@@ -49,7 +49,7 @@ export default class ConciseIssueLocationsNavigator extends React.PureComponent
         ? flows[selectedFlowIndex]
         : flows.length > 0 ? flows[0] : secondaryLocations;
 
-    if (locations == null || locations.length === 0) {
+    if (locations == null || locations.length === 0 || locations.every(location => !location.msg)) {
       return null;
     }
 
index b65c2d51bc5b396c63eeb648c46901897c222679..76facdb40737482ab580e115f7400bfdad30ec15 100644 (file)
@@ -61,6 +61,7 @@ type Props = {
   displayAllIssues: boolean,
   displayIssueLocationsCount?: boolean;
   displayIssueLocationsLink?: boolean;
+  displayLocationMarkers?: boolean;
   highlightedLine?: number,
   highlightedLocations?: Array<FlowLocation>,
   highlightedLocationMessage?: { index: number, text: string },
@@ -145,6 +146,7 @@ export default class SourceViewerBase extends React.PureComponent {
     displayAllIssues: false,
     displayIssueLocationsCount: true,
     displayIssueLocationsLink: true,
+    displayLocationMarkers: true,
     loadComponent,
     loadIssues,
     loadSources
@@ -604,6 +606,7 @@ export default class SourceViewerBase extends React.PureComponent {
         displayAllIssues={this.props.displayAllIssues}
         displayIssueLocationsCount={this.props.displayIssueLocationsCount}
         displayIssueLocationsLink={this.props.displayIssueLocationsLink}
+        displayLocationMarkers={this.props.displayLocationMarkers}
         duplications={this.state.duplications}
         duplicationsByLine={this.state.duplicationsByLine}
         duplicatedFiles={this.state.duplicatedFiles}
index 0c1af3244b9bca360b1aef441490dcd38889bdc8..44934fde835aceb5557be08ede7dcdcaf5223f74 100644 (file)
@@ -41,6 +41,7 @@ export default class SourceViewerCode extends React.PureComponent {
     displayAllIssues: boolean,
     displayIssueLocationsCount?: boolean;
     displayIssueLocationsLink?: boolean;
+    displayLocationMarkers?: boolean;
     duplications?: Array<Duplication>,
     duplicationsByLine: { [number]: Array<number> },
     duplicatedFiles?: Array<{ key: string }>,
@@ -156,6 +157,7 @@ export default class SourceViewerCode extends React.PureComponent {
         displayIssues={displayIssues}
         displayIssueLocationsCount={this.props.displayIssueLocationsCount}
         displayIssueLocationsLink={this.props.displayIssueLocationsLink}
+        displayLocationMarkers={this.props.displayLocationMarkers}
         duplications={this.getDuplicationsForLine(line)}
         duplicationsCount={duplicationsCount}
         filtered={filtered}
index a5441d1e81468e6c89d1159ac8450ce32010e5bd..5da88260309536ed0717a0118d25b469e3970ade 100644 (file)
@@ -41,6 +41,7 @@ type Props = {|
   displayIssues: boolean,
   displayIssueLocationsCount?: boolean;
   displayIssueLocationsLink?: boolean;
+  displayLocationMarkers?: boolean;
   duplications: Array<number>,
   duplicationsCount: number,
   filtered: boolean | null,
@@ -148,6 +149,7 @@ export default class Line extends React.PureComponent {
           branch={this.props.branch}
           displayIssueLocationsCount={this.props.displayIssueLocationsCount}
           displayIssueLocationsLink={this.props.displayIssueLocationsLink}
+          displayLocationMarkers={this.props.displayLocationMarkers}
           highlightedLocationMessage={this.props.highlightedLocationMessage}
           highlightedSymbols={this.props.highlightedSymbols}
           issues={this.props.issues}
index 4cedfd753c46791839b37fb16e110e3340dc4674..f3aea8272c98f23956a3bd2e9e9d17aa2ef5a360 100644 (file)
@@ -34,6 +34,7 @@ type Props = {|
   branch?: string,
   displayIssueLocationsCount?: boolean,
   displayIssueLocationsLink?: boolean,
+  displayLocationMarkers?: boolean,
   highlightedLocationMessage?: { index: number, text: string },
   highlightedSymbols?: Array<string>,
   issues: Array<Issue>,
@@ -203,7 +204,7 @@ export default class LineCode extends React.PureComponent {
     let leadingMarker = false;
 
     tokens.forEach((token, index) => {
-      if (token.markers.length > 0) {
+      if (this.props.displayLocationMarkers && token.markers.length > 0) {
         token.markers.forEach(marker => {
           const message =
             highlightedLocationMessage != null && highlightedLocationMessage.index === marker