private void AddMissingEntries(AnalysisOutput output, AnalyzerLanguage language) { var foundKeys = output.Issues.Select(i => i.RuleId).ToList(); var notFoundKeys = RuleFinder.GetAnalyzerTypes(language) .Select(t => new { Type = t, RuleAttribute = t.GetCustomAttribute <RuleAttribute>() }) .Select(rule => RuleFinder.IsRuleTemplate(rule.Type) ? string.Format(TemplateRuleIdPattern, rule.RuleAttribute.Key) : rule.RuleAttribute.Key) .Where(s => !foundKeys.Contains(s)); foreach (var notFoundKey in notFoundKeys) { output.Issues.Add(new Issue { RuleId = notFoundKey }); } }
private void SplitAndStoreOmstarByIssueType(AnalysisOutput omstar) { foreach (var issueGroup in omstar.Issues.GroupBy(issue => issue.RuleId)) { var omstarForRule = new AnalysisOutput { ToolInfo = omstar.ToolInfo, Version = omstar.Version, Issues = issueGroup .OrderBy(issue => { var location = issue.Locations.FirstOrDefault(); return(location == null ? string.Empty : location.AnalysisTarget.Uri); }, new InvariantCultureStringSortComparer()) .ThenBy(issue => { var location = issue.Locations.FirstOrDefault(); return(location == null ? 0 : location.AnalysisTarget.Region.StartLine); }) .ThenBy(issue => { var location = issue.Locations.FirstOrDefault(); return(location == null ? 0 : location.AnalysisTarget.Region.EndLine); }) .ThenBy(issue => { return(issue.FullMessage); }, new InvariantCultureStringSortComparer()) .ToList() }; var content = JsonConvert.SerializeObject(omstarForRule, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented }); File.WriteAllText(Path.Combine( AnalysisOutputDirectory.FullName, string.Format("{0}.json", issueGroup.Key)), content); } }
private static AnalysisOutput GenerateOmstarOutput(ErrorModels.Xml.AnalysisOutput xml) { var assemblyName = xml.GetType().Assembly.GetName(); var omstar = new AnalysisOutput { Version = "0.1", ToolInfo = new ToolInfo { FileVersion = "1.0.0", ToolName = assemblyName.Name }, Issues = xml.Files.SelectMany(f => f.Issues.Select(i => new Issue { FullMessage = i.Message, RuleId = i.Id, Properties = null, Locations = new List <IssueLocation> { new IssueLocation { AnalysisTarget = new AnalysisTarget { Region = new Region { StartLine = i.Line, EndLine = i.Line, StartColumn = 0, EndColumn = int.MaxValue }, Uri = f.Path } } } })).ToList() }; return(omstar); }
public static async Task <string> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log) { var defaultTimeLimit = TimeSpan.FromMinutes(2); var content = await new StreamReader(req.Body).ReadToEndAsync(); var input = JsonConvert.DeserializeObject <AnalysisInput>(content); try { var output = Utilities.RunWithTimeLimit(() => Analysis.Analyze(input), defaultTimeLimit); return(JsonConvert.SerializeObject(output)); } catch (BackendUtilities.TimeoutException ex) { var result = new AnalysisOutput { Error = "Operation was not completed in " + defaultTimeLimit.ToString(), Status = BioModelAnalyzer.StatusType.Error }; return(JsonConvert.SerializeObject(result)); } }
/// <summary> /// Clears the session state /// </summary> public void ClearState() { MemoryRegion.RemoveVariablesInScope(VariableType.Standard); if (DataInfo != null) { DataInfo.Dispose(); } OverriddenSetOptions = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); DataInfo = new DataSourceInfo(); Recodes.Clear(); Reset(); CurrentRead = null; IsFirstStatement = false; ProgramText.Length = 0; DataTableRefreshNeeded = true; AnalysisOut = new AnalysisOutput(this); isCancelRequest = false; GroupVariableList = new Dictionary<string, List<string>>(); }
private void Initialize() { GroupVariableList = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase); StatisticModuleList = new Dictionary<string, System.Reflection.Assembly>(StringComparer.OrdinalIgnoreCase); CommandToAssemblyMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); DLLClassList = new Dictionary<string, IDLLClass>(); foreach (string s in System.Configuration.ConfigurationSettings.AppSettings) { switch (s.ToUpper()) { case "FREQUENCY": case "TABLES": case "SUMMARIZE": case "GRAPH": case "MEANS": case "MATCH": case "LINEARREGRESSION": case "LOGISTICREGRESSION": case "COMPLEXSAMPLEMEANS": case "COMPLEXSAMPLETABLES": case "COMPLEXSAMPLEFREQUENCY": case "KAPLANMEIERSURVIVAL": case "COXPROPORTIONALHAZARDS": string StatisticsAssembly = System.Configuration.ConfigurationSettings.AppSettings[s].ToString(); if (! StatisticModuleList.ContainsKey(StatisticsAssembly)) { System.Reflection.Assembly a = System.Reflection.Assembly.Load(StatisticsAssembly); StatisticModuleList.Add(StatisticsAssembly, a); } CommandToAssemblyMap.Add(s, StatisticsAssembly); break; } } ConnectionList = new Dictionary<string, IDataSource>(StringComparer.OrdinalIgnoreCase); DataTableRefreshNeeded = true; CurrentSelect = new StringBuilder(); PermanantVariables = new System.Collections.Specialized.NameValueCollection(); GlobalVariables = new System.Collections.Specialized.NameValueCollection(); StandardVariables = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); SelectString = new StringBuilder(); SelectExpression = new List<Epi.Core.AnalysisInterpreter.AnalysisRule>(); SortExpression = new StringBuilder(); DataSet = new System.Data.DataSet(); DataInfo = new DataSourceInfo(); ProgramText = new StringBuilder(); IsFirstStatement = false; Recodes = new Dictionary<string, Epi.Core.AnalysisInterpreter.Rules.RecodeList>(StringComparer.OrdinalIgnoreCase); VariableExpressionList = new Dictionary<string, AnalysisRule>(StringComparer.OrdinalIgnoreCase); VariableValueList = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); AnalysisOut = new AnalysisOutput(this); OverriddenSetOptions = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); SelectCommandList.Add(CommandNames.ABS); SelectCommandList.Add(CommandNames.AND); SelectCommandList.Add(CommandNames.ALWAYS); SelectCommandList.Add(CommandNames.APPEND); SelectCommandList.Add(CommandNames.MOD); SelectCommandList.Add(CommandNames.LIKE); SelectCommandList.Add(CommandNames.OR); SelectCommandList.Add(CommandNames.XOR); SelectCommandList.Add(CommandNames.NOT); SelectCommandList.Add(CommandNames.EXP); SelectCommandList.Add(CommandNames.LN); SelectCommandList.Add(CommandNames.LOG); SelectCommandList.Add(CommandNames.NUMTODATE); SelectCommandList.Add(CommandNames.NUMTOTIME); SelectCommandList.Add(CommandNames.RECORDCOUNT); SelectCommandList.Add(CommandNames.RND); SelectCommandList.Add(CommandNames.ROUND); SelectCommandList.Add(CommandNames.STEP); SelectCommandList.Add(CommandNames.SIN); SelectCommandList.Add(CommandNames.COS); SelectCommandList.Add(CommandNames.TAN); SelectCommandList.Add(CommandNames.TRUNC); SelectCommandList.Add(CommandNames.PFROMZ); SelectCommandList.Add(CommandNames.ZSCORE); SelectCommandList.Add(CommandNames.YEARS); SelectCommandList.Add(CommandNames.MONTHS); SelectCommandList.Add(CommandNames.DAYS); SelectCommandList.Add(CommandNames.YEAR); SelectCommandList.Add(CommandNames.MONTH); SelectCommandList.Add(CommandNames.DAY); SelectCommandList.Add(CommandNames.CURRENTUSER); SelectCommandList.Add(CommandNames.EXISTS); SelectCommandList.Add(CommandNames.FILEDATE); SelectCommandList.Add(CommandNames.SYSTEMDATE); SelectCommandList.Add(CommandNames.SYSTEMTIME); SelectCommandList.Add(CommandNames.HOURS); SelectCommandList.Add(CommandNames.MINUTES); SelectCommandList.Add(CommandNames.SECONDS); SelectCommandList.Add(CommandNames.HOUR); SelectCommandList.Add(CommandNames.MINUTE); SelectCommandList.Add(CommandNames.SECOND); SelectCommandList.Add(CommandNames.FINDTEXT); SelectCommandList.Add(CommandNames.FORMAT); SelectCommandList.Add(CommandNames.LINEBREAK); SelectCommandList.Add(CommandNames.STRLEN); SelectCommandList.Add(CommandNames.SUBSTRING); SelectCommandList.Add(CommandNames.TXTTONUM); SelectCommandList.Add(CommandNames.TXTTODATE); SelectCommandList.Add(CommandNames.UPPERCASE); }