mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:41:23 +00:00
Fix start >= end error in over-indentation (#8982)
Closes https://github.com/astral-sh/ruff/issues/8977.
This commit is contained in:
parent
17c8817695
commit
b358cbf398
3 changed files with 65 additions and 41 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
"""
|
||||||
|
Author
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Platform:
|
class Platform:
|
||||||
""" Remove sampler
|
""" Remove sampler
|
||||||
Args:
|
Args:
|
||||||
|
|
|
@ -251,7 +251,8 @@ pub(crate) fn indent(checker: &mut Checker, docstring: &Docstring) {
|
||||||
let mut diagnostic =
|
let mut diagnostic =
|
||||||
Diagnostic::new(OverIndentation, TextRange::empty(line.start()));
|
Diagnostic::new(OverIndentation, TextRange::empty(line.start()));
|
||||||
let edit = if indent.is_empty() {
|
let edit = if indent.is_empty() {
|
||||||
Edit::deletion(line.start(), line_indent.text_len())
|
// Delete the entire indent.
|
||||||
|
Edit::range_deletion(TextRange::at(line.start(), line_indent.text_len()))
|
||||||
} else {
|
} else {
|
||||||
// Convert the character count to an offset within the source.
|
// Convert the character count to an offset within the source.
|
||||||
let offset = checker
|
let offset = checker
|
||||||
|
|
|
@ -1,57 +1,75 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs
|
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs
|
||||||
---
|
---
|
||||||
D208.py:3:1: D208 [*] Docstring is over-indented
|
D208.py:2:1: D208 [*] Docstring is over-indented
|
||||||
|
|
|
|
||||||
1 | class Platform:
|
1 | """
|
||||||
2 | """ Remove sampler
|
2 | Author
|
||||||
3 | Args:
|
|
||||||
| D208
|
| D208
|
||||||
4 | Returns:
|
3 | """
|
||||||
5 | """
|
|
||||||
|
|
|
|
||||||
= help: Remove over-indentation
|
= help: Remove over-indentation
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
1 1 | class Platform:
|
1 1 | """
|
||||||
2 2 | """ Remove sampler
|
2 |- Author
|
||||||
3 |- Args:
|
2 |+Author
|
||||||
3 |+ Args:
|
3 3 | """
|
||||||
4 4 | Returns:
|
4 4 |
|
||||||
5 5 | """
|
5 5 |
|
||||||
|
|
||||||
D208.py:4:1: D208 [*] Docstring is over-indented
|
D208.py:8:1: D208 [*] Docstring is over-indented
|
||||||
|
|
|
|
||||||
2 | """ Remove sampler
|
6 | class Platform:
|
||||||
3 | Args:
|
7 | """ Remove sampler
|
||||||
4 | Returns:
|
8 | Args:
|
||||||
| D208
|
| D208
|
||||||
5 | """
|
9 | Returns:
|
||||||
|
|
10 | """
|
||||||
= help: Remove over-indentation
|
|
|
||||||
|
= help: Remove over-indentation
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
1 1 | class Platform:
|
5 5 |
|
||||||
2 2 | """ Remove sampler
|
6 6 | class Platform:
|
||||||
3 3 | Args:
|
7 7 | """ Remove sampler
|
||||||
4 |- Returns:
|
8 |- Args:
|
||||||
4 |+ Returns:
|
8 |+ Args:
|
||||||
5 5 | """
|
9 9 | Returns:
|
||||||
|
10 10 | """
|
||||||
|
|
||||||
D208.py:5:1: D208 [*] Docstring is over-indented
|
D208.py:9:1: D208 [*] Docstring is over-indented
|
||||||
|
|
|
|
||||||
3 | Args:
|
7 | """ Remove sampler
|
||||||
4 | Returns:
|
8 | Args:
|
||||||
5 | """
|
9 | Returns:
|
||||||
| D208
|
| D208
|
||||||
|
|
10 | """
|
||||||
= help: Remove over-indentation
|
|
|
||||||
|
= help: Remove over-indentation
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
2 2 | """ Remove sampler
|
6 6 | class Platform:
|
||||||
3 3 | Args:
|
7 7 | """ Remove sampler
|
||||||
4 4 | Returns:
|
8 8 | Args:
|
||||||
5 |- """
|
9 |- Returns:
|
||||||
5 |+ """
|
9 |+ Returns:
|
||||||
|
10 10 | """
|
||||||
|
|
||||||
|
D208.py:10:1: D208 [*] Docstring is over-indented
|
||||||
|
|
|
||||||
|
8 | Args:
|
||||||
|
9 | Returns:
|
||||||
|
10 | """
|
||||||
|
| D208
|
||||||
|
|
|
||||||
|
= help: Remove over-indentation
|
||||||
|
|
||||||
|
ℹ Safe fix
|
||||||
|
7 7 | """ Remove sampler
|
||||||
|
8 8 | Args:
|
||||||
|
9 9 | Returns:
|
||||||
|
10 |- """
|
||||||
|
10 |+ """
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue