about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
authorvsrs <vit@conrlab.com>2020-05-21 11:34:34 +0300
committervsrs <vit@conrlab.com>2020-05-21 11:34:34 +0300
commitc41a10c29331127ee830badddae55f3e27c9a6ea (patch)
treeb30bbcb65ff0717ea5a8b5060b288e03f157d1f5 /editors/code/src
parent8ee40ccbe963a0a5e3e998c1652378e1035dc40d (diff)
downloadrust-c41a10c29331127ee830badddae55f3e27c9a6ea.tar.gz
rust-c41a10c29331127ee830badddae55f3e27c9a6ea.zip
Apply suggestions from @Veetaha code review
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/cargo.ts14
1 files changed, 4 insertions, 10 deletions
diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts
index c3e2e5c0513..a55b2f860f6 100644
--- a/editors/code/src/cargo.ts
+++ b/editors/code/src/cargo.ts
@@ -25,7 +25,7 @@ export function artifactSpec(args: readonly string[]): ArtifactSpec {
     switch (cargoArgs[0]) {
         case "run": cargoArgs[0] = "build"; break;
         case "test": {
-            if (cargoArgs.indexOf("--no-run") === -1) {
+            if (!cargoArgs.includes("--no-run")) {
                 cargoArgs.push("--no-run");
             }
             break;
@@ -36,9 +36,7 @@ export function artifactSpec(args: readonly string[]): ArtifactSpec {
     if (cargoArgs[0] === "test") {
         // for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests
         // produce 2 artifacts: {"kind": "bin"} and {"kind": "test"}
-        result.filter = (artifacts) => {
-            return artifacts.filter(a => a.isTest);
-        };
+        result.filter = (artifacts) => artifacts.filter(it => it.isTest);
     }
 
     return result;
@@ -48,7 +46,7 @@ export class Cargo {
     constructor(readonly rootFolder: string, readonly output: OutputChannel) { }
 
     private async getArtifacts(spec: ArtifactSpec): Promise<CompilationArtifact[]> {
-        let artifacts: CompilationArtifact[] = [];
+        const artifacts: CompilationArtifact[] = [];
 
         try {
             await this.runCargo(spec.cargoArgs,
@@ -75,11 +73,7 @@ export class Cargo {
             throw new Error(`Cargo invocation has failed: ${err}`);
         }
 
-        if (spec.filter) {
-            artifacts = spec.filter(artifacts);
-        }
-
-        return artifacts;
+        return spec.filter?.(artifacts) ?? artifacts;
     }
 
     async executableFromArgs(args: readonly string[]): Promise<string> {