Skip to content

Commit

Permalink
Skip Unknown File Types by Default (#360)
Browse files Browse the repository at this point in the history
* Skip Unknown File Types by Default

* Bump Dependencies
  • Loading branch information
gfs committed May 10, 2021
1 parent 25ac4c1 commit 405c4f8
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 20 deletions.
6 changes: 3 additions & 3 deletions AppInspector.CLI/AppInspector.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotLiquid" Version="2.0.361" />
<PackageReference Include="NLog" Version="4.7.5" />
<PackageReference Include="DotLiquid" Version="2.1.436" />
<PackageReference Include="NLog" Version="4.7.9" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.3.37" />
<PackageReference Update="Nerdbank.GitVersioning" Version="3.4.194" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions AppInspector.CLI/CLICmdOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public class CLIAnalyzeCmdOptions : CLICommandOptions

[Option("single-threaded", Required = false, HelpText = "Disables parallel processing.")]
public bool SingleThread { get; set; }

[Option("scan-unknown-file-types", Required = false, HelpText = "Scan unknown file types.")]
public bool ScanUnknownTypes { get; set; }
}

[Verb("tagdiff", HelpText = "Compares unique tag values between two source paths")]
Expand Down
3 changes: 2 additions & 1 deletion AppInspector.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ private static int RunAnalyzeCommand(CLIAnalyzeCmdOptions cliOptions)
FilePathExclusions = cliOptions.FilePathExclusions,
ConsoleVerbosityLevel = cliOptions.ConsoleVerbosityLevel,
Log = cliOptions.Log,
SingleThread = cliOptions.SingleThread
SingleThread = cliOptions.SingleThread,
ScanUnknownTypes = cliOptions.ScanUnknownTypes
}); ;

AnalyzeResult analyzeResult = command.GetResult();
Expand Down
12 changes: 6 additions & 6 deletions AppInspector/AppInspector.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="DotLiquid" Version="2.0.361" />
<PackageReference Include="Microsoft.CST.OAT" Version="1.0.74" />
<PackageReference Include="Microsoft.CST.RecursiveExtractor" Version="1.0.36" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog" Version="4.7.5" />
<PackageReference Include="DotLiquid" Version="2.1.436" />
<PackageReference Include="Microsoft.CST.OAT" Version="1.0.84" />
<PackageReference Include="Microsoft.CST.RecursiveExtractor" Version="1.0.60" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="4.7.9" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -94,7 +94,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.3.37" />
<PackageReference Update="Nerdbank.GitVersioning" Version="3.4.194" />
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="BeforeCompile">
Expand Down
8 changes: 7 additions & 1 deletion AppInspector/Commands/AnalyzeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AnalyzeOptions : CommandOptions
public string FilePathExclusions { get; set; } = "sample,example,test,docs,.vs,.git";
public bool SingleThread { get; set; } = false;
public bool TreatEverythingAsCode { get; set; } = false;
public bool ScanUnknownTypes { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -645,6 +646,11 @@ private bool FileChecksPassed(string filePath, ref LanguageInfo languageInfo, lo
{
_metaDataHelper?.AddLanguage("Unknown");
languageInfo = new LanguageInfo() { Extensions = new string[] { Path.GetExtension(filePath) }, Name = "Unknown" };
if (!_options.ScanUnknownTypes)
{
_metaDataHelper?.Metadata.IncrementFilesSkipped();
return false;
}
}

// 1. Check for exclusions
Expand Down Expand Up @@ -768,13 +774,13 @@ private bool ExcludeFileFromScan(string filePath)
{
string? rootScanDirectory = Directory.Exists(_options.SourcePath) ? _options.SourcePath : Path.GetDirectoryName(_options.SourcePath);
bool scanningRootFolder = !string.IsNullOrEmpty(filePath) && Path.GetDirectoryName(filePath)?.ToLower() == rootScanDirectory?.ToLower();

// 2. Skip excluded files i.e. sample, test or similar from sub-directories (not root #210) unless ignore filter requested
if (!scanningRootFolder)
{
if (_fileExclusionList != null && _fileExclusionList.Any(v => filePath.ToLower().Contains(v)))
{
WriteOnce.SafeLog(MsgHelp.FormatString(MsgHelp.ID.ANALYZE_EXCLUDED_TYPE_SKIPPED, filePath??""), LogLevel.Warn);
_metaDataHelper?.Metadata.IncrementFilesSkipped();
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
</Compile>
</ItemGroup>
<ItemGroup>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.3.37" />
<PackageReference Update="Nerdbank.GitVersioning" Version="3.4.194" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions RulesEngine/AppInspector.RulesEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CST.OAT" Version="1.0.74" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog" Version="4.7.5" />
<PackageReference Include="Microsoft.CST.OAT" Version="1.0.84" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="4.7.9" />
</ItemGroup>

<ItemGroup>
Expand All @@ -41,7 +41,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.3.37" />
<PackageReference Update="Nerdbank.GitVersioning" Version="3.4.194" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions UnitTest.Commands/UnitTest.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
</ItemGroup>
Expand Down Expand Up @@ -152,7 +152,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.3.37" />
<PackageReference Update="Nerdbank.GitVersioning" Version="3.4.194" />
</ItemGroup>

</Project>

0 comments on commit 405c4f8

Please sign in to comment.