9
dotnet-format - MegaLinter by OX Security
source link: https://oxsecurity.github.io/megalinter/latest/descriptors/csharp_dotnet_format/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
dotnet-format
dotnet-format documentation
- Version in MegaLinter: 000
- Visit Official Web Site
Configuration in MegaLinter
- Enable dotnet-format by adding
CSHARP_DOTNET_FORMAT
in ENABLE_LINTERS variable - Disable dotnet-format by adding
CSHARP_DOTNET_FORMAT
in DISABLE_LINTERS variable
- Enable auto-fixes by adding
CSHARP_DOTNET_FORMAT
in APPLY_FIXES variable
Variable | Description | Default value |
---|---|---|
CSHARP_DOTNET_FORMAT_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
CSHARP_DOTNET_FORMAT_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
CSHARP_DOTNET_FORMAT_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
CSHARP_DOTNET_FORMAT_CLI_LINT_MODE | Override default CLI lint mode - file : Calls the linter for each file- list_of_files : Call the linter with the list of files as argument- project : Call the linter from the root of the project |
file |
CSHARP_DOTNET_FORMAT_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".cs"] |
CSHARP_DOTNET_FORMAT_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
Include every file |
CSHARP_DOTNET_FORMAT_PRE_COMMANDS | List of bash commands to run before the linter | None |
CSHARP_DOTNET_FORMAT_POST_COMMANDS | List of bash commands to run after the linter | None |
CSHARP_DOTNET_FORMAT_DISABLE_ERRORS | Run linter but consider errors as warnings | true |
CSHARP_DOTNET_FORMAT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
MegaLinter Flavours
This linter is available in the following flavours
Behind the scenes
How are identified applicable files
- File extensions:
.cs
How the linting is performed
- dotnet-format is called one time by identified file
Example calls
dotnet-format --folder --check --exclude / --include myfile.cs
dotnet-format --folder --exclude / --include myfile.cs
Help content
dotnet-format
dotnet-format
Usage:
dotnet-format [options] [<workspace>]
Arguments:
<workspace> 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: ]
Options:
--no-restore Doesn't execute an implicit restore before formatting.
-f, --folder Whether to treat the `<workspace>` argument as a simple folder of files.
-w, --fix-whitespace Run whitespace formatting. Run by default when not applying fixes.
-s, --fix-style <error|info|warn> Run code style analyzers and apply fixes.
-a, --fix-analyzers <error|info|warn> Run 3rd party analyzers and apply fixes.
--diagnostics <diagnostics> A space separated list of diagnostic ids to use as a filter when fixing code style or 3rd party issues. [default: ]
--include <include> A list of relative file or folder paths to include in formatting. All files are formatted if empty. [default: ]
--exclude <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 <report-path> Accepts a file path, which if provided, will produce a json report in the given directory.
-v, --verbosity <d|detailed|diag|diagnostic|m|minimal|n|normal|q|quiet> Set the verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]
--binarylog <binary-log-path> Log all project or solution load information to a binary log file.
--version Show version information
-?, -h, --help Show help and usage information
Installation on mega-linter Docker image
- Dockerfile commands :
# Parent descriptor 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
ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet"
# Linter install
RUN /usr/share/dotnet/dotnet tool install -g dotnet-format
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK