Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for static and dynamic analyzer tools.
https://codechecker.readthedocs.io
Apache License 2.0
2.27k stars 383 forks source link

Proposal. Open a source file in it's original place (github, bitbucket etc) #2702

Open irishrover opened 4 years ago

irishrover commented 4 years ago

Is your feature request related to a problem? Please describe. The CodeChecker bug view mode doesn't show neither git blame info nor file history so it makes hard to report a bug for the code owner.

Describe the solution you would like Open an external site where the file with a CodeChecker bug originates from. For example to open GitHub or BitBucket etc with the given file and line number.

Here's an ugly and dirty sample for the Chromium sources. Site URL and line number templates can be taken from the CodeChecker config file.

diff --git a/web/server/www/scripts/codecheckerviewer/BugViewer.js b/web/server/www/scripts/codecheckerviewer/BugViewer.js
index d14ff54f..65b00385 100644
--- a/web/server/www/scripts/codecheckerviewer/BugViewer.js
+++ b/web/server/www/scripts/codecheckerviewer/BugViewer.js
@@ -187,6 +187,15 @@ function (declare, domClass, dom, style, fx, Toggler, keys, on, query, Memory,
         that._lineDrawer(from, to);
       });

+      this.codeMirror.on("gutterClick", function(cm, n) {
+        var info = cm.lineInfo(n);
+        window.open(
+          "https://source.chromium.org/chromium/chromium/src/+/master:" +
+          that.filepath.innerHTML +
+          ";l=" +
+          (info.line + 1).toString());
+      });
+
       on(document, 'keydown', function (event) {
         if (event.ctrlKey && event.keyCode === 13) // Enter
           that.codeMirror.execCommand('findPersistentNext');

Additional context With my fix applied just left-click on the line number on the left.

irishrover commented 4 years ago

What do you think? Does it make sense?

csordasmarton commented 4 years ago

@irishrover We are planning to integrate CodeChecker with git.

Our first plan is to set run name and version tag information based on git information at the CodeChecker store command (the run name will be the branch name and the version tag will be the latest commit hash).

Our second plan is to show git blame information alongside the file editor on the UI (show the commit hash and author who modified the line). I agree with you that it would be also a great feature to go to the source code repository and to see for example the commit our the source file there.

It's still under discussion in our side and I think our plan is to do this on the next major CodeChecker release: v6.13.0.