Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix start >= end error in over-indentation #8982

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pydocstyle/D208.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
Author
"""


class Platform:
""" Remove sampler
Args:
Expand Down
3 changes: 2 additions & 1 deletion crates/ruff_linter/src/rules/pydocstyle/rules/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 | """

D208.py:4:1: D208 [*] Docstring is over-indented
|
2 | """ Remove sampler
3 | Args:
4 |     Returns:
| D208
5 | """
|
= help: Remove over-indentation
1 1 | """
2 |- Author
2 |+Author
3 3 | """
4 4 |
5 5 |

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 | """

D208.py:5:1: D208 [*] Docstring is over-indented
|
3 | Args:
4 |     Returns:
5 | """
| D208
|
= help: Remove over-indentation
5 5 |
6 6 | class Platform:
7 7 | """ Remove sampler
8 |- Args:
8 |+ Args:
9 9 |     Returns:
10 10 | """

D208.py:9:1: D208 [*] Docstring is over-indented
|
7 | """ Remove sampler
8 | Args:
9 |     Returns:
| D208
10 | """
|
= help: Remove over-indentation

ℹ Safe fix
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
2 2 | """ Remove sampler
3 3 | Args:
4 4 |     Returns:
5 |- """
5 |+ """
7 7 | """ Remove sampler
8 8 | Args:
9 9 |     Returns:
10 |- """
10 |+ """


Loading