]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12110 Fix extra lines/snippets issue
authorJeremy Davis <jeremy.davis@sonarsource.com>
Fri, 17 May 2019 14:55:56 +0000 (16:55 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 23 May 2019 18:21:10 +0000 (20:21 +0200)
server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx
server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/CrossComponentSourceViewerWrapper-test.tsx.snap

index 0a0441159804191e001f617eb1e2b03fbc2f85c2..72f972d71d9bad55b79eb992539c84fe6c9b7f7f 100644 (file)
@@ -94,17 +94,8 @@ export default class ComponentSourceSnippetViewer extends React.PureComponent<Pr
   }
 
   createSnippetsFromProps() {
-    const mainLocation: T.FlowLocation = {
-      component: this.props.issue.component,
-      textRange: this.props.issue.textRange || {
-        endLine: 0,
-        endOffset: 0,
-        startLine: 0,
-        startOffset: 0
-      }
-    };
     const snippets = createSnippets(
-      this.props.snippetGroup.locations.concat(mainLocation),
+      this.props.snippetGroup.locations,
       this.props.snippetGroup.sources,
       this.props.last
     );
index 1aeb92a076dc3eaa3c05f8cb27b889928ecd1cbe..5f6913c5ace958df7c57e80824efb5e672e9426e 100644 (file)
@@ -16,46 +16,100 @@ exports[`should render correctly 1`] = `
 
 exports[`should render correctly 2`] = `
 <div>
-  <ComponentSourceSnippetViewer
-    issue={
+  <ContextProvider
+    key="1-0-0"
+    value={
       Object {
-        "actions": Array [],
-        "component": "main.js",
-        "componentLongName": "main.js",
-        "componentQualifier": "FIL",
-        "componentUuid": "foo1234",
-        "creationDate": "2017-03-01T09:36:01+0100",
-        "flows": Array [
-          Array [
-            Object {
-              "component": "main.js",
-              "textRange": Object {
-                "endLine": 2,
-                "endOffset": 2,
-                "startLine": 1,
-                "startOffset": 1,
+        "branchLike": undefined,
+        "file": Object {
+          "key": "main.js",
+          "measures": Object {
+            "coverage": "85.2",
+            "duplicationDensity": "1.0",
+            "issues": "12",
+            "lines": "56",
+          },
+          "path": "main.js",
+          "project": "my-project",
+          "projectName": "MyProject",
+          "q": "FIL",
+          "uuid": "foo-bar",
+        },
+      }
+    }
+  >
+    <ComponentSourceSnippetViewer
+      issue={
+        Object {
+          "actions": Array [],
+          "component": "main.js",
+          "componentLongName": "main.js",
+          "componentQualifier": "FIL",
+          "componentUuid": "foo1234",
+          "creationDate": "2017-03-01T09:36:01+0100",
+          "flows": Array [
+            Array [
+              Object {
+                "component": "main.js",
+                "textRange": Object {
+                  "endLine": 2,
+                  "endOffset": 2,
+                  "startLine": 1,
+                  "startOffset": 1,
+                },
               },
-            },
-            Object {
-              "component": "main.js",
-              "textRange": Object {
-                "endLine": 2,
-                "endOffset": 2,
-                "startLine": 1,
-                "startOffset": 1,
+              Object {
+                "component": "main.js",
+                "textRange": Object {
+                  "endLine": 2,
+                  "endOffset": 2,
+                  "startLine": 1,
+                  "startOffset": 1,
+                },
               },
-            },
-            Object {
-              "component": "main.js",
-              "textRange": Object {
-                "endLine": 2,
-                "endOffset": 2,
-                "startLine": 1,
-                "startOffset": 1,
+              Object {
+                "component": "main.js",
+                "textRange": Object {
+                  "endLine": 2,
+                  "endOffset": 2,
+                  "startLine": 1,
+                  "startOffset": 1,
+                },
               },
-            },
+            ],
+            Array [
+              Object {
+                "component": "main.js",
+                "textRange": Object {
+                  "endLine": 2,
+                  "endOffset": 2,
+                  "startLine": 1,
+                  "startOffset": 1,
+                },
+              },
+              Object {
+                "component": "main.js",
+                "textRange": Object {
+                  "endLine": 2,
+                  "endOffset": 2,
+                  "startLine": 1,
+                  "startOffset": 1,
+                },
+              },
+            ],
           ],
-          Array [
+          "fromHotspot": false,
+          "key": "1",
+          "line": 25,
+          "message": "Reduce the number of conditional operators (4) used in the expression",
+          "organization": "myorg",
+          "project": "myproject",
+          "projectKey": "foo",
+          "projectName": "Foo",
+          "projectOrganization": "org",
+          "rule": "javascript:S1067",
+          "ruleName": "foo",
+          "secondaryLocations": Array [
             Object {
               "component": "main.js",
               "textRange": Object {
@@ -75,30 +129,26 @@ exports[`should render correctly 2`] = `
               },
             },
           ],
-        ],
-        "fromHotspot": false,
-        "key": "1",
-        "line": 25,
-        "message": "Reduce the number of conditional operators (4) used in the expression",
-        "organization": "myorg",
-        "project": "myproject",
-        "projectKey": "foo",
-        "projectName": "Foo",
-        "projectOrganization": "org",
-        "rule": "javascript:S1067",
-        "ruleName": "foo",
-        "secondaryLocations": Array [
-          Object {
-            "component": "main.js",
-            "textRange": Object {
-              "endLine": 2,
-              "endOffset": 2,
-              "startLine": 1,
-              "startOffset": 1,
-            },
+          "severity": "MAJOR",
+          "status": "OPEN",
+          "textRange": Object {
+            "endLine": 26,
+            "endOffset": 15,
+            "startLine": 25,
+            "startOffset": 0,
           },
+          "transitions": Array [],
+          "type": "BUG",
+        }
+      }
+      issuesByLine={Object {}}
+      last={true}
+      loadDuplications={[Function]}
+      locations={
+        Array [
           Object {
             "component": "main.js",
+            "index": 0,
             "textRange": Object {
               "endLine": 2,
               "endOffset": 2,
@@ -106,86 +156,58 @@ exports[`should render correctly 2`] = `
               "startOffset": 1,
             },
           },
-        ],
-        "severity": "MAJOR",
-        "status": "OPEN",
-        "textRange": Object {
-          "endLine": 26,
-          "endOffset": 15,
-          "startLine": 25,
-          "startOffset": 0,
-        },
-        "transitions": Array [],
-        "type": "BUG",
+        ]
       }
-    }
-    issuesByLine={Object {}}
-    key="1-0-0"
-    last={true}
-    loadDuplications={[Function]}
-    locations={
-      Array [
+      onIssueChange={[MockFunction]}
+      onIssuePopupToggle={[Function]}
+      onLinePopupToggle={[Function]}
+      onLocationSelect={[MockFunction]}
+      renderDuplicationPopup={[Function]}
+      scroll={[MockFunction]}
+      snippetGroup={
         Object {
-          "component": "main.js",
-          "index": 0,
-          "textRange": Object {
-            "endLine": 2,
-            "endOffset": 2,
-            "startLine": 1,
-            "startOffset": 1,
-          },
-        },
-      ]
-    }
-    onIssueChange={[MockFunction]}
-    onIssuePopupToggle={[Function]}
-    onLinePopupToggle={[Function]}
-    onLocationSelect={[MockFunction]}
-    renderDuplicationPopup={[Function]}
-    scroll={[MockFunction]}
-    snippetGroup={
-      Object {
-        "component": Object {
-          "key": "main.js",
-          "measures": Object {
-            "coverage": "85.2",
-            "duplicationDensity": "1.0",
-            "issues": "12",
-            "lines": "56",
-          },
-          "path": "main.js",
-          "project": "my-project",
-          "projectName": "MyProject",
-          "q": "FIL",
-          "uuid": "foo-bar",
-        },
-        "locations": Array [
-          Object {
-            "component": "main.js",
-            "index": 0,
-            "textRange": Object {
-              "endLine": 2,
-              "endOffset": 2,
-              "startLine": 1,
-              "startOffset": 1,
+          "component": Object {
+            "key": "main.js",
+            "measures": Object {
+              "coverage": "85.2",
+              "duplicationDensity": "1.0",
+              "issues": "12",
+              "lines": "56",
             },
+            "path": "main.js",
+            "project": "my-project",
+            "projectName": "MyProject",
+            "q": "FIL",
+            "uuid": "foo-bar",
           },
-        ],
-        "sources": Object {
-          "16": Object {
-            "code": "<span class=\\"k\\">import</span> java.util.<span class=\\"sym-9 sym\\">ArrayList</span>;",
-            "coverageStatus": "covered",
-            "coveredConditions": 2,
-            "duplicated": false,
-            "isNew": true,
-            "line": 16,
-            "scmAuthor": "simon.brandhof@sonarsource.com",
-            "scmDate": "2018-12-11T10:48:39+0100",
-            "scmRevision": "80f564becc0c0a1c9abaa006eca83a4fd278c3f0",
+          "locations": Array [
+            Object {
+              "component": "main.js",
+              "index": 0,
+              "textRange": Object {
+                "endLine": 2,
+                "endOffset": 2,
+                "startLine": 1,
+                "startOffset": 1,
+              },
+            },
+          ],
+          "sources": Object {
+            "16": Object {
+              "code": "<span class=\\"k\\">import</span> java.util.<span class=\\"sym-9 sym\\">ArrayList</span>;",
+              "coverageStatus": "covered",
+              "coveredConditions": 2,
+              "duplicated": false,
+              "isNew": true,
+              "line": 16,
+              "scmAuthor": "simon.brandhof@sonarsource.com",
+              "scmDate": "2018-12-11T10:48:39+0100",
+              "scmRevision": "80f564becc0c0a1c9abaa006eca83a4fd278c3f0",
+            },
           },
-        },
+        }
       }
-    }
-  />
+    />
+  </ContextProvider>
 </div>
 `;