mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:45:24 +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>>,
|
pub fixable: Option<Vec<RuleSelector>>,
|
||||||
#[option(
|
#[option(
|
||||||
default = r#""text""#,
|
default = r#""text""#,
|
||||||
value_type = r#""text" | "json" | "junit" | "github" | "gitlab" | "pylint""#,
|
value_type = r#""text" | "json" | "junit" | "github" | "gitlab" | "pylint" | "azure""#,
|
||||||
example = r#"
|
example = r#"
|
||||||
# Group violations by containing file.
|
# Group violations by containing file.
|
||||||
format = "grouped"
|
format = "grouped"
|
||||||
|
@ -203,8 +203,8 @@ pub struct Options {
|
||||||
/// The style in which violation messages should be formatted: `"text"`
|
/// The style in which violation messages should be formatted: `"text"`
|
||||||
/// (default), `"grouped"` (group messages by file), `"json"`
|
/// (default), `"grouped"` (group messages by file), `"json"`
|
||||||
/// (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub
|
/// (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub
|
||||||
/// Actions annotations), `"gitlab"` (GitLab CI code quality report), or
|
/// Actions annotations), `"gitlab"` (GitLab CI code quality report),
|
||||||
/// `"pylint"` (Pylint text format).
|
/// `"pylint"` (Pylint text format) or `"azure"` (Azure Pipeline logging commands).
|
||||||
pub format: Option<SerializationFormat>,
|
pub format: Option<SerializationFormat>,
|
||||||
#[option(
|
#[option(
|
||||||
default = r#"false"#,
|
default = r#"false"#,
|
||||||
|
|
|
@ -216,6 +216,7 @@ pub enum SerializationFormat {
|
||||||
Github,
|
Github,
|
||||||
Gitlab,
|
Gitlab,
|
||||||
Pylint,
|
Pylint,
|
||||||
|
Azure,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SerializationFormat {
|
impl Default for SerializationFormat {
|
||||||
|
|
|
@ -374,6 +374,33 @@ impl Printer {
|
||||||
writeln!(stdout, "{label}")?;
|
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()?;
|
stdout.flush()?;
|
||||||
|
|
|
@ -209,7 +209,7 @@ Options:
|
||||||
--ignore-noqa
|
--ignore-noqa
|
||||||
Ignore any `# noqa` comments
|
Ignore any `# noqa` comments
|
||||||
--format <FORMAT>
|
--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>
|
--target-version <TARGET_VERSION>
|
||||||
The minimum Python version that should be supported
|
The minimum Python version that should be supported
|
||||||
--config <CONFIG>
|
--config <CONFIG>
|
||||||
|
|
5
ruff.schema.json
generated
5
ruff.schema.json
generated
|
@ -272,7 +272,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"format": {
|
"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": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/SerializationFormat"
|
"$ref": "#/definitions/SerializationFormat"
|
||||||
|
@ -2178,7 +2178,8 @@
|
||||||
"grouped",
|
"grouped",
|
||||||
"github",
|
"github",
|
||||||
"gitlab",
|
"gitlab",
|
||||||
"pylint"
|
"pylint",
|
||||||
|
"azure"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Strictness": {
|
"Strictness": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue