Skip to content

Commit 064a9e6

Browse files
authored
Add Evaluate mode (#1)
1 parent 6caa35f commit 064a9e6

6 files changed

Lines changed: 90 additions & 17 deletions

File tree

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ The list of plugins must be specified in the [configuration file](./TeamTools.Li
1616
## Parameters
1717

1818
| Parameter | Shortcut | Description |
19-
|-----------|---------|-------------|
19+
|-----------|----------|-------------|
20+
| `--evaluate` || Evaluate mode to test linter features. It uses severity = warning and EvaluateConfig.json |
2021
| `--config` | `-c` | Path to the configuration file |
2122
| `--dir` | `-d` | Path to a directory containing files to be linted |
2223
| `--file` | `-f` | Path to a single file to be linted |
@@ -26,14 +27,25 @@ The list of plugins must be specified in the [configuration file](./TeamTools.Li
2627
| `--severity` | `-s` | Minimum severity level of findings to include in results. Default is `info` (includes all errors, warnings, hints, and info messages). Use `warning` to include only errors and warnings, or `error` for only explicit errors. Severity levels for each rule are defined in the plugin configuration |
2728
| `--basepath` | `-r` | Base path for files. If specified, relative paths (with this base) will be used in logs and output instead of absolute paths |
2829
| `--verbose` | `-v` | Print detailed progress information to the console |
29-
| `--withversion` | `-n` | Print the version number before outputting results. Unlike `--version`, this allows linting to proceed while also showing the current version in the log |
30+
| `--with-version` | `-n` | Print the version number before outputting results. Unlike `--version`, this allows linting to proceed while also showing the current version in the log |
3031
| `--diff` || Lint all files differing from the `master` branch. Works only when running on files in a Git repository (Git must be in `PATH`). Alternatively, compute the file list manually, save it to a text file, and pass its path via `--filelist` |
3132
| `--quiet` || Do not return a non‑zero exit code if linting findings are detected |
3233
| `--version` || Print the utility version without performing other operations |
3334
| `--help` || Display the list of parameters |
3435

3536
## Usage Examples
3637

38+
### 🚀 First time run to evaluate linter features and capabilities
39+
40+
```cmd
41+
.\TeamTools.Linter.CommandLine.exe --dir "c:\source\my_project" --evaluate
42+
```
43+
44+
Evaluate-mode raises minimal severity to `warning` and forces `EvaluateConfig.json` to be used.
45+
Use this mode to find significant violations in a project which has never been analyzed by this linter before
46+
to test if the linter suffices your needs. Rules related to formatting standard, naming convention and such
47+
are disabled in this mode.
48+
3749
### Linting diff for a directory
3850

3951
```cmd
@@ -48,7 +60,7 @@ The diff is calculated via Git against the main branch; only modified files are
4860
.\TeamTools.Linter.CommandLine.exe --file "c:\source\my_project\Stored procedures\dbo.my_proc.sql"
4961
```
5062

51-
### Linting all files in a directory and excluding info messages
63+
### Linting all files in a directory excluding info messages
5264

5365
```cmd
5466
.\TeamTools.Linter.CommandLine.exe --dir "c:\source\my_project" --severity warning

TeamTools.Linter.CommandLine/Config/CommandLineOptions.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace TeamTools.TSQL.Linter.CommandLine.Config
88
public class CommandLineOptions
99
{
1010
private string configFile = SanitizePath(Path.Combine(AppContext.BaseDirectory, "DefaultConfig.json"));
11+
private string evaluateConfigFile = SanitizePath(Path.Combine(AppContext.BaseDirectory, "EvaluateConfig.json"));
1112
private string directoryName;
1213
private string fileName;
1314
private string fileListSource;
@@ -250,6 +251,23 @@ public string BasePath
250251
HelpText = "Show current version")]
251252
public bool Version { get; set; }
252253

254+
[Option(
255+
longName: "evaluate",
256+
Required = false,
257+
Default = false,
258+
HelpText = "Use this option for first run to detect significant violations only")]
259+
public bool EvaluateApp
260+
{
261+
set
262+
{
263+
if (value)
264+
{
265+
minimalSeverity = Severity.Warning;
266+
configFile = evaluateConfigFile;
267+
}
268+
}
269+
}
270+
253271
private static string SanitizePath(string value)
254272
{
255273
if (string.IsNullOrWhiteSpace(value))
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"plugins": {
3+
"SSDT": {
4+
"dll": "./Plugins/TeamTools.Linter.SSDT/TeamTools.SSDT.ProjectValidator.dll",
5+
"config": "./Plugins/TeamTools.Linter.SSDT/DefaultConfig.json"
6+
},
7+
"TSQL": {
8+
"dll": "./Plugins/TeamTools.Linter.TSQL/TeamTools.TSQL.Linter.dll",
9+
"config": "./Plugins/TeamTools.Linter.TSQL/EvaluateConfig.json"
10+
}
11+
},
12+
"ignore": {
13+
"folders": [
14+
".git",
15+
".vs",
16+
".stylecop",
17+
"bin",
18+
"obj",
19+
"Framework",
20+
"TestResults",
21+
"TestSources",
22+
"node_packages",
23+
"packages",
24+
"tSQLt"
25+
],
26+
"extensions": [
27+
".dll",
28+
".orig",
29+
".exe",
30+
".user",
31+
".local",
32+
".dbmdl",
33+
".jfm",
34+
".dacpac",
35+
".rar",
36+
".zip",
37+
".7z"
38+
]
39+
},
40+
"options": {
41+
"mainBranch": "master"
42+
}
43+
}

TeamTools.Linter.CommandLine/TeamTools.Linter.CommandLine.csproj

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
<ItemGroup>
3434
<Content Include="..\LICENSE" Pack="true" CopyToOutputDirectory="PreserveNewest" />
3535
<Content Include="DefaultConfig.json" CopyToOutputDirectory="PreserveNewest" />
36+
<Content Include="EvaluateConfig.json" CopyToOutputDirectory="PreserveNewest" />
3637
<Folder Include="plugins\" />
3738
</ItemGroup>
3839

3940
<!-- Stuff for embedding plugin binaries into the build output -->
4041
<PropertyGroup>
41-
<SqlLinterProj>TeamTools.TSQL.Linter</SqlLinterProj>
42-
<FileLinterProj>TeamTools.StructuredFiles.Linter</FileLinterProj>
43-
<SsdtLinterProj>TeamTools.SSDT.ProjectValidator</SsdtLinterProj>
42+
<SqlLinterProj>TeamTools.Linter.TSQL</SqlLinterProj>
43+
<SsdtLinterProj>TeamTools.Linter.SSDT</SsdtLinterProj>
4444

45-
<PluginsPath>$(MSBuildThisFileDirectory)..</PluginsPath>
45+
<PluginsPath>$(MSBuildThisFileDirectory)..\..</PluginsPath>
4646
<PluginSourceSubfolder Condition="'$(TargetFramework)'=='netcoreapp3.1'">bin\$(Configuration)\netstandard2.0</PluginSourceSubfolder>
4747
<PluginSourceSubfolder Condition="'$(TargetFramework)'!='netcoreapp3.1'">bin\$(Configuration)\$(TargetFramework)</PluginSourceSubfolder>
4848
<PluginNugetTargetSubfolder>tools\$(TargetFramework)\any\plugins</PluginNugetTargetSubfolder>
@@ -54,9 +54,6 @@
5454
<SqlLinterBin Include="$(PluginsPath)\$(SqlLinterProj)\$(PluginSourceSubfolder)\**\*.*">
5555
<InProject>false</InProject>
5656
</SqlLinterBin>
57-
<FileLinterBin Include="$(PluginsPath)\$(FileLinterProj)\$(PluginSourceSubfolder)\**\*.*">
58-
<InProject>false</InProject>
59-
</FileLinterBin>
6057
<SsdtLinterBin Include="$(PluginsPath)\$(SsdtLinterProj)\$(PluginSourceSubfolder)\**\*.*">
6158
<InProject>false</InProject>
6259
</SsdtLinterBin>
@@ -79,7 +76,6 @@
7976

8077
<Target Name="CopyPlugins" AfterTargets="AfterBuild">
8178
<Copy SourceFiles="@(SqlLinterBin)" DestinationFiles="$(TargetDir)\plugins\$(SqlLinterProj)\%(RecursiveDir)%(FileName)%(Extension)" />
82-
<Copy SourceFiles="@(FileLinterBin)" DestinationFiles="$(TargetDir)\plugins\$(FileLinterProj)\%(RecursiveDir)%(FileName)%(Extension)" />
8379
<Copy SourceFiles="@(SsdtLinterBin)" DestinationFiles="$(TargetDir)\plugins\$(SsdtLinterProj)\%(RecursiveDir)%(FileName)%(Extension)" />
8480
</Target>
8581

@@ -91,9 +87,6 @@
9187
<TfmSpecificPackageFile Include="@(SsdtLinterBin)">
9288
<PackagePath>$(PluginNugetTargetSubfolder)\$(SsdtLinterProj)\%(RecursiveDir)%(FileName)%(Extension)</PackagePath>
9389
</TfmSpecificPackageFile>
94-
<TfmSpecificPackageFile Include="@(FileLinterBin)">
95-
<PackagePath>$(PluginNugetTargetSubfolder)\$(FileLinterProj)\%(RecursiveDir)%(FileName)%(Extension)</PackagePath>
96-
</TfmSpecificPackageFile>
9790
</ItemGroup>
9891
</Target>
9992
</Project>

TeamTools.Linter.CommandLineTests/UnitTests/CommandLineOptionsTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ namespace TeamTools.TSQL.Linter.CommandLineTests
99
[Category("Linter.ConsoleExe")]
1010
public class CommandLineOptionsTests
1111
{
12-
private Dictionary<string, List<string>> argVariants;
1312
#if Windows
1413
private const string BasePath = @"c:\";
1514
#else
1615
private const string BasePath = @"/home/";
1716
#endif
1817

18+
private Dictionary<string, List<string>> argVariants;
19+
1920
[SetUp]
2021
public void Setup()
2122
{

cli-linter.code-workspace

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"Nuget.Config": "xml"
1616
},
1717
"[xml]": {
18-
"editor.tabSize": 2
18+
"editor.tabSize": 2,
19+
"editor.wordWrap": "off"
1920
},
2021
"editor.insertSpaces": true,
2122
"editor.formatOnSave": true,
@@ -39,6 +40,10 @@
3940
"editor.suggest.insertMode": "replace",
4041
"editor.defaultFormatter": "vscode.json-language-features"
4142
},
43+
"[code-workspace]": {
44+
"editor.tabSize": 2,
45+
"editor.defaultFormatter": "esbenp.prettier-vscode"
46+
},
4247
"markdownlint.config": {
4348
"MD033": {
4449
"allowed_elements": ["p"],
@@ -134,7 +139,8 @@
134139
// To prevent weird values from local computer environment variables.
135140
// This will be converted into "Any CPU" by Directory.Build.props
136141
"PLATFORM": ""
137-
}
142+
},
143+
"xml.format.maxLineWidth": 0
138144
},
139145
"extensions": {
140146
"recommendations": [

0 commit comments

Comments
 (0)