Skip to content

Commit 097ff87

Browse files
committed
Tweak rule documentation
1 parent 2624249 commit 097ff87

File tree

56 files changed

+162
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+162
-96
lines changed

crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl Violation for MissingReturnTypeClassMethod {
469469
/// ```
470470
///
471471
/// ## References
472-
/// - [PEP 484](https://www.python.org/dev/peps/pep-0484/#the-any-type)
472+
/// - [PEP 484: The `Any` type](https://peps.python.org/pep-0484/#the-any-type)
473473
/// - [Python documentation: `typing.Any`](https://docs.python.org/3/library/typing.html#typing.Any)
474474
/// - [Mypy documentation: The Any type](https://mypy.readthedocs.io/en/stable/kinds_of_types.html#the-any-type)
475475
#[violation]

crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_imports.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@ use crate::checkers::ast::Checker;
1010
use crate::registry::AsRule;
1111

1212
/// ## What it does
13-
/// Checks for imports of the`telnetlib` module.
13+
/// Checks for imports of the `telnetlib` module.
1414
///
1515
/// ## Why is this bad?
16-
/// Telnet is considered insecure. Instead, use SSH or another encrypted
16+
/// Telnet is considered insecure. It is deprecated since version 3.11, and
17+
/// will be removed in version 3.13. Instead, use SSH or another encrypted
1718
/// protocol.
1819
///
1920
/// ## Example
2021
/// ```python
2122
/// import telnetlib
2223
/// ```
24+
///
25+
/// ## References
26+
/// - [Python documentation: `telnetlib` - Telnet client](https://docs.python.org/3.12/library/telnetlib.html#module-telnetlib)
27+
/// - [PEP 594: `telnetlib`](https://peps.python.org/pep-0594/#telnetlib)
2328
#[violation]
2429
pub struct SuspiciousTelnetlibImport;
2530

@@ -41,6 +46,9 @@ impl Violation for SuspiciousTelnetlibImport {
4146
/// ```python
4247
/// import ftplib
4348
/// ```
49+
///
50+
/// ## References
51+
/// - [Python documentation: `ftplib` - FTP protocol client](https://docs.python.org/3/library/ftplib.html)
4452
#[violation]
4553
pub struct SuspiciousFtplibImport;
4654

@@ -63,8 +71,9 @@ impl Violation for SuspiciousFtplibImport {
6371
/// ```python
6472
/// import pickle
6573
/// ```
74+
///
6675
/// ## References
67-
/// - [Python Docs](https://docs.python.org/3/library/pickle.html)
76+
/// - [Python documentation: `pickle` — Python object serialization](https://docs.python.org/3/library/pickle.html)
6877
#[violation]
6978
pub struct SuspiciousPickleImport;
7079

crates/ruff_linter/src/rules/flake8_blind_except/rules/blind_except.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use crate::checkers::ast::Checker;
6060
/// ## References
6161
/// - [Python documentation: The `try` statement](https://docs.python.org/3/reference/compound_stmts.html#the-try-statement)
6262
/// - [Python documentation: Exception hierarchy](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)
63-
/// - [PEP8 Programming Recommendations on bare `except`](https://peps.python.org/pep-0008/#programming-recommendations)
63+
/// - [PEP 8: Programming Recommendations on bare `except`](https://peps.python.org/pep-0008/#programming-recommendations)
6464
#[violation]
6565
pub struct BlindExcept {
6666
name: String,

crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Violation for AbstractBaseClassWithoutAbstractMethod {
8888
/// ```
8989
///
9090
/// ## References
91-
/// - [Python documentation: abc](https://docs.python.org/3/library/abc.html)
91+
/// - [Python documentation: `abc`](https://docs.python.org/3/library/abc.html)
9292
#[violation]
9393
pub struct EmptyMethodWithoutAbstractDecorator {
9494
name: String,

crates/ruff_linter/src/rules/flake8_bugbear/rules/f_string_docstring.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::checkers::ast::Checker;
2828
/// ```
2929
///
3030
/// ## References
31-
/// - [PEP 257](https://peps.python.org/pep-0257/)
31+
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
3232
/// - [Python documentation: Formatted string literals](https://docs.python.org/3/reference/lexical_analysis.html#f-strings)
3333
#[violation]
3434
pub struct FStringDocstring;

crates/ruff_linter/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use crate::checkers::ast::Checker;
4040
///
4141
/// ## References
4242
/// - [The Hitchhiker's Guide to Python: Late Binding Closures](https://docs.python-guide.org/writing/gotchas/#late-binding-closures)
43-
/// - [Python documentation: functools.partial](https://docs.python.org/3/library/functools.html#functools.partial)
43+
/// - [Python documentation: `functools.partial`](https://docs.python.org/3/library/functools.html#functools.partial)
4444
#[violation]
4545
pub struct FunctionUsesLoopVariable {
4646
name: String,

crates/ruff_linter/src/rules/flake8_bugbear/rules/getattr_with_constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::fix::edits::pad;
1414
///
1515
/// ## Why is this bad?
1616
/// `getattr` is used to access attributes dynamically. If the attribute is
17-
/// defined as a constant, it is no safer than a typical property access. When
17+
/// defined as a constant, it is not safer than a typical property access. When
1818
/// possible, prefer property access over `getattr` calls, as the former is
1919
/// more concise and idiomatic.
2020
///

crates/ruff_linter/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ use crate::checkers::ast::Checker;
2626
/// ```python
2727
/// warnings.warn("This is a warning", stacklevel=2)
2828
/// ```
29+
///
30+
/// ## References
31+
/// - [Python documentation: `warnings.warn`](https://docs.python.org/3/library/warnings.html#warnings.warn)
2932
#[violation]
3033
pub struct NoExplicitStacklevel;
3134

crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::checkers::ast::Checker;
3535
/// ```
3636
///
3737
/// ## References
38-
/// - [Python documentation: contextlib.suppress](https://docs.python.org/3/library/contextlib.html#contextlib.suppress)
38+
/// - [Python documentation: `contextlib.suppress`](https://docs.python.org/3/library/contextlib.html#contextlib.suppress)
3939
#[violation]
4040
pub struct UselessContextlibSuppress;
4141

crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_dict_comprehension_for_iterable.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ use crate::checkers::ast::Checker;
3030
/// dict.fromkeys(iterable)
3131
/// dict.fromkeys(iterable, 1)
3232
/// ```
33+
///
34+
/// ## References
35+
/// - [Python documentation: `dict.fromkeys`](https://docs.python.org/3/library/stdtypes.html#dict.fromkeys)
3336
#[violation]
3437
pub struct UnnecessaryDictComprehensionForIterable {
3538
is_value_none_literal: bool,
@@ -53,7 +56,7 @@ impl Violation for UnnecessaryDictComprehensionForIterable {
5356
}
5457
}
5558

56-
/// RUF025
59+
/// C420
5760
pub(crate) fn unnecessary_dict_comprehension_for_iterable(
5861
checker: &mut Checker,
5962
dict_comp: &ast::ExprDictComp,

0 commit comments

Comments
 (0)