Repository: microsoft/ApplicationInspector
File: AppInspector.CLI/Writers/AnalyzeHtmlWriter.cs (C#)

Code before:
            CLIAnalyzeCmdOptions jsonOptions = new CLIAnalyzeCmdOptions()
            {
                OutputFileFormat = "json",
                OutputFilePath = "output.json"
            };

            //quiet normal write noise for json writter to just gen the file; then restore
            WriteOnce.ConsoleVerbosity saveVerbosity = WriteOnce.Verbosity;
            WriteOnce.Verbosity = WriteOnce.ConsoleVerbosity.None;
            AnalyzeJsonWriter jsonWriter = (AnalyzeJsonWriter)WriterFactory.GetWriter(jsonOptions);
            jsonWriter.WriteResults(_analyzeResult, jsonOptions);
            WriteOnce.Verbosity = saveVerbosity;
        }



        private string MergeResourceFiles(string inputPath)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (Directory.Exists(inputPath))
            {
                try
                {
                    IEnumerable<string> srcfileList = Directory.EnumerateFiles(inputPath, "*.*", SearchOption.AllDirectories);
                    if (srcfileList.Count() == 0)
                    {
                        throw new OpException(MsgHelp.FormatString(MsgHelp.ID.CMD_INVALID_FILE_OR_DIR, inputPath));
                    }
                 
                    foreach(string fileName in srcfileList)
                    {
                        stringBuilder.Append(File.ReadAllText(fileName));
                    }
                }
                catch (Exception)
                {
                    throw new OpException(MsgHelp.FormatString(MsgHelp.ID.CMD_INVALID_FILE_OR_DIR, inputPath));
                }
            }

            return stringBuilder.ToString();
        }




        public override void FlushAndClose()
        {
            TextWriter.Flush();
            TextWriter.Close();

Review comment (suggestion):
```suggestion
                    if (!srcfileList.Any())
```

Code after:
            WriteOnce.ConsoleVerbosity saveVerbosity = WriteOnce.Verbosity;
            WriteOnce.Verbosity = WriteOnce.ConsoleVerbosity.None;
            AnalyzeJsonWriter jsonWriter = (AnalyzeJsonWriter)WriterFactory.GetWriter(jsonOptions);
            jsonWriter.WriteResults(_analyzeResult, jsonOptions);
            WriteOnce.Verbosity = saveVerbosity;
        }

        public override void FlushAndClose()
        {
            TextWriter.Flush();
            TextWriter.Close();
            TextWriter = null;
        }

        private void RegisterSafeType(Type type)
        {
            Template.RegisterSafeType(type, (t) => t.ToString());
            Template.RegisterSafeType(type, type.GetMembers(BindingFlags.Instance).Select((e) => e.Name).ToArray());
        }

        #region UIAndReportResultsHelp

        /// <summary>
        /// Processing for organizing results into easy to use TagGroups for customizable display organization in HTML UI
        /// </summary>
        public void PopulateTagGroups()
        {
            //read default/user preferences on what tags to report presence on and groupings
            if (File.Exists(Utils.GetPath(Utils.AppPath.tagGroupPref)))
            {
                TagGroupPreferences = JsonConvert.DeserializeObject<List<TagCategory>>(File.ReadAllText(Utils.GetPath(Utils.AppPath.tagGroupPref)));
            }
            else
            {
                TagGroupPreferences = new List<TagCategory>();
            }

            //for each preferred group of tag patterns determine if at least one instance was detected
            foreach (TagCategory tagCategory in TagGroupPreferences)
            {
                foreach (TagGroup tagGroup in tagCategory.Groups)
                {
                    foreach (TagSearchPattern pattern in tagGroup.Patterns)
                    {
                        pattern.Detected = _appMetaData.UniqueTags.Any(v => v.Contains(pattern.SearchPattern));
                        //create dynamic "category" groups of tags with pattern relationship established from TagReportGroups.json
                        //that can be used to populate reports with various attributes for each tag detected
                        if (pattern.Detected)
                        {
                            bool uniqueTagsOnly = tagCategory.Type == TagCategory.tagInfoType.uniqueTags;
                            KeyedTagInfoLists["tagGrp" + tagGroup.DataRef] = GetTagInfoListByTagGroup(tagGroup, uniqueTagsOnly);