mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00
Add Azure Devops as a -format
option. (#3335)
This commit is contained in:
parent
5d8591fec4
commit
30c71dc59a
5 changed files with 35 additions and 6 deletions
|
@ -194,7 +194,7 @@ pub struct Options {
|
|||
pub fixable: Option<Vec<RuleSelector>>,
|
||||
#[option(
|
||||
default = r#""text""#,
|
||||
value_type = r#""text" | "json" | "junit" | "github" | "gitlab" | "pylint""#,
|
||||
value_type = r#""text" | "json" | "junit" | "github" | "gitlab" | "pylint" | "azure""#,
|
||||
example = r#"
|
||||
# Group violations by containing file.
|
||||
format = "grouped"
|
||||
|
@ -203,8 +203,8 @@ pub struct Options {
|
|||
/// The style in which violation messages should be formatted: `"text"`
|
||||
/// (default), `"grouped"` (group messages by file), `"json"`
|
||||
/// (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub
|
||||
/// Actions annotations), `"gitlab"` (GitLab CI code quality report), or
|
||||
/// `"pylint"` (Pylint text format).
|
||||
/// Actions annotations), `"gitlab"` (GitLab CI code quality report),
|
||||
/// `"pylint"` (Pylint text format) or `"azure"` (Azure Pipeline logging commands).
|
||||
pub format: Option<SerializationFormat>,
|
||||
#[option(
|
||||
default = r#"false"#,
|
||||
|
|
|
@ -216,6 +216,7 @@ pub enum SerializationFormat {
|
|||
Github,
|
||||
Gitlab,
|
||||
Pylint,
|
||||
Azure,
|
||||
}
|
||||
|
||||
impl Default for SerializationFormat {
|
||||
|
|
|
@ -374,6 +374,33 @@ impl Printer {
|
|||
writeln!(stdout, "{label}")?;
|
||||
}
|
||||
}
|
||||
SerializationFormat::Azure => {
|
||||
// Generate error logging commands for Azure Pipelines format.
|
||||
// See https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#logissue-log-an-error-or-warning
|
||||
for message in &diagnostics.messages {
|
||||
let label = format!(
|
||||
"{}{}{}{}{}{} {} {}",
|
||||
relativize_path(Path::new(&message.filename)),
|
||||
":",
|
||||
message.location.row(),
|
||||
":",
|
||||
message.location.column(),
|
||||
":",
|
||||
message.kind.rule().noqa_code(),
|
||||
message.kind.body(),
|
||||
);
|
||||
writeln!(
|
||||
stdout,
|
||||
"##vso[task.logissue type=error\
|
||||
;sourcepath={};linenumber={};columnnumber={};code={};]{}",
|
||||
message.filename,
|
||||
message.location.row(),
|
||||
message.location.column(),
|
||||
message.kind.rule().noqa_code(),
|
||||
label,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stdout.flush()?;
|
||||
|
|
|
@ -209,7 +209,7 @@ Options:
|
|||
--ignore-noqa
|
||||
Ignore any `# noqa` comments
|
||||
--format <FORMAT>
|
||||
Output serialization format for violations [env: RUFF_FORMAT=] [possible values: text, json, junit, grouped, github, gitlab, pylint]
|
||||
Output serialization format for violations [env: RUFF_FORMAT=] [possible values: text, json, junit, grouped, github, gitlab, pylint, azure]
|
||||
--target-version <TARGET_VERSION>
|
||||
The minimum Python version that should be supported
|
||||
--config <CONFIG>
|
||||
|
|
5
ruff.schema.json
generated
5
ruff.schema.json
generated
|
@ -272,7 +272,7 @@
|
|||
]
|
||||
},
|
||||
"format": {
|
||||
"description": "The style in which violation messages should be formatted: `\"text\"` (default), `\"grouped\"` (group messages by file), `\"json\"` (machine-readable), `\"junit\"` (machine-readable XML), `\"github\"` (GitHub Actions annotations), `\"gitlab\"` (GitLab CI code quality report), or `\"pylint\"` (Pylint text format).",
|
||||
"description": "The style in which violation messages should be formatted: `\"text\"` (default), `\"grouped\"` (group messages by file), `\"json\"` (machine-readable), `\"junit\"` (machine-readable XML), `\"github\"` (GitHub Actions annotations), `\"gitlab\"` (GitLab CI code quality report), `\"pylint\"` (Pylint text format) or `\"azure\"` (Azure Pipeline logging commands).",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/SerializationFormat"
|
||||
|
@ -2178,7 +2178,8 @@
|
|||
"grouped",
|
||||
"github",
|
||||
"gitlab",
|
||||
"pylint"
|
||||
"pylint",
|
||||
"azure"
|
||||
]
|
||||
},
|
||||
"Strictness": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue