diff --git a/README.md b/README.md index a60fbf5..aff43ed 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ The list of plugins must be specified in the [configuration file](./TeamTools.Li ## Parameters | Parameter | Shortcut | Description | -|-----------|---------|-------------| +|-----------|----------|-------------| +| `--evaluate` | — | Evaluate mode to test linter features. It uses severity = warning and EvaluateConfig.json | | `--config` | `-c` | Path to the configuration file | | `--dir` | `-d` | Path to a directory containing files to be linted | | `--file` | `-f` | Path to a single file to be linted | @@ -26,7 +27,7 @@ The list of plugins must be specified in the [configuration file](./TeamTools.Li | `--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 | | `--basepath` | `-r` | Base path for files. If specified, relative paths (with this base) will be used in logs and output instead of absolute paths | | `--verbose` | `-v` | Print detailed progress information to the console | -| `--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 | +| `--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 | | `--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` | | `--quiet` | — | Do not return a non‑zero exit code if linting findings are detected | | `--version` | — | Print the utility version without performing other operations | @@ -34,6 +35,17 @@ The list of plugins must be specified in the [configuration file](./TeamTools.Li ## Usage Examples +### 🚀 First time run to evaluate linter features and capabilities + +```cmd +.\TeamTools.Linter.CommandLine.exe --dir "c:\source\my_project" --evaluate +``` + +Evaluate-mode raises minimal severity to `warning` and forces `EvaluateConfig.json` to be used. +Use this mode to find significant violations in a project which has never been analyzed by this linter before +to test if the linter suffices your needs. Rules related to formatting standard, naming convention and such +are disabled in this mode. + ### Linting diff for a directory ```cmd @@ -48,7 +60,7 @@ The diff is calculated via Git against the main branch; only modified files are .\TeamTools.Linter.CommandLine.exe --file "c:\source\my_project\Stored procedures\dbo.my_proc.sql" ``` -### Linting all files in a directory and excluding info messages +### Linting all files in a directory excluding info messages ```cmd .\TeamTools.Linter.CommandLine.exe --dir "c:\source\my_project" --severity warning diff --git a/TeamTools.Linter.CommandLine/Config/CommandLineOptions.cs b/TeamTools.Linter.CommandLine/Config/CommandLineOptions.cs index 7d9f050..2ac444c 100644 --- a/TeamTools.Linter.CommandLine/Config/CommandLineOptions.cs +++ b/TeamTools.Linter.CommandLine/Config/CommandLineOptions.cs @@ -8,6 +8,7 @@ namespace TeamTools.TSQL.Linter.CommandLine.Config public class CommandLineOptions { private string configFile = SanitizePath(Path.Combine(AppContext.BaseDirectory, "DefaultConfig.json")); + private string evaluateConfigFile = SanitizePath(Path.Combine(AppContext.BaseDirectory, "EvaluateConfig.json")); private string directoryName; private string fileName; private string fileListSource; @@ -250,6 +251,23 @@ public string BasePath HelpText = "Show current version")] public bool Version { get; set; } + [Option( + longName: "evaluate", + Required = false, + Default = false, + HelpText = "Use this option for first run to detect significant violations only")] + public bool EvaluateApp + { + set + { + if (value) + { + minimalSeverity = Severity.Warning; + configFile = evaluateConfigFile; + } + } + } + private static string SanitizePath(string value) { if (string.IsNullOrWhiteSpace(value)) diff --git a/TeamTools.Linter.CommandLine/EvaluateConfig.json b/TeamTools.Linter.CommandLine/EvaluateConfig.json new file mode 100644 index 0000000..544fe3f --- /dev/null +++ b/TeamTools.Linter.CommandLine/EvaluateConfig.json @@ -0,0 +1,43 @@ +{ + "plugins": { + "SSDT": { + "dll": "./Plugins/TeamTools.Linter.SSDT/TeamTools.SSDT.ProjectValidator.dll", + "config": "./Plugins/TeamTools.Linter.SSDT/DefaultConfig.json" + }, + "TSQL": { + "dll": "./Plugins/TeamTools.Linter.TSQL/TeamTools.TSQL.Linter.dll", + "config": "./Plugins/TeamTools.Linter.TSQL/EvaluateConfig.json" + } + }, + "ignore": { + "folders": [ + ".git", + ".vs", + ".stylecop", + "bin", + "obj", + "Framework", + "TestResults", + "TestSources", + "node_packages", + "packages", + "tSQLt" + ], + "extensions": [ + ".dll", + ".orig", + ".exe", + ".user", + ".local", + ".dbmdl", + ".jfm", + ".dacpac", + ".rar", + ".zip", + ".7z" + ] + }, + "options": { + "mainBranch": "master" + } +} diff --git a/TeamTools.Linter.CommandLine/TeamTools.Linter.CommandLine.csproj b/TeamTools.Linter.CommandLine/TeamTools.Linter.CommandLine.csproj index 9395d3b..519dd6d 100644 --- a/TeamTools.Linter.CommandLine/TeamTools.Linter.CommandLine.csproj +++ b/TeamTools.Linter.CommandLine/TeamTools.Linter.CommandLine.csproj @@ -33,16 +33,16 @@ + - TeamTools.TSQL.Linter - TeamTools.StructuredFiles.Linter - TeamTools.SSDT.ProjectValidator + TeamTools.Linter.TSQL + TeamTools.Linter.SSDT - $(MSBuildThisFileDirectory).. + $(MSBuildThisFileDirectory)..\.. bin\$(Configuration)\netstandard2.0 bin\$(Configuration)\$(TargetFramework) tools\$(TargetFramework)\any\plugins @@ -54,9 +54,6 @@ false - - false - false @@ -79,7 +76,6 @@ - @@ -91,9 +87,6 @@ $(PluginNugetTargetSubfolder)\$(SsdtLinterProj)\%(RecursiveDir)%(FileName)%(Extension) - - $(PluginNugetTargetSubfolder)\$(FileLinterProj)\%(RecursiveDir)%(FileName)%(Extension) - diff --git a/TeamTools.Linter.CommandLineTests/UnitTests/CommandLineOptionsTests.cs b/TeamTools.Linter.CommandLineTests/UnitTests/CommandLineOptionsTests.cs index f05986d..f1eeca4 100644 --- a/TeamTools.Linter.CommandLineTests/UnitTests/CommandLineOptionsTests.cs +++ b/TeamTools.Linter.CommandLineTests/UnitTests/CommandLineOptionsTests.cs @@ -9,13 +9,14 @@ namespace TeamTools.TSQL.Linter.CommandLineTests [Category("Linter.ConsoleExe")] public class CommandLineOptionsTests { - private Dictionary> argVariants; #if Windows private const string BasePath = @"c:\"; #else private const string BasePath = @"/home/"; #endif + private Dictionary> argVariants; + [SetUp] public void Setup() { diff --git a/cli-linter.code-workspace b/cli-linter.code-workspace index e121205..4a3699c 100644 --- a/cli-linter.code-workspace +++ b/cli-linter.code-workspace @@ -15,7 +15,8 @@ "Nuget.Config": "xml" }, "[xml]": { - "editor.tabSize": 2 + "editor.tabSize": 2, + "editor.wordWrap": "off" }, "editor.insertSpaces": true, "editor.formatOnSave": true, @@ -39,6 +40,10 @@ "editor.suggest.insertMode": "replace", "editor.defaultFormatter": "vscode.json-language-features" }, + "[code-workspace]": { + "editor.tabSize": 2, + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, "markdownlint.config": { "MD033": { "allowed_elements": ["p"], @@ -134,7 +139,8 @@ // To prevent weird values from local computer environment variables. // This will be converted into "Any CPU" by Directory.Build.props "PLATFORM": "" - } + }, + "xml.format.maxLineWidth": 0 }, "extensions": { "recommendations": [