mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 18:02:23 +00:00
Add Fix::applicability
to JSON output (#4341)
This commit is contained in:
parent
04097d194c
commit
ddbe5a1243
4 changed files with 7 additions and 4 deletions
|
@ -39,8 +39,9 @@ impl Serialize for ExpandedMessages<'_> {
|
|||
|
||||
let fix = message.fix.as_ref().map(|fix| {
|
||||
json!({
|
||||
"message": message.kind.suggestion.as_deref(),
|
||||
"edits": &ExpandedEdits { edits: fix.edits(), source_code: &source_code },
|
||||
"applicability": fix.applicability(),
|
||||
"message": message.kind.suggestion.as_deref(),
|
||||
"edits": &ExpandedEdits { edits: fix.edits(), source_code: &source_code },
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
@ -189,14 +189,13 @@ def fibonacci(n):
|
|||
|
||||
let fib_source = SourceFileBuilder::new("fib.py", fib).finish();
|
||||
|
||||
#[allow(deprecated)]
|
||||
let unused_variable = Diagnostic::new(
|
||||
UnusedVariable {
|
||||
name: "x".to_string(),
|
||||
},
|
||||
TextRange::new(TextSize::from(94), TextSize::from(95)),
|
||||
)
|
||||
.with_fix(Fix::unspecified(Edit::deletion(
|
||||
.with_fix(Fix::suggested(Edit::deletion(
|
||||
TextSize::from(94),
|
||||
TextSize::from(99),
|
||||
)));
|
||||
|
|
|
@ -7,6 +7,7 @@ expression: content
|
|||
"code": "F401",
|
||||
"message": "`os` imported but unused",
|
||||
"fix": {
|
||||
"applicability": "Suggested",
|
||||
"message": "Remove unused import: `os`",
|
||||
"edits": [
|
||||
{
|
||||
|
@ -37,6 +38,7 @@ expression: content
|
|||
"code": "F841",
|
||||
"message": "Local variable `x` is assigned to but never used",
|
||||
"fix": {
|
||||
"applicability": "Suggested",
|
||||
"message": "Remove assignment to unused variable `x`",
|
||||
"edits": [
|
||||
{
|
||||
|
|
|
@ -93,6 +93,7 @@ fn test_stdin_json() -> Result<()> {
|
|||
"code": "F401",
|
||||
"message": "`os` imported but unused",
|
||||
"fix": {{
|
||||
"applicability": "Unspecified",
|
||||
"message": "Remove unused import: `os`",
|
||||
"edits": [
|
||||
{{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue