diff --git a/.automation/generated/linter-helps.json b/.automation/generated/linter-helps.json index 0209b1cf627..b2f6bc82950 100644 --- a/.automation/generated/linter-helps.json +++ b/.automation/generated/linter-helps.json @@ -1580,30 +1580,35 @@ " list Shows list of available checks [aliases: l]" ], "dotnet-format": [ - "dotnet-format", - " dotnet-format", + "Description:", + " Formats code to match editorconfig settings.", "", "Usage:", - " dotnet-format [options] []", + " dotnet format [] [command] [options]", "", "Arguments:", - " A path to a solution file, a project file, or a folder containing a solution or project file. If a path is not specified then the current directory is used. [default: ]", + " The project or solution file to operate on. If a file is not specified, the command will search the current directory for one. [default: ]", "", "Options:", + " --diagnostics A space separated list of diagnostic ids to use as a filter when fixing code style or 3rd party issues.", + " [default: whichever ids are listed in the editorconfig file]", + " --severity The severity of diagnostics to fix. Allowed values are info, warn, and error.", " --no-restore Doesn't execute an implicit restore before formatting.", - " -f, --folder Whether to treat the `` argument as a simple folder of files.", - " -w, --fix-whitespace Run whitespace formatting. Run by default when not applying fixes.", - " -s, --fix-style Run code style analyzers and apply fixes.", - " -a, --fix-analyzers Run 3rd party analyzers and apply fixes.", - " --diagnostics A space separated list of diagnostic ids to use as a filter when fixing code style or 3rd party issues. [default: ]", - " --include A list of relative file or folder paths to include in formatting. All files are formatted if empty. [default: ]", - " --exclude A list of relative file or folder paths to exclude from formatting. [default: ]", - " --check Formats files without saving changes to disk. Terminates with a non-zero exit code if any files were formatted.", - " --report Accepts a file path, which if provided, will produce a json report in the given directory.", + " --verify-no-changes Verify no formatting changes would be performed. Terminates with a non-zero exit code if any files would have", + " been formatted.", + " --include A list of relative file or folder paths to include in formatting. All files are formatted if empty. [default:", + " all files in the solution or project]", + " --exclude A list of relative file or folder paths to exclude from formatting. [default: none]", + " --include-generated Format files generated by the SDK.", " -v, --verbosity Set the verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]", " --binarylog Log all project or solution load information to a binary log file.", - " --version Show version information", - " -?, -h, --help Show help and usage information", + " --report Accepts a file path, which if provided, will produce a json report in the given directory.", + " -?, -h, --help Show command line help.", + "", + "Commands:", + " whitespace Run whitespace formatting. [default: ]", + " style Run code style analyzers and apply fixes. [default: ]", + " analyzers Run 3rd party analyzers and apply fixes. [default: ]", "" ], "dustilock": [ diff --git a/.automation/test/csharp/bad/csharp_bad_01.cs b/.automation/test/csharp/bad/csharp_bad_01.cs new file mode 100644 index 00000000000..b0f430afd10 --- /dev/null +++ b/.automation/test/csharp/bad/csharp_bad_01.cs @@ -0,0 +1,11 @@ +using System; + +namespace HelloWorld +{ + class Program { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/.automation/test/csharp/bad/csharp_bad_02.cs b/.automation/test/csharp/bad/csharp_bad_02.cs new file mode 100644 index 00000000000..ee40f8b0470 --- /dev/null +++ b/.automation/test/csharp/bad/csharp_bad_02.cs @@ -0,0 +1,13 @@ +using System; + +namespace HelloWorld +{ + class Program + { + static void Main (string[] args) + { + Console.WriteLine ("Hello World!"); + var value = 3 * 4 + 5; + } + } +} diff --git a/.automation/test/csharp/bad/csharp_project.csproj b/.automation/test/csharp/bad/csharp_project.csproj new file mode 100644 index 00000000000..74abf5c9766 --- /dev/null +++ b/.automation/test/csharp/bad/csharp_project.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/.automation/test/csharp/csharp_bad_01.cs b/.automation/test/csharp/csharp_bad_01.cs deleted file mode 100644 index fb79c65b97f..00000000000 Binary files a/.automation/test/csharp/csharp_bad_01.cs and /dev/null differ diff --git a/.automation/test/csharp/csharp_good_01.cs b/.automation/test/csharp/good/csharp_good_01.cs similarity index 100% rename from .automation/test/csharp/csharp_good_01.cs rename to .automation/test/csharp/good/csharp_good_01.cs diff --git a/.automation/test/csharp/good/csharp_good_02.cs b/.automation/test/csharp/good/csharp_good_02.cs new file mode 100644 index 00000000000..a68542dced6 --- /dev/null +++ b/.automation/test/csharp/good/csharp_good_02.cs @@ -0,0 +1,12 @@ +using System; + +namespace HelloWorld +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/.automation/test/csharp/good/csharp_project.csproj b/.automation/test/csharp/good/csharp_project.csproj new file mode 100644 index 00000000000..74abf5c9766 --- /dev/null +++ b/.automation/test/csharp/good/csharp_project.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/.automation/test/csharp/reports/ERROR-CSHARP_DOTNET_FORMAT.txt b/.automation/test/csharp/reports/ERROR-CSHARP_DOTNET_FORMAT.txt index f4b4bc59757..515d7c368b6 100644 --- a/.automation/test/csharp/reports/ERROR-CSHARP_DOTNET_FORMAT.txt +++ b/.automation/test/csharp/reports/ERROR-CSHARP_DOTNET_FORMAT.txt @@ -1,10 +1,14 @@ -Results of dotnet-format linter (version 4.1.131201) +Results of dotnet-format linter (version 000) See documentation on https://megalinter.github.io/descriptors/csharp_dotnet_format/ ----------------------------------------------- -[ERROR] .automation/test/csharp/csharp_bad_01.cs - Formatting code files in workspace '.automation/test/csharp'. - csharp/csharp_bad_01.cs(1,33): Fix whitespace formatting. - Formatted code file '.automation/test/csharp/csharp_bad_01.cs'. - Format complete in 1295ms. +❌ [ERROR] .automation/test/csharp/csharp_bad_01.cs + .automation/test/csharp/csharp_bad_01.cs(5,18): error WHITESPACE: Fix whitespace formatting. Replace 1 characters with '\n\s\s\s\s'. [.automation/test/csharp/csharp_project.csproj] + .automation/test/csharp/csharp_bad_02.cs(7,25): error WHITESPACE: Fix whitespace formatting. Delete 1 characters. [.automation/test/csharp/csharp_project.csproj] + .automation/test/csharp/csharp_bad_02.cs(9,30): error WHITESPACE: Fix whitespace formatting. Delete 1 characters. [.automation/test/csharp/csharp_project.csproj] + +❌ [ERROR] .automation/test/csharp/csharp_bad_02.cs + .automation/test/csharp/csharp_bad_01.cs(5,18): error WHITESPACE: Fix whitespace formatting. Replace 1 characters with '\n\s\s\s\s'. [.automation/test/csharp/csharp_project.csproj] + .automation/test/csharp/csharp_bad_02.cs(7,25): error WHITESPACE: Fix whitespace formatting. Delete 1 characters. [.automation/test/csharp/csharp_project.csproj] + .automation/test/csharp/csharp_bad_02.cs(9,30): error WHITESPACE: Fix whitespace formatting. Delete 1 characters. [.automation/test/csharp/csharp_project.csproj] diff --git a/.automation/test/csharp/reports/SUCCESS-CSHARP_DOTNET_FORMAT.txt b/.automation/test/csharp/reports/SUCCESS-CSHARP_DOTNET_FORMAT.txt index 12bca8f7579..8501088c00d 100644 --- a/.automation/test/csharp/reports/SUCCESS-CSHARP_DOTNET_FORMAT.txt +++ b/.automation/test/csharp/reports/SUCCESS-CSHARP_DOTNET_FORMAT.txt @@ -1,8 +1,10 @@ -Results of dotnet-format linter (version 4.1.131201) +Results of dotnet-format linter (version 000) See documentation on https://megalinter.github.io/descriptors/csharp_dotnet_format/ ----------------------------------------------- -[SUCCESS] .automation/test/csharp/csharp_good_01.cs - Formatting code files in workspace '.automation/test/csharp'. - Format complete in 1181ms. +✅ [SUCCESS] .automation/test/csharp/good/csharp_good_01.cs + + +✅ [SUCCESS] .automation/test/csharp/good/csharp_good_02.cs + diff --git a/.automation/test/sample_project_fixes/csharp_for_fixes_1.cs b/.automation/test/sample_project_fixes/csharp_project/csharp_for_fixes_1.cs similarity index 100% rename from .automation/test/sample_project_fixes/csharp_for_fixes_1.cs rename to .automation/test/sample_project_fixes/csharp_project/csharp_for_fixes_1.cs diff --git a/.automation/test/sample_project_fixes/csharp_project/csharp_project.csproj b/.automation/test/sample_project_fixes/csharp_project/csharp_project.csproj new file mode 100644 index 00000000000..74abf5c9766 --- /dev/null +++ b/.automation/test/sample_project_fixes/csharp_project/csharp_project.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/.automation/test/sample_project_fixes/dotnet_solution.sln b/.automation/test/sample_project_fixes/dotnet_solution.sln new file mode 100644 index 00000000000..af0d713e994 --- /dev/null +++ b/.automation/test/sample_project_fixes/dotnet_solution.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32630.192 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "csharp_project", "csharp_project\csharp_project.csproj", "{FF219771-9DBB-4FB0-8217-F77034831035}" +EndProject +Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "vbdotnet_project", "vbdotnet_project\vbdotnet_project.vbproj", "{AF06A915-8734-4B54-836D-A0E2BAE228EB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FF219771-9DBB-4FB0-8217-F77034831035}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF219771-9DBB-4FB0-8217-F77034831035}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF219771-9DBB-4FB0-8217-F77034831035}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF219771-9DBB-4FB0-8217-F77034831035}.Release|Any CPU.Build.0 = Release|Any CPU + {AF06A915-8734-4B54-836D-A0E2BAE228EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF06A915-8734-4B54-836D-A0E2BAE228EB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF06A915-8734-4B54-836D-A0E2BAE228EB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF06A915-8734-4B54-836D-A0E2BAE228EB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4DFF31ED-FADA-4A6E-B9D4-51D89C3C1FFC} + EndGlobalSection +EndGlobal diff --git a/.automation/test/sample_project_fixes/vbdotnet_for_fixes_1.vb b/.automation/test/sample_project_fixes/vbdotnet_project/vbdotnet_for_fixes_1.vb similarity index 100% rename from .automation/test/sample_project_fixes/vbdotnet_for_fixes_1.vb rename to .automation/test/sample_project_fixes/vbdotnet_project/vbdotnet_for_fixes_1.vb diff --git a/.automation/test/sample_project_fixes/vbdotnet_project/vbdotnet_project.vbproj b/.automation/test/sample_project_fixes/vbdotnet_project/vbdotnet_project.vbproj new file mode 100644 index 00000000000..3edb2ae4157 --- /dev/null +++ b/.automation/test/sample_project_fixes/vbdotnet_project/vbdotnet_project.vbproj @@ -0,0 +1,9 @@ + + + + Exe + vb_projecty + net6.0 + + + diff --git a/.automation/test/vbdotnet/bad/vb_projecty.vbproj b/.automation/test/vbdotnet/bad/vb_projecty.vbproj new file mode 100644 index 00000000000..3edb2ae4157 --- /dev/null +++ b/.automation/test/vbdotnet/bad/vb_projecty.vbproj @@ -0,0 +1,9 @@ + + + + Exe + vb_projecty + net6.0 + + + diff --git a/.automation/test/vbdotnet/vbdotnet_bad_1.vb b/.automation/test/vbdotnet/bad/vbdotnet_bad_1.vb similarity index 100% rename from .automation/test/vbdotnet/vbdotnet_bad_1.vb rename to .automation/test/vbdotnet/bad/vbdotnet_bad_1.vb diff --git a/.automation/test/vbdotnet/bad/vbdotnet_bad_2.vb b/.automation/test/vbdotnet/bad/vbdotnet_bad_2.vb new file mode 100644 index 00000000000..ed079cbbdf1 --- /dev/null +++ b/.automation/test/vbdotnet/bad/vbdotnet_bad_2.vb @@ -0,0 +1,7 @@ +Imports System + +Public Module Hello + Public Sub Main( ) + Console.WriteLine("hello, world" + End Sub +End Module diff --git a/.automation/test/vbdotnet/good/vb_projecty.vbproj b/.automation/test/vbdotnet/good/vb_projecty.vbproj new file mode 100644 index 00000000000..3edb2ae4157 --- /dev/null +++ b/.automation/test/vbdotnet/good/vb_projecty.vbproj @@ -0,0 +1,9 @@ + + + + Exe + vb_projecty + net6.0 + + + diff --git a/.automation/test/vbdotnet/vbdotnet_good_1.vb b/.automation/test/vbdotnet/good/vbdotnet_good_1.vb similarity index 100% rename from .automation/test/vbdotnet/vbdotnet_good_1.vb rename to .automation/test/vbdotnet/good/vbdotnet_good_1.vb diff --git a/.automation/test/vbdotnet/good/vbdotnet_good_2.vb b/.automation/test/vbdotnet/good/vbdotnet_good_2.vb new file mode 100644 index 00000000000..c828d8309f3 --- /dev/null +++ b/.automation/test/vbdotnet/good/vbdotnet_good_2.vb @@ -0,0 +1,7 @@ +Imports System + +Public Module Hello + Public Sub Main() + Console.WriteLine("hello, world") + End Sub +End Module diff --git a/.automation/test/vbdotnet/reports/ERROR-VBDOTNET_DOTNET_FORMAT.txt b/.automation/test/vbdotnet/reports/ERROR-VBDOTNET_DOTNET_FORMAT.txt index 87e3dfcc2f0..cb2efbaa8ee 100644 --- a/.automation/test/vbdotnet/reports/ERROR-VBDOTNET_DOTNET_FORMAT.txt +++ b/.automation/test/vbdotnet/reports/ERROR-VBDOTNET_DOTNET_FORMAT.txt @@ -1,12 +1,20 @@ -Results of dotnet-format linter (version 4.1.131201) +Results of dotnet-format linter (version 000) See documentation on https://megalinter.github.io/descriptors/vbdotnet_dotnet_format/ ----------------------------------------------- -[ERROR] .automation/test/vbdotnet/vbdotnet_bad_1.vb - Formatting code files in workspace '.automation/test/vbdotnet'. - vbdotnet/vbdotnet_bad_1.vb(4,4): Fix whitespace formatting. - vbdotnet/vbdotnet_bad_1.vb(4,20): Fix whitespace formatting. - vbdotnet/vbdotnet_bad_1.vb(5,7): Fix whitespace formatting. - Formatted code file '.automation/test/vbdotnet/vbdotnet_bad_1.vb'. - Format complete in 1188ms. +❌ [ERROR] .automation/test/vbdotnet/vbdotnet_bad_1.vb + .automation/test/vbdotnet/vbdotnet_bad_1.vb(4,4): error WHITESPACE: Fix whitespace formatting. Insert '\s'. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_1.vb(4,20): error WHITESPACE: Fix whitespace formatting. Delete 2 characters. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_1.vb(5,7): error WHITESPACE: Fix whitespace formatting. Insert '\s\s'. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_2.vb(4,4): error WHITESPACE: Fix whitespace formatting. Insert '\s'. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_2.vb(4,20): error WHITESPACE: Fix whitespace formatting. Delete 2 characters. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_2.vb(5,7): error WHITESPACE: Fix whitespace formatting. Insert '\s\s'. [.automation/test/vbdotnet/vb_projecty.vbproj] + +❌ [ERROR] .automation/test/vbdotnet/vbdotnet_bad_2.vb + .automation/test/vbdotnet/vbdotnet_bad_1.vb(4,4): error WHITESPACE: Fix whitespace formatting. Insert '\s'. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_1.vb(4,20): error WHITESPACE: Fix whitespace formatting. Delete 2 characters. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_1.vb(5,7): error WHITESPACE: Fix whitespace formatting. Insert '\s\s'. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_2.vb(4,4): error WHITESPACE: Fix whitespace formatting. Insert '\s'. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_2.vb(4,20): error WHITESPACE: Fix whitespace formatting. Delete 2 characters. [.automation/test/vbdotnet/vb_projecty.vbproj] + .automation/test/vbdotnet/vbdotnet_bad_2.vb(5,7): error WHITESPACE: Fix whitespace formatting. Insert '\s\s'. [.automation/test/vbdotnet/vb_projecty.vbproj] diff --git a/.automation/test/vbdotnet/reports/SUCCESS-VBDOTNET_DOTNET_FORMAT.txt b/.automation/test/vbdotnet/reports/SUCCESS-VBDOTNET_DOTNET_FORMAT.txt index 63a94e4b7b0..ba77aa8104b 100644 --- a/.automation/test/vbdotnet/reports/SUCCESS-VBDOTNET_DOTNET_FORMAT.txt +++ b/.automation/test/vbdotnet/reports/SUCCESS-VBDOTNET_DOTNET_FORMAT.txt @@ -1,8 +1,10 @@ -Results of dotnet-format linter (version 4.1.131201) +Results of dotnet-format linter (version 000) See documentation on https://megalinter.github.io/descriptors/vbdotnet_dotnet_format/ ----------------------------------------------- -[SUCCESS] .automation/test/vbdotnet/vbdotnet_good_1.vb - Formatting code files in workspace '.automation/test/vbdotnet'. - Format complete in 1063ms. +✅ [SUCCESS] .automation/test/vbdotnet/good/vbdotnet_good_1.vb + + +✅ [SUCCESS] .automation/test/vbdotnet/good/vbdotnet_good_2.vb + diff --git a/CHANGELOG.md b/CHANGELOG.md index cd408fb1e56..4cb7185e84a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l - Fix perl linter skipping files +- Upgrade to dotnet 6.0, dotnet-format requires `.sln`, `.csproj` or `.vbproj` in the repo + - Linter versions upgrades - [csharpier](https://csharpier.com/) from 0.21.0 to **0.16.0** on 2022-12-29 - [stylelint](https://stylelint.io) from 14.16.0 to **14.16.1** on 2022-12-29 diff --git a/Dockerfile b/Dockerfile index b7d25e14dac..c05f82fd386 100644 --- a/Dockerfile +++ b/Dockerfile @@ -313,7 +313,7 @@ RUN rc-update add docker boot && rc-service docker start || true \ # CSHARP installation && wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" @@ -366,7 +366,7 @@ RUN mkdir -p ${PWSH_DIRECTORY} \ # Next line commented because already managed by another linter # RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ # && chmod +x dotnet-install.sh \ -# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest +# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest # Next line commented because already managed by another linter # ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" @@ -408,7 +408,7 @@ RUN curl --retry 5 --retry-delay 5 -sLO "${ARM_TTK_URI}" \ && /usr/share/dotnet/dotnet tool install -g dotnet-format \ # csharpier installation - && /usr/share/dotnet/dotnet tool install -g csharpier --version 0.16.0 \ + && /usr/share/dotnet/dotnet tool install -g csharpier \ # dartanalyzer installation && wget --tries=50 -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \ @@ -544,10 +544,10 @@ ENV PATH="~/.raku/bin:/opt/rakudo-pkg/bin:/opt/rakudo-pkg/share/perl6/site/bin:$ # Next line commented because already managed by another linter # RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ # && chmod +x dotnet-install.sh \ -# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest +# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest # Next line commented because already managed by another linter # ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" -RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.6.9 \ +RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI \ # dustilock installation && ML_THIRD_PARTY_DIR=/download/dustilock && \ @@ -601,10 +601,10 @@ RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.6.9 \ # Next line commented because already managed by another linter # RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ # && chmod +x dotnet-install.sh \ -# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest +# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest # Next line commented because already managed by another linter # ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" - && dotnet tool install --global --version 1.14.5 TSQLLint \ + && dotnet tool install --global TSQLLint \ # tflint installation # Managed with COPY --from=tflint /usr/local/bin/tflint /usr/bin/ @@ -624,10 +624,6 @@ RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.6.9 \ ENV KICS_QUERIES_PATH=/opt/kics/assets/queries KICS_LIBRARIES_PATH=/opt/kics/assets/libraries # Managed with COPY --from=kics /app/bin/assets /opt/kics/assets/ -# dotnet-format installation -# Next line commented because already managed by another linter -# RUN /usr/share/dotnet/dotnet tool install -g dotnet-format - #OTHER__END ################################ diff --git a/flavors/dotnet/Dockerfile b/flavors/dotnet/Dockerfile index 8927533298d..ee426e386d3 100644 --- a/flavors/dotnet/Dockerfile +++ b/flavors/dotnet/Dockerfile @@ -235,7 +235,7 @@ RUN mkdir -p ${PWSH_DIRECTORY} \ # CSHARP installation && wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" @@ -255,7 +255,7 @@ RUN mkdir -p ${PWSH_DIRECTORY} \ # Next line commented because already managed by another linter # RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ # && chmod +x dotnet-install.sh \ -# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest +# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest # Next line commented because already managed by another linter # ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" @@ -294,7 +294,7 @@ RUN curl --retry 5 --retry-delay 5 -sLO "${ARM_TTK_URI}" \ && /usr/share/dotnet/dotnet tool install -g dotnet-format \ # csharpier installation - && /usr/share/dotnet/dotnet tool install -g csharpier --version 0.16.0 \ + && /usr/share/dotnet/dotnet tool install -g csharpier \ # hadolint installation # Managed with COPY --from=hadolint /bin/hadolint /usr/bin/hadolint @@ -362,14 +362,10 @@ RUN curl --retry 5 --retry-delay 5 -sLO "${ARM_TTK_URI}" \ # Next line commented because already managed by another linter # RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ # && chmod +x dotnet-install.sh \ -# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest +# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest # Next line commented because already managed by another linter # ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" - && dotnet tool install --global --version 1.14.5 TSQLLint - -# dotnet-format installation -# Next line commented because already managed by another linter -# RUN /usr/share/dotnet/dotnet tool install -g dotnet-format + && dotnet tool install --global TSQLLint #OTHER__END diff --git a/flavors/security/Dockerfile b/flavors/security/Dockerfile index f78cefba2d6..b60ecf2fb4b 100644 --- a/flavors/security/Dockerfile +++ b/flavors/security/Dockerfile @@ -210,10 +210,10 @@ RUN printf '#!/bin/bash \n\nif [[ -x "$1" ]]; then exit 0; else echo "Error: Fil # devskim installation && wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" -RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.6.9 \ +RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI \ # dustilock installation && ML_THIRD_PARTY_DIR=/download/dustilock && \ diff --git a/linters/csharp_dotnet_format/Dockerfile b/linters/csharp_dotnet_format/Dockerfile index 47b37b17dd7..1eb15fb93e8 100644 --- a/linters/csharp_dotnet_format/Dockerfile +++ b/linters/csharp_dotnet_format/Dockerfile @@ -107,13 +107,10 @@ ENV PATH="/node_modules/.bin:${PATH}" # CSHARP installation RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" -# dotnet-format installation -RUN /usr/share/dotnet/dotnet tool install -g dotnet-format - #OTHER__END ###################### diff --git a/linters/repository_devskim/Dockerfile b/linters/repository_devskim/Dockerfile index 06bbdd9c673..fc1f575613c 100644 --- a/linters/repository_devskim/Dockerfile +++ b/linters/repository_devskim/Dockerfile @@ -132,10 +132,10 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ # devskim installation RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" -RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.6.9 +RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI #OTHER__END diff --git a/linters/sql_tsqllint/Dockerfile b/linters/sql_tsqllint/Dockerfile index fb862bc2489..1786943fea0 100644 --- a/linters/sql_tsqllint/Dockerfile +++ b/linters/sql_tsqllint/Dockerfile @@ -107,7 +107,7 @@ ENV PATH="/node_modules/.bin:${PATH}" # tsqllint installation RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" RUN dotnet tool install --global TSQLLint diff --git a/linters/vbdotnet_dotnet_format/Dockerfile b/linters/vbdotnet_dotnet_format/Dockerfile index c076821a244..77dd03eafa9 100644 --- a/linters/vbdotnet_dotnet_format/Dockerfile +++ b/linters/vbdotnet_dotnet_format/Dockerfile @@ -107,13 +107,10 @@ ENV PATH="/node_modules/.bin:${PATH}" # VBDOTNET installation RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" -# dotnet-format installation -RUN /usr/share/dotnet/dotnet tool install -g dotnet-format - #OTHER__END ###################### diff --git a/megalinter/descriptors/csharp.megalinter-descriptor.yml b/megalinter/descriptors/csharp.megalinter-descriptor.yml index 0233ce41ddf..c66d739a331 100644 --- a/megalinter/descriptors/csharp.megalinter-descriptor.yml +++ b/megalinter/descriptors/csharp.megalinter-descriptor.yml @@ -19,29 +19,30 @@ install: - | RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest - ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" linters: # DOTNET FORMAT - class: DotnetFormatLinter linter_name: dotnet-format is_formatter: true - linter_url: https://github.com/dotnet/format + linter_text: | + dotnet-format requires a `.sln` or `.csproj` file to run correctly. + linter_url: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-format linter_repo: https://github.com/dotnet/format linter_image_url: https://user-images.githubusercontent.com/9797472/61659851-6bbdc880-ac7d-11e9-95f7-d30c7de1a18a.png + cli_executable: dotnet cli_lint_extra_args: - - "--folder" - - "--check" - - "--exclude" - - "/" - - "--include" - cli_lint_fix_arg_name: "--megalinter-fix-flag" # Workaround for PythonBlackOrIsortLinter class behavior + - "format" + - "{{WORKSPACE}}" + - "--verify-no-changes" + cli_lint_fix_arg_name: "--megalinter-fix-flag" # Workaround for DotnetFormatLinter class behavior cli_lint_fix_remove_args: - - "--check" + - "--verify-no-changes" linter_version_cache: "000" examples: - - "dotnet-format --folder --check --exclude / --include myfile.cs" - - "dotnet-format --folder --exclude / --include myfile.cs" # Fix + - "dotnet format {{WORKSPACE}} --verify-no-changes" + - "dotnet format {{WORKSPACE}}" # Fix install: dockerfile: - RUN /usr/share/dotnet/dotnet tool install -g dotnet-format @@ -66,7 +67,7 @@ linters: - "dotnet csharpier myfile.cs myfile2.cs" # Fix install: dockerfile: - - RUN /usr/share/dotnet/dotnet tool install -g csharpier --version 0.16.0 + - RUN /usr/share/dotnet/dotnet tool install -g csharpier ide: rider: - name: csharpier diff --git a/megalinter/descriptors/repository.megalinter-descriptor.yml b/megalinter/descriptors/repository.megalinter-descriptor.yml index 0073ec25b9e..a5cc9581ee9 100644 --- a/megalinter/descriptors/repository.megalinter-descriptor.yml +++ b/megalinter/descriptors/repository.megalinter-descriptor.yml @@ -92,9 +92,9 @@ linters: - | RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest - ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" - - RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.6.9 + - RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI ide: vscode: - name: VSCode DevSkim diff --git a/megalinter/descriptors/sql.megalinter-descriptor.yml b/megalinter/descriptors/sql.megalinter-descriptor.yml index 455e2f1c44c..7329efc732f 100644 --- a/megalinter/descriptors/sql.megalinter-descriptor.yml +++ b/megalinter/descriptors/sql.megalinter-descriptor.yml @@ -68,7 +68,6 @@ linters: examples: - "tsqllint myfile.sql" - "tsqllint myfile.sql myfile2.sql" - downgraded_version: true install: apk: - icu-libs @@ -83,9 +82,9 @@ linters: - | RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest - ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" - - RUN dotnet tool install --global --version 1.14.5 TSQLLint + - RUN dotnet tool install --global TSQLLint ide: vscode: - name: TSQL Lint diff --git a/megalinter/descriptors/vbdotnet.megalinter-descriptor.yml b/megalinter/descriptors/vbdotnet.megalinter-descriptor.yml index 1eb6eff0b59..973218a56ad 100644 --- a/megalinter/descriptors/vbdotnet.megalinter-descriptor.yml +++ b/megalinter/descriptors/vbdotnet.megalinter-descriptor.yml @@ -19,28 +19,27 @@ install: - | RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \ && chmod +x dotnet-install.sh \ - && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 5.0 -version latest + && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest - ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet" linters: # DOTNET FORMAT - class: DotnetFormatLinter linter_name: dotnet-format is_formatter: true - linter_url: https://github.com/dotnet/format + linter_text: | + dotnet-format requires a `.sln` or `.vbproj` file to run correctly. + linter_url: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-format + linter_repo: https://github.com/dotnet/format linter_image_url: https://user-images.githubusercontent.com/9797472/61659851-6bbdc880-ac7d-11e9-95f7-d30c7de1a18a.png + cli_executable: dotnet cli_lint_extra_args: - - "--folder" - - "--check" - - "--exclude" - - "/" - - "--include" + - "format" + - "{{WORKSPACE}}" + - "--verify-no-changes" cli_lint_fix_arg_name: "--megalinter-fix-flag" # Workaround to allow fix cli_lint_fix_remove_args: - - "--check" + - "--verify-no-changes" linter_version_cache: "000" examples: - - "dotnet-format --folder --check --exclude / --include myfile.vb" - - "dotnet-format --folder --exclude / --include myfile.vb" - install: - dockerfile: - - RUN /usr/share/dotnet/dotnet tool install -g dotnet-format + - "dotnet format {{WORKSPACE}} --verify-no-changes" + - "dotnet format {{WORKSPACE}}" # Fix diff --git a/megalinter/linters/DotnetFormatLinter.py b/megalinter/linters/DotnetFormatLinter.py index ea5c8abc3b3..b7a47cc6060 100644 --- a/megalinter/linters/DotnetFormatLinter.py +++ b/megalinter/linters/DotnetFormatLinter.py @@ -3,8 +3,6 @@ Use dotnet-format to lint CSharp files """ -import os.path - from megalinter import Linter @@ -12,10 +10,10 @@ class DotnetFormatLinter(Linter): # Build the CLI command to call to lint a file def build_lint_command(self, file=None): + # cli_lint_mode = list_of_files or project + dotnet_format_command = " ".join(super().build_lint_command(None)) commands = [ - f'cd "{os.path.realpath(os.path.dirname(file))}" || exit 1', - " ".join(super().build_lint_command(os.path.basename(file))) - + " | tee /dev/tty2 2>&1", + dotnet_format_command + " | tee /dev/tty2 2>&1", 'exit "${PIPESTATUS[0]}"', ] return " && ".join(commands)