private void AddAnalyzerCommentRegularExpression(ImmutableArray <DiagnosticAnalyzer> .Builder builder) { const string analyzedId = "S124"; if (!AnalyzerIds.Contains(analyzedId)) { return; } var rules = ImmutableArray.CreateBuilder <CommentRegularExpressionRule>(); foreach (var parameters in Parameters[analyzedId]) { rules.Add( new CommentRegularExpressionRule { // TODO: Add rule description Descriptor = CommentRegularExpression.CreateDiagnosticDescriptor(parameters["RuleKey"], parameters["message"]), RegularExpression = parameters["regularExpression"] }); } var analyzer = new CommentRegularExpression { Rules = rules.ToImmutable() }; builder.Add(analyzer); }
private void AddAnalyzerClassName(ImmutableArray <DiagnosticAnalyzer> .Builder builder) { var analyzer = new ClassName(); if (!AnalyzerIds.Contains(analyzer.SupportedDiagnostics.Single().Id)) { return; } analyzer.Convention = Parameters[analyzer.SupportedDiagnostics.Single().Id].Single()["format"]; builder.Add(analyzer); }
private void AddAnalyzerFileLines(ImmutableArray <DiagnosticAnalyzer> .Builder builder) { var analyzer = new FileLines(); if (!AnalyzerIds.Contains(analyzer.SupportedDiagnostics.Single().Id)) { return; } analyzer.Maximum = int.Parse( Parameters[analyzer.SupportedDiagnostics.Single().Id].Single()["maximumFileLocThreshold"], NumberStyles.None, CultureInfo.InvariantCulture); builder.Add(analyzer); }
private void AddAnalyzerTooManyLabelsInSwitch(ImmutableArray <DiagnosticAnalyzer> .Builder builder) { var analyzer = new TooManyLabelsInSwitch(); if (!AnalyzerIds.Contains(analyzer.SupportedDiagnostics.Single().Id)) { return; } analyzer.Maximum = int.Parse( Parameters[analyzer.SupportedDiagnostics.Single().Id].Single()["maximum"], NumberStyles.None, CultureInfo.InvariantCulture); builder.Add(analyzer); }
private void AddAnalyzerExpressionCOmplexity(ImmutableArray <DiagnosticAnalyzer> .Builder builder) { var analyzer = new ExpressionComplexity(); if (!AnalyzerIds.Contains(analyzer.SupportedDiagnostics.Single().Id)) { return; } analyzer.Maximum = int.Parse( Parameters[analyzer.SupportedDiagnostics.Single().Id].Single()["max"], NumberStyles.None, CultureInfo.InvariantCulture); builder.Add(analyzer); }
private void AddAnalyzerMagicNumber(ImmutableArray <DiagnosticAnalyzer> .Builder builder) { var analyzer = new MagicNumber(); if (!AnalyzerIds.Contains(analyzer.SupportedDiagnostics.Single().Id)) { return; } analyzer.Exceptions = Parameters[analyzer.SupportedDiagnostics.Single().Id].Single()["exceptions"] .Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(e => e.Trim()) .ToImmutableHashSet(); builder.Add(analyzer); }
public ImmutableArray <DiagnosticAnalyzer> Analyzers() { var builder = ImmutableArray.CreateBuilder <DiagnosticAnalyzer>(); foreach (var parameterLessAnalyzer in parameterLessAnalyzers .Where(parameterLessAnalyzer => AnalyzerIds.Contains(parameterLessAnalyzer.SupportedDiagnostics.Single().Id))) { builder.Add(parameterLessAnalyzer); } AddAnalyzerFileLines(builder); AddAnalyzerLineLength(builder); AddAnalyzerTooManyLabelsInSwitch(builder); AddAnalyzerTooManyParameters(builder); AddAnalyzerExpressionCOmplexity(builder); AddAnalyzerFunctionalComplexity(builder); AddAnalyzerClassName(builder); AddAnalyzerMethodName(builder); AddAnalyzerMagicNumber(builder); AddAnalyzerCommentRegularExpression(builder); return(builder.ToImmutable()); }