mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:24 +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:
|
||||
""" Remove sampler
|
||||
Args:
|
||||
|
|
|
@ -251,7 +251,8 @@ pub(crate) fn indent(checker: &mut Checker, docstring: &Docstring) {
|
|||
let mut diagnostic =
|
||||
Diagnostic::new(OverIndentation, TextRange::empty(line.start()));
|
||||
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 {
|
||||
// Convert the character count to an offset within the source.
|
||||
let offset = checker
|
||||
|
|
|
@ -1,57 +1,75 @@
|
|||
---
|
||||
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:
|
||||
2 | """ Remove sampler
|
||||
3 | Args:
|
||||
1 | """
|
||||
2 | Author
|
||||
| D208
|
||||
4 | Returns:
|
||||
5 | """
|
||||
3 | """
|
||||
|
|
||||
= help: Remove over-indentation
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | class Platform:
|
||||
2 2 | """ Remove sampler
|
||||
3 |- Args:
|
||||
3 |+ Args:
|
||||
4 4 | Returns:
|
||||
5 5 | """
|
||||
1 1 | """
|
||||
2 |- Author
|
||||
2 |+Author
|
||||
3 3 | """
|
||||
4 4 |
|
||||
5 5 |
|
||||
|
||||
D208.py:4:1: D208 [*] Docstring is over-indented
|
||||
|
|
||||
2 | """ Remove sampler
|
||||
3 | Args:
|
||||
4 | Returns:
|
||||
| D208
|
||||
5 | """
|
||||
|
|
||||
= help: Remove over-indentation
|
||||
D208.py:8:1: D208 [*] Docstring is over-indented
|
||||
|
|
||||
6 | class Platform:
|
||||
7 | """ Remove sampler
|
||||
8 | Args:
|
||||
| D208
|
||||
9 | Returns:
|
||||
10 | """
|
||||
|
|
||||
= help: Remove over-indentation
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | class Platform:
|
||||
2 2 | """ Remove sampler
|
||||
3 3 | Args:
|
||||
4 |- Returns:
|
||||
4 |+ Returns:
|
||||
5 5 | """
|
||||
5 5 |
|
||||
6 6 | class Platform:
|
||||
7 7 | """ Remove sampler
|
||||
8 |- Args:
|
||||
8 |+ Args:
|
||||
9 9 | Returns:
|
||||
10 10 | """
|
||||
|
||||
D208.py:5:1: D208 [*] Docstring is over-indented
|
||||
|
|
||||
3 | Args:
|
||||
4 | Returns:
|
||||
5 | """
|
||||
| D208
|
||||
|
|
||||
= help: Remove over-indentation
|
||||
D208.py:9:1: D208 [*] Docstring is over-indented
|
||||
|
|
||||
7 | """ Remove sampler
|
||||
8 | Args:
|
||||
9 | Returns:
|
||||
| D208
|
||||
10 | """
|
||||
|
|
||||
= help: Remove over-indentation
|
||||
|
||||
ℹ Safe fix
|
||||
2 2 | """ Remove sampler
|
||||
3 3 | Args:
|
||||
4 4 | Returns:
|
||||
5 |- """
|
||||
5 |+ """
|
||||
6 6 | class Platform:
|
||||
7 7 | """ Remove sampler
|
||||
8 8 | Args:
|
||||
9 |- Returns:
|
||||
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