Skip to content

Commit

Permalink
Add warning when --diagnostics specified in wrong context
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Feb 26, 2021
1 parent 15305cc commit 4b40a17
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/FormatCommand.cs
Expand Up @@ -89,7 +89,7 @@ internal static RootCommand CreateCommandLineOptions()
var folder = symbolResult.ValueForOption<bool>("--folder");
var fixAnalyzers = symbolResult.OptionResult("--fix-analyzers");
return folder && fixAnalyzers != null
? "Cannot specify the '--folder' option when running analyzers."
? Resources.Cannot_specify_the_folder_option_when_running_analyzers
: null;
}

Expand All @@ -98,7 +98,7 @@ internal static RootCommand CreateCommandLineOptions()
var folder = symbolResult.ValueForOption<bool>("--folder");
var fixStyle = symbolResult.OptionResult("--fix-style");
return folder && fixStyle != null
? "Cannot specify the '--folder' option when fixing style."
? Resources.Cannot_specify_the_folder_option_when_fixing_style
: null;
}

Expand Down
5 changes: 5 additions & 0 deletions src/Program.cs
Expand Up @@ -150,6 +150,11 @@ private static async Task<int> Main(string[] args)
fixType |= FixCategory.Analyzers;
}

if (fixType == FixCategory.None && diagnostics.Length > 0)
{
logger.LogWarning("The '--diagnostics' option only applies when fixing style or running analyzers.");
}

if (fixType == FixCategory.None || fixWhitespace)
{
fixType |= FixCategory.Whitespace;
Expand Down
9 changes: 9 additions & 0 deletions src/Resources.resx
Expand Up @@ -300,4 +300,13 @@
<data name="A_space_separated_list_of_diagnostic_ids_to_use_as_a_filter_when_fixing_code_style_or_3rd_party_issues" xml:space="preserve">
<value>A space separated list of diagnostic ids to use as a filter when fixing code style or 3rd party issues.</value>
</data>
<data name="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers" xml:space="preserve">
<value>The '--diagnostics' option only applies when fixing style or running analyzers.</value>
</data>
<data name="Cannot_specify_the_folder_option_when_running_analyzers" xml:space="preserve">
<value>Cannot specify the '--folder' option when running analyzers.</value>
</data>
<data name="Cannot_specify_the_folder_option_when_fixing_style" xml:space="preserve">
<value>Cannot specify the '--folder' option when fixing style.</value>
</data>
</root>
15 changes: 15 additions & 0 deletions src/xlf/Resources.cs.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">{0} obsahuje jak soubor projektu MSBuild, tak soubor řešení. Určete, který soubor chcete použít, pomocí argumentu &lt;workspace&gt;.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">Styl kódu</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">Verze .NET CLI je {0}.</target>
Expand Down
15 changes: 15 additions & 0 deletions src/xlf/Resources.de.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">In "{0}" wurden eine MSBuild-Projektdatei und eine Projektmappendatei gefunden. Geben Sie die zu verwendende Datei mit dem &lt;workspace&gt;-Argument an.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">Codeformat</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">Die dotnet-CLI-Version ist "{0}".</target>
Expand Down
15 changes: 15 additions & 0 deletions src/xlf/Resources.es.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">Se encontró un archivo del proyecto y un archivo de solución MSBuild en "{0}". Especifique cuál debe usarse con el argumento &lt;workspace&gt;.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">Estilo de código</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">La versión de la CLI de dotnet es "{0}".</target>
Expand Down
15 changes: 15 additions & 0 deletions src/xlf/Resources.fr.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">Fichier projet et fichier solution MSBuild trouvés dans '{0}'. Spécifiez celui qui doit être utilisé avec l'argument &lt;espace de travail&gt;.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">Style de code</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">La version de l'interface CLI dotnet est '{0}'.</target>
Expand Down
15 changes: 15 additions & 0 deletions src/xlf/Resources.it.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">In '{0}' sono stati trovati sia un file di progetto che un file di soluzione MSBuild. Per specificare quello desiderato, usare l'argomento &lt;workspace&gt;.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">Stile codice</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">La versione dell'interfaccia della riga di comando di dotnet è '{0}'.</target>
Expand Down
15 changes: 15 additions & 0 deletions src/xlf/Resources.ja.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">MSBuild のプロジェクト ファイルとソリューション ファイルの両方が '{0}' で見つかりました。使用するものを &lt;workspace&gt; 引数で指定してください。</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">コード スタイル</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">dotnet CLI バージョンは '{0}' です。</target>
Expand Down
15 changes: 15 additions & 0 deletions src/xlf/Resources.ko.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">'{0}'에 MSBuild 프로젝트 파일 및 솔루션 파일이 모두 있습니다. &lt;workspace&gt; 인수를 사용하여 사용할 파일을 지정하세요.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">코드 스타일</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">dotnet CLI 버전은 '{0}'입니다.</target>
Expand Down
15 changes: 15 additions & 0 deletions src/xlf/Resources.pl.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">W elemencie „{0}” znaleziono zarówno plik rozwiązania, jak i plik projektu MSBuild. Określ plik do użycia za pomocą argumentu &lt;workspace&gt;.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">Styl kodu</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">Wersja interfejsu wiersza polecenia dotnet to „{0}”.</target>
Expand Down
15 changes: 15 additions & 0 deletions src/xlf/Resources.pt-BR.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">Foram encontrados um arquivo de solução e um arquivo de projeto do MSBuild em '{0}'. Especifique qual será usado com o argumento &lt;workspace&gt;.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">Estilo do Código</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">A versão do CLI do dotnet é '{0}'.</target>
Expand Down
15 changes: 15 additions & 0 deletions src/xlf/Resources.ru.xlf
Expand Up @@ -42,6 +42,16 @@
<target state="translated">В "{0}" обнаружены как файл проекта, так и файл решения MSBuild. Укажите используемый файл с помощью аргумента &lt;workspace&gt;.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_fixing_style">
<source>Cannot specify the '--folder' option when fixing style.</source>
<target state="new">Cannot specify the '--folder' option when fixing style.</target>
<note />
</trans-unit>
<trans-unit id="Cannot_specify_the_folder_option_when_running_analyzers">
<source>Cannot specify the '--folder' option when running analyzers.</source>
<target state="new">Cannot specify the '--folder' option when running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="Code_Style">
<source>Code Style</source>
<target state="translated">Стиль кода</target>
Expand Down Expand Up @@ -217,6 +227,11 @@
<target state="new">Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both.</target>
<note />
</trans-unit>
<trans-unit id="The_diagnostics_option_only_applies_when_fixing_style_or_running_analyzers">
<source>The '--diagnostics' option only applies when fixing style or running analyzers.</source>
<target state="new">The '--diagnostics' option only applies when fixing style or running analyzers.</target>
<note />
</trans-unit>
<trans-unit id="The_dotnet_CLI_version_is_0">
<source>The dotnet CLI version is '{0}'.</source>
<target state="translated">Версия CLI dotnet: "{0}".</target>
Expand Down

0 comments on commit 4b40a17

Please sign in to comment.