diff --git a/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Commands/AnalyzeCommand.cs b/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Commands/AnalyzeCommand.cs index a72cc500..2067745e 100644 --- a/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Commands/AnalyzeCommand.cs +++ b/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Commands/AnalyzeCommand.cs @@ -140,7 +140,7 @@ public int Run() Writer outputWriter = WriterFactory.GetWriter(_fileFormat, _outputFormat); if (string.IsNullOrEmpty(_outputFile)) outputWriter.TextWriter= Console.Out; - else + else outputWriter.TextWriter = File.CreateText(_outputFile); int filesAnalyzed = 0; diff --git a/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/DummyWriter.cs b/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/DummyWriter.cs new file mode 100644 index 00000000..984dadc1 --- /dev/null +++ b/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/DummyWriter.cs @@ -0,0 +1,19 @@ +// Copyright (C) Microsoft. All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Microsoft.DevSkim.CLI.Writers +{ + public class DummyWriter : Writer + { + public override void WriteIssue(IssueRecord issue) + { + // This is intentionaly empty + } + + public override void FlushAndClose() + { + // This is intentionaly empty + } + + } +} diff --git a/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/IWritter.cs b/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/IWritter.cs deleted file mode 100644 index 7d839d7f..00000000 --- a/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/IWritter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Microsoft.DevSkim.CLI.Writers -{ - public interface IWritter - { - - } -} diff --git a/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/WriterFactory.cs b/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/WriterFactory.cs index 8b7e0152..44e64cea 100644 --- a/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/WriterFactory.cs +++ b/src/Microsoft.DevSkim/Microsoft.DevSkim.CLI/Writers/WriterFactory.cs @@ -9,8 +9,13 @@ public class WriterFactory { public static Writer GetWriter(string writerName, string format = null) { + if (string.IsNullOrEmpty(writerName)) + writerName = "_dummy"; + switch (writerName.ToLowerInvariant()) - { + { + case "_dummy": + return new DummyWriter(); case "json": return new JsonWriter(format); case "text":