Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dotnet to v6 #1680

Merged
merged 91 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
e2f8c5b
Upgrade dotnet to v6 + list_of_files for dotnet-format
nvuillam Jul 24, 2022
cf820a9
Fixes
nvuillam Jul 25, 2022
e794e49
Fixes
nvuillam Jul 25, 2022
92e3137
Merge branch 'main' into features/dotnet-upgrade
nvuillam Jul 30, 2022
c140688
Adding dotnet project files
Jul 31, 2022
35fca2b
Better .cs examples of bad code
Jul 31, 2022
be35811
Dotnet Upgrade project files (#1679)
lextatic Jul 31, 2022
072621f
Merge branch 'main' into features/dotnet-upgrade
nvuillam Jul 31, 2022
14c527d
Update doc
nvuillam Jul 31, 2022
bfc1ba7
Adding .csproj files to sample_project_fixes
Jul 31, 2022
14d70b6
Added .sln info on linter_text property
Jul 31, 2022
ba6e914
Merge remote-tracking branch 'oxsecirity/features/dotnet-upgrade' int…
Jul 31, 2022
4433588
Updated linter URL and added {{WORKSPACE}} CLI arg
Jul 31, 2022
bec39b4
Unifying vb and csharp projects into one single solution
Jul 31, 2022
995e9df
Upgrade dotnet version on linter dockers
Jul 31, 2022
08e80ba
Really upgrade dotnet everywhere
nvuillam Jul 31, 2022
f8b92cc
Merge remote-tracking branch 'oxsecirity/features/dotnet-upgrade' int…
Aug 1, 2022
ff77273
Merge branch 'main' into features/dotnet-upgrade
nvuillam Aug 1, 2022
c96e1e9
Revert "Upgrade dotnet version on linter dockers"
Aug 1, 2022
dae34ab
Merge branch 'features/dotnet-upgrade' into features/dotnet-upgrade-p…
Aug 4, 2022
f751c73
Testing some Dockerfile configs
Aug 4, 2022
d84ae29
dotnet info
Aug 4, 2022
33c246b
Trying to figure out dotnet version running on each test case
Aug 5, 2022
f6d5342
Checking root's workspace
Aug 5, 2022
0bdb723
Checking for tool versions
Aug 5, 2022
0a855ab
Merge branch 'main' into features/dotnet-upgrade
nvuillam Aug 5, 2022
ec6c581
Merge branch 'features/dotnet-upgrade' into features/dotnet-upgrade-p…
Aug 13, 2022
be93ed6
Removing dotnet-format install from Docker images
Aug 13, 2022
fa059af
Updating linter versions and helps for dotnet-format
Aug 13, 2022
dea1008
Reverting pre_coomands and configuring new dotnet format params
Aug 13, 2022
c27e374
Forgot the "format" argument
Aug 13, 2022
ecd5cf0
Updating test reports
Aug 13, 2022
c01d946
Fixed ERROR paths
Aug 13, 2022
af93486
Merge branch 'main' into features/dotnet-upgrade
nvuillam Aug 15, 2022
4c32a7c
Merge branch 'features/dotnet-upgrade' into features/dotnet-upgrade-p…
Nov 6, 2022
37eca7c
Merge remote-tracking branch 'oxsecirity/main' into features/dotnet-u…
Nov 6, 2022
5bff146
Merge remote-tracking branch 'origin/main' into features/dotnet-upgra…
nvuillam Nov 24, 2022
e20508e
Undowngrade DevSkim version
nvuillam Nov 24, 2022
3d7d0fe
changelog
nvuillam Nov 24, 2022
fb40391
Remove version from DevSkim install line
nvuillam Nov 24, 2022
960d165
Update TSQLLint version
nvuillam Nov 24, 2022
2d9d566
fix dotnet format call
nvuillam Nov 24, 2022
92f57bc
Using relative paths for worksapces
Nov 26, 2022
4c26868
Detailed logging for debug
Nov 26, 2022
ae80122
Revert "Using relative paths for worksapces"
Nov 26, 2022
a38264f
Disabling list_of_files mode.
Nov 26, 2022
1210aa7
Reverting back to list_of_files
lextatic Nov 26, 2022
45402ec
Echoing linting command
lextatic Nov 27, 2022
d25dced
Checking workspace path
lextatic Nov 27, 2022
51288cc
Fixing descriptor parsing
lextatic Nov 27, 2022
8f1362d
Fix parse
lextatic Nov 27, 2022
d23c648
Trying to figure out why --include is failing
lextatic Nov 27, 2022
7f136ba
Testing the exact computed command manually
lextatic Nov 27, 2022
a6fa5d6
Testing relative paths
lextatic Nov 27, 2022
a754088
Checking file contnt before testing linter
lextatic Nov 27, 2022
6d9ba3a
Checking editorconfig contents
lextatic Nov 27, 2022
1320ac6
Adding editorconfigs to validate whitespaces.
lextatic Nov 27, 2022
cd30160
Re-enabling detailed logging
lextatic Nov 27, 2022
f457abc
Adding style error to csharp_bad_02.cs.
lextatic Nov 27, 2022
0082851
Testing whitespace formatting for vb only
lextatic Nov 27, 2022
4a85cdb
I don't know anymore
lextatic Nov 27, 2022
7d881e6
Fixed VB descriptor
lextatic Nov 28, 2022
86fe8ed
A few mroe tests with editorconfigs
lextatic Nov 29, 2022
677f1ef
Fixed pre-command syntax
lextatic Nov 29, 2022
02df457
Testing lint without --include parameter
lextatic Nov 30, 2022
1e93976
Trying several path styles
lextatic Nov 30, 2022
6adfc7a
Testing some different paths
lextatic Nov 30, 2022
e5603c2
Testing echo
lextatic Nov 30, 2022
912ae6b
More tests
lextatic Nov 30, 2022
dc97fd8
Checking versions
lextatic Dec 1, 2022
028dce9
Adding dotnet --info
lextatic Dec 1, 2022
a189a83
Upgrade to dotnet 7 and removed list_of_files
lextatic Dec 1, 2022
8ba59da
Revert some changes for --list-of-files
lextatic Dec 1, 2022
1e0944a
More experiments
lextatic Dec 2, 2022
b6e30f3
Ops
lextatic Dec 2, 2022
b220d13
Fixing malformed file
lextatic Dec 2, 2022
bd24fc0
Whoa, python sux
lextatic Dec 2, 2022
01c88dc
Change dotnet command
lextatic Dec 2, 2022
699d6ad
Updating reports for tests
lextatic Dec 2, 2022
1ec2fad
Success linters also format bad files
lextatic Dec 2, 2022
83d3277
Separating good and bad test projects
lextatic Dec 3, 2022
cc99469
Revert back to dotnet6
lextatic Dec 3, 2022
46a5a1a
Updated success report files
lextatic Dec 3, 2022
272def5
Merge remote-tracking branch 'oxsecirity/main' into features/dotnet-u…
lextatic Dec 3, 2022
e54901b
Removing unused import from DotnetFormatLinter.py
lextatic Dec 3, 2022
dc5d945
Merge remote-tracking branch 'oxsecirity/main' into features/dotnet-u…
lextatic Dec 10, 2022
4e5b040
Merge remote-tracking branch 'oxsecirity/main' into features/dotnet-u…
lextatic Jan 5, 2023
7630633
Upgrade to dotnet 7
lextatic Jan 5, 2023
7a8d094
Removing csharpier version specification from install cli
lextatic Jan 5, 2023
bde05c3
Revert "Upgrade to dotnet 7"
lextatic Jan 6, 2023
7f206ca
Updating changelog, removed 'list_of_files' for now
lextatic Jan 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .automation/test/csharp/csharp_bad_01.cs
Binary file not shown.
12 changes: 12 additions & 0 deletions .automation/test/csharp/csharp_bad_02.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace HelloWorld
{
class Program
{
static void Main (string[] args)
{
Console.WriteLine ("Hello World!");
}
}
}
12 changes: 12 additions & 0 deletions .automation/test/csharp/csharp_good_02.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
10 changes: 10 additions & 0 deletions .automation/test/csharp/csharp_project.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
31 changes: 31 additions & 0 deletions .automation/test/sample_project_fixes/dotnet_solution.sln
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>vb_projecty</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

</Project>
9 changes: 9 additions & 0 deletions .automation/test/vbdotnet/vb_projecty.vbproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>vb_projecty</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

</Project>
7 changes: 7 additions & 0 deletions .automation/test/vbdotnet/vbdotnet_bad_2.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Imports System

Public Module Hello
Public Sub Main( )
Console.WriteLine("hello, world"
End Sub
End Module
7 changes: 7 additions & 0 deletions .automation/test/vbdotnet/vbdotnet_good_2.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Imports System

Public Module Hello
Public Sub Main()
Console.WriteLine("hello, world")
End Sub
End Module
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-linter.yml file, or with `oxsecurity/megalinter:beta` docker image

- Upgrade to dotnet 6.0 + `list_of_files` for dotnet-format CLI lint mode to improve performances (requires `.csproj` or `.vbproj` in the repo)

- Linter versions upgrades
- [checkstyle](https://checkstyle.sourceforge.io) from 10.3.1 to **10.3.2** on 2022-08-01
- [flake8](https://flake8.pycqa.org) from 5.0.0 to **5.0.1** on 2022-08-01
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ RUN mkdir -p ${PWSH_DIRECTORY} \
# 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"

Expand Down Expand Up @@ -320,7 +320,7 @@ RUN curl -fLo coursier https://git.io/coursier-cli && \
# 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"

Expand Down Expand Up @@ -497,7 +497,7 @@ 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
Expand Down Expand Up @@ -555,7 +555,7 @@ RUN ML_THIRD_PARTY_DIR="/third-party/misspell" \
# 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 TSQLLint
Expand Down
6 changes: 3 additions & 3 deletions flavors/dotnet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ RUN mkdir -p ${PWSH_DIRECTORY} \
# 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"

Expand All @@ -204,7 +204,7 @@ ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet"
# 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"

Expand Down Expand Up @@ -309,7 +309,7 @@ RUN ML_THIRD_PARTY_DIR="/third-party/misspell" \
# 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 TSQLLint
Expand Down
2 changes: 1 addition & 1 deletion flavors/security/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ RUN ML_THIRD_PARTY_DIR="/third-party/kubeconform" \
# 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
Expand Down
2 changes: 1 addition & 1 deletion linters/csharp_dotnet_format/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ 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"

Expand Down
2 changes: 1 addition & 1 deletion linters/sql_tsqllint/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion linters/vbdotnet_dotnet_format/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ 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"

Expand Down
20 changes: 12 additions & 8 deletions megalinter/descriptors/csharp.megalinter-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,33 @@ 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
pre_commands: dotnet --info
lextatic marked this conversation as resolved.
Show resolved Hide resolved
cli_lint_mode: list_of_files
cli_lint_extra_args:
- "--folder"
- "--check"
- "{{WORKSPACE}}"
- "--verify-no-changes"
- "--exclude"
- "/"
- "--include"
cli_lint_fix_arg_name: "--megalinter-fix-flag" # Workaround for PythonBlackOrIsortLinter class behavior
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 --verify-no-changes --exclude / --include myfile.cs myfile2.cs"
- "dotnet-format --exclude / --include myfile.cs myfile2.cs" # Fix
install:
dockerfile:
- RUN /usr/share/dotnet/dotnet tool install -g dotnet-format
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ linters:
linter_rules_configuration_url: https://github.com/microsoft/DevSkim/wiki/Analyze-Command
linter_rules_ignore_config_url: https://github.com/microsoft/DevSkim/wiki/Analyze-Command
linter_image_url: https://github.com/microsoft/DevSkim/raw/main/media/devskim_logo.svg
pre_commands: dotnet --info
cli_lint_mode: project
cli_lint_extra_args:
- analyze
Expand Down Expand Up @@ -49,7 +50,7 @@ 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
ide:
Expand Down
3 changes: 2 additions & 1 deletion megalinter/descriptors/sql.megalinter-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ linters:
linter_rules_url: https://github.com/tsqllint/tsqllint#rule-configuration
linter_rules_configuration_url: https://github.com/tsqllint/tsqllint#rule-configuration
linter_rules_inline_disable_url: https://github.com/tsqllint/tsqllint#disabling-rules-with-inline-comments
pre_commands: dotnet --info
config_file_name: ".tsqllintrc"
cli_lint_mode: list_of_files
cli_config_arg_name: "--config"
Expand All @@ -81,7 +82,7 @@ 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 TSQLLint
ide:
Expand Down
18 changes: 11 additions & 7 deletions megalinter/descriptors/vbdotnet.megalinter-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,32 @@ 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_lint_mode: list_of_files
cli_lint_extra_args:
- "--folder"
- "--check"
- "{{WORKSPACE}}"
- "--verify-no-changes"
- "--exclude"
- "/"
- "--include"
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"
- "dotnet-format --verify-no-changes --exclude / --include myfile.vb myfile2.vb"
- "dotnet-format --exclude / --include myfile.vb myfile2.vb"
install:
dockerfile:
- RUN /usr/share/dotnet/dotnet tool install -g dotnet-format
23 changes: 17 additions & 6 deletions megalinter/linters/DotnetFormatLinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ class DotnetFormatLinter(Linter):

# Build the CLI command to call to lint a file
def build_lint_command(self, file=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",
'exit "${PIPESTATUS[0]}"',
]
if file is not None:
# cli_lint_mode = file
file = os.path.basename(file)
dotnet_format_command = " ".join(super().build_lint_command(file))
commands = [
f'cd "{os.path.realpath(os.path.dirname(file))}" || exit 1',
dotnet_format_command + " | tee /dev/tty2 2>&1",
'exit "${PIPESTATUS[0]}"',
]

else:
# cli_lint_mode = list_of_files or project
dotnet_format_command = " ".join(super().build_lint_command(None))
commands = [
dotnet_format_command + " | tee /dev/tty2 2>&1",
'exit "${PIPESTATUS[0]}"',
]
return " && ".join(commands)