From e63e753cdfe8742f3c2c057f6023b4897b0935af Mon Sep 17 00:00:00 2001 From: Oleg Safonov Date: Thu, 27 Jul 2017 18:42:10 +0300 Subject: [PATCH] Fix problem with filters while stdin analyze (#81) --- src/core/Runtime/EngineRunner.cs | 32 +++++++++++++++++--------------- test | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/core/Runtime/EngineRunner.cs b/src/core/Runtime/EngineRunner.cs index 4a79dee..c790627 100644 --- a/src/core/Runtime/EngineRunner.cs +++ b/src/core/Runtime/EngineRunner.cs @@ -45,9 +45,11 @@ public LinterhubOutputSchema RunAnalyze( { return Directory.GetFiles(context.WorkingDirectory, x, System.IO.SearchOption.AllDirectories).ToList(); }).SelectMany(x => x).ToList() - .ForEach(x => { + .ForEach(x => + { var lo = new EngineOptions(); - context.RunOptions.Select(y => { + context.RunOptions.Select(y => + { if (y.Key == "{path}") { return new KeyValuePair(y.Key, Path.GetFullPath(x) @@ -123,7 +125,8 @@ public LinterhubOutputSchema RunAnalyze( result.AddRange(parsedOutput.Where(x => x.Path != string.Empty)); } - if (result.Count != 0) { + if (result.Count != 0) + { var exists = output.Find(x => x.Engine == context.Specification.Schema.Name); if (exists != null) { @@ -152,20 +155,19 @@ public LinterhubOutputSchema RunAnalyze( }); - if(config != null) + output.ForEach(x => { - output.ForEach(x => { - x.Result.ForEach(y => { - y.Messages = y.Messages.Where(m => - { - return !(config.Ignore.Find(r => y.Path.Contains(r.Mask)) != null || config.Ignore.Find(r => y.Path.Contains(r.Mask) && m.RuleId == r.RuleId) != null || - config.Ignore.Find(r => y.Path.Contains(r.Mask) && m.Line == r.Line) != null); - }).OrderBy(z => z.Line).ThenBy(z => z.Column).ThenBy(z => z.RuleId).ToList(); - }); - x.Result.Sort((a,b) => a.Path.CompareTo(b.Path)); + x.Result.ForEach(y => + { + y.Messages = y.Messages.Where(m => + { + return config != null ? !(config.Ignore.Find(r => y.Path.Contains(r.Mask)) != null || config.Ignore.Find(r => y.Path.Contains(r.Mask) && m.RuleId == r.RuleId) != null || + config.Ignore.Find(r => y.Path.Contains(r.Mask) && m.Line == r.Line) != null) : true; + }).OrderBy(z => z.Line).ThenBy(z => z.Column).ThenBy(z => z.RuleId).ToList(); }); - output.Sort((a,b) => a.Engine.CompareTo(b.Engine)); - } + x.Result.Sort((a, b) => a.Path.CompareTo(b.Path)); + }); + output.Sort((a, b) => a.Engine.CompareTo(b.Engine)); return output; diff --git a/test b/test index 46e21d8..227bb0b 160000 --- a/test +++ b/test @@ -1 +1 @@ -Subproject commit 46e21d82451bfb8ac8aa0c09dbeff9a03a78f2f4 +Subproject commit 227bb0bd5e39cf50e4fcc0e2fc1e1a26d8aba461