"use strict";

const vscode   = require("vscode");
const analyser = require("./complexity-analyzer");
const reporter = require("./report-builder.js");
const config   = require("./config");
const Output   = require("./output-channel");

function getFileRelativePath(document) {
    const fileUri = document.fileName;
    const projectPath = vscode.workspace.rootPath;

    return projectPath ? fileUri.replace(projectPath, "") : fileUri;
}

function buildReport(document) {
    const channel = new Output();

    const filePath = getFileRelativePath(document);
    channel.write(filePath);

    const metrics = config.getMetrics();
    const legend = reporter.getLegend(metrics);
    channel.write(legend)

    const fileContents = document.getText();
    const analysis = analyser.analyse(fileContents);
    const report = reporter.buildFileReport(analysis, metrics);
    channel.write(report);
}

function runAnalysis(editor) {
    try {
        buildReport(editor.document);
    } catch (e) {
        vscode.window.showErrorMessage("Failed to analyse file. " + e);
        console.log(e);
    }
}

module.exports = {
    execute: runAnalysis
};

@@ -233,212 +233,8 @@
 );%0A%0A
-function getFileRelativePath(document) %7B%0A    const fileUri = document.fileName;%0A    const projectPath = vscode.workspace.rootPath;%0A%0A    return projectPath ? fileUri.replace(projectPath, %22%22) : fileUri;%0A%7D%0A%0A
 func
@@ -322,15 +322,27 @@
 h = 
-getFile
+vscode.workspace.as
 Rela
@@ -354,24 +354,33 @@
 ath(document
+.fileName
 );%0A    chann

Use build in relative path method