mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +00:00
Use a derive macro for Violations (#14557)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
6fd10e2fe7
commit
14ba469fc0
629 changed files with 2555 additions and 2562 deletions
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -41,8 +41,8 @@ use crate::docstrings::Docstring;
|
|||
/// ## References
|
||||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [Python documentation: String and Bytes literals](https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals)
|
||||
#[violation]
|
||||
pub struct EscapeSequenceInDocstring;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct EscapeSequenceInDocstring;
|
||||
|
||||
impl Violation for EscapeSequenceInDocstring {
|
||||
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines};
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
|
@ -40,8 +40,8 @@ use crate::docstrings::Docstring;
|
|||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
#[violation]
|
||||
pub struct BlankLineAfterSummary {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct BlankLineAfterSummary {
|
||||
num_lines: usize,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_trivia::{indentation_at_offset, PythonWhitespace};
|
||||
use ruff_source_file::{Line, LineRanges, UniversalNewlineIterator};
|
||||
use ruff_text_size::Ranged;
|
||||
|
@ -42,8 +42,8 @@ use crate::registry::Rule;
|
|||
/// - `lint.pydocstyle.convention`
|
||||
///
|
||||
/// [D211]: https://docs.astral.sh/ruff/rules/blank-line-before-class
|
||||
#[violation]
|
||||
pub struct OneBlankLineBeforeClass;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct OneBlankLineBeforeClass;
|
||||
|
||||
impl AlwaysFixableViolation for OneBlankLineBeforeClass {
|
||||
#[derive_message_formats]
|
||||
|
@ -94,8 +94,8 @@ impl AlwaysFixableViolation for OneBlankLineBeforeClass {
|
|||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
#[violation]
|
||||
pub struct OneBlankLineAfterClass;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct OneBlankLineAfterClass;
|
||||
|
||||
impl AlwaysFixableViolation for OneBlankLineAfterClass {
|
||||
#[derive_message_formats]
|
||||
|
@ -141,8 +141,8 @@ impl AlwaysFixableViolation for OneBlankLineAfterClass {
|
|||
/// - `lint.pydocstyle.convention`
|
||||
///
|
||||
/// [D203]: https://docs.astral.sh/ruff/rules/one-blank-line-before-class
|
||||
#[violation]
|
||||
pub struct BlankLineBeforeClass;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct BlankLineBeforeClass;
|
||||
|
||||
impl AlwaysFixableViolation for BlankLineBeforeClass {
|
||||
#[derive_message_formats]
|
||||
|
|
|
@ -2,7 +2,7 @@ use regex::Regex;
|
|||
use std::sync::LazyLock;
|
||||
|
||||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_trivia::PythonWhitespace;
|
||||
use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines};
|
||||
use ruff_text_size::Ranged;
|
||||
|
@ -37,8 +37,8 @@ use crate::registry::Rule;
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct NoBlankLineBeforeFunction {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct NoBlankLineBeforeFunction {
|
||||
num_lines: usize,
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,8 @@ impl AlwaysFixableViolation for NoBlankLineBeforeFunction {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct NoBlankLineAfterFunction {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct NoBlankLineAfterFunction {
|
||||
num_lines: usize,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_text_size::Ranged;
|
||||
use ruff_text_size::{TextLen, TextRange};
|
||||
|
||||
|
@ -29,8 +29,8 @@ use crate::docstrings::Docstring;
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct FirstLineCapitalized {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct FirstLineCapitalized {
|
||||
first_word: String,
|
||||
capitalized_word: String,
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use ruff_text_size::TextLen;
|
|||
use strum::IntoEnumIterator;
|
||||
|
||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines};
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
|
@ -44,8 +44,8 @@ use crate::rules::pydocstyle::helpers::logical_line;
|
|||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
#[violation]
|
||||
pub struct EndsInPeriod;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct EndsInPeriod;
|
||||
|
||||
impl Violation for EndsInPeriod {
|
||||
/// `None` in the case a fix is never available or otherwise Some
|
||||
|
|
|
@ -2,7 +2,7 @@ use ruff_text_size::TextLen;
|
|||
use strum::IntoEnumIterator;
|
||||
|
||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines};
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
|
@ -43,8 +43,8 @@ use crate::rules::pydocstyle::helpers::logical_line;
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct EndsInPunctuation;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct EndsInPunctuation;
|
||||
|
||||
impl Violation for EndsInPunctuation {
|
||||
/// `None` in the case a fix is never available or otherwise Some
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_ast::identifier::Identifier;
|
||||
use ruff_python_semantic::analyze::visibility::is_overload;
|
||||
|
||||
|
@ -66,8 +66,8 @@ use crate::docstrings::Docstring;
|
|||
/// ## References
|
||||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [Python documentation: `typing.overload`](https://docs.python.org/3/library/typing.html#typing.overload)
|
||||
#[violation]
|
||||
pub struct OverloadWithDocstring;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct OverloadWithDocstring;
|
||||
|
||||
impl Violation for OverloadWithDocstring {
|
||||
#[derive_message_formats]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruff_diagnostics::{AlwaysFixableViolation, Violation};
|
||||
use ruff_diagnostics::{Diagnostic, Edit, Fix};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_ast::docstrings::{clean_space, leading_space};
|
||||
use ruff_source_file::{Line, NewlineWithTrailingNewline};
|
||||
use ruff_text_size::{Ranged, TextSize};
|
||||
|
@ -10,6 +10,7 @@ use crate::checkers::ast::Checker;
|
|||
use crate::docstrings::Docstring;
|
||||
use crate::registry::Rule;
|
||||
|
||||
#[allow(clippy::tabs_in_doc_comments)]
|
||||
/// ## What it does
|
||||
/// Checks for docstrings that are indented with tabs.
|
||||
///
|
||||
|
@ -50,8 +51,8 @@ use crate::registry::Rule;
|
|||
///
|
||||
/// [PEP 8]: https://peps.python.org/pep-0008/#tabs-or-spaces
|
||||
/// [formatter]: https://docs.astral.sh/ruff/formatter
|
||||
#[violation]
|
||||
pub struct IndentWithSpaces;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct IndentWithSpaces;
|
||||
|
||||
impl Violation for IndentWithSpaces {
|
||||
#[derive_message_formats]
|
||||
|
@ -98,8 +99,8 @@ impl Violation for IndentWithSpaces {
|
|||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
/// [formatter]: https://docs.astral.sh/ruff/formatter/
|
||||
#[violation]
|
||||
pub struct UnderIndentation;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UnderIndentation;
|
||||
|
||||
impl AlwaysFixableViolation for UnderIndentation {
|
||||
#[derive_message_formats]
|
||||
|
@ -150,8 +151,8 @@ impl AlwaysFixableViolation for UnderIndentation {
|
|||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
/// [formatter]:https://docs.astral.sh/ruff/formatter/
|
||||
#[violation]
|
||||
pub struct OverIndentation;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct OverIndentation;
|
||||
|
||||
impl AlwaysFixableViolation for OverIndentation {
|
||||
#[derive_message_formats]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_ast::str::{is_triple_quote, leading_quote};
|
||||
use ruff_python_semantic::Definition;
|
||||
use ruff_source_file::{LineRanges, NewlineWithTrailingNewline, UniversalNewlineIterator};
|
||||
|
@ -58,8 +58,8 @@ use crate::registry::Rule;
|
|||
///
|
||||
/// [D213]: https://docs.astral.sh/ruff/rules/multi-line-summary-second-line
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257
|
||||
#[violation]
|
||||
pub struct MultiLineSummaryFirstLine;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct MultiLineSummaryFirstLine;
|
||||
|
||||
impl AlwaysFixableViolation for MultiLineSummaryFirstLine {
|
||||
#[derive_message_formats]
|
||||
|
@ -121,8 +121,8 @@ impl AlwaysFixableViolation for MultiLineSummaryFirstLine {
|
|||
///
|
||||
/// [D212]: https://docs.astral.sh/ruff/rules/multi-line-summary-first-line
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257
|
||||
#[violation]
|
||||
pub struct MultiLineSummarySecondLine;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct MultiLineSummarySecondLine;
|
||||
|
||||
impl AlwaysFixableViolation for MultiLineSummarySecondLine {
|
||||
#[derive_message_formats]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use ruff_text_size::{TextLen, TextSize};
|
||||
|
||||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_ast::docstrings::clean_space;
|
||||
use ruff_source_file::{NewlineWithTrailingNewline, UniversalNewlines};
|
||||
use ruff_text_size::Ranged;
|
||||
|
@ -43,8 +43,8 @@ use crate::docstrings::Docstring;
|
|||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
#[violation]
|
||||
pub struct NewLineAfterLastParagraph;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct NewLineAfterLastParagraph;
|
||||
|
||||
impl AlwaysFixableViolation for NewLineAfterLastParagraph {
|
||||
#[derive_message_formats]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_source_file::UniversalNewlines;
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
|
@ -40,8 +40,8 @@ use crate::docstrings::Docstring;
|
|||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
#[violation]
|
||||
pub struct NoSignature;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct NoSignature;
|
||||
|
||||
impl Violation for NoSignature {
|
||||
#[derive_message_formats]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_source_file::NewlineWithTrailingNewline;
|
||||
use ruff_text_size::Ranged;
|
||||
use ruff_text_size::{TextLen, TextRange};
|
||||
|
@ -31,8 +31,8 @@ use crate::rules::pydocstyle::helpers::ends_with_backslash;
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct SurroundingWhitespace;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct SurroundingWhitespace;
|
||||
|
||||
impl Violation for SurroundingWhitespace {
|
||||
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::LazyLock;
|
|||
use imperative::Mood;
|
||||
|
||||
use ruff_diagnostics::{Diagnostic, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_semantic::analyze::visibility::{is_property, is_test};
|
||||
use ruff_source_file::UniversalNewlines;
|
||||
use ruff_text_size::Ranged;
|
||||
|
@ -50,8 +50,8 @@ static MOOD: LazyLock<Mood> = LazyLock::new(Mood::new);
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
#[violation]
|
||||
pub struct NonImperativeMood {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct NonImperativeMood {
|
||||
first_line: String,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -29,8 +29,8 @@ use crate::registry::Rule;
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct EmptyDocstring;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct EmptyDocstring;
|
||||
|
||||
impl Violation for EmptyDocstring {
|
||||
#[derive_message_formats]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_ast::identifier::Identifier;
|
||||
use ruff_python_semantic::analyze::visibility::{
|
||||
is_call, is_init, is_magic, is_new, is_overload, is_override, Visibility,
|
||||
|
@ -61,8 +61,8 @@ use crate::registry::Rule;
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct UndocumentedPublicModule;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UndocumentedPublicModule;
|
||||
|
||||
impl Violation for UndocumentedPublicModule {
|
||||
#[derive_message_formats]
|
||||
|
@ -144,8 +144,8 @@ impl Violation for UndocumentedPublicModule {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct UndocumentedPublicClass;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UndocumentedPublicClass;
|
||||
|
||||
impl Violation for UndocumentedPublicClass {
|
||||
#[derive_message_formats]
|
||||
|
@ -226,8 +226,8 @@ impl Violation for UndocumentedPublicClass {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct UndocumentedPublicMethod;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UndocumentedPublicMethod;
|
||||
|
||||
impl Violation for UndocumentedPublicMethod {
|
||||
#[derive_message_formats]
|
||||
|
@ -316,8 +316,8 @@ impl Violation for UndocumentedPublicMethod {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Style Python Docstrings](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct UndocumentedPublicFunction;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UndocumentedPublicFunction;
|
||||
|
||||
impl Violation for UndocumentedPublicFunction {
|
||||
#[derive_message_formats]
|
||||
|
@ -359,8 +359,8 @@ impl Violation for UndocumentedPublicFunction {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Style Python Docstrings](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct UndocumentedPublicPackage;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UndocumentedPublicPackage;
|
||||
|
||||
impl Violation for UndocumentedPublicPackage {
|
||||
#[derive_message_formats]
|
||||
|
@ -416,8 +416,8 @@ impl Violation for UndocumentedPublicPackage {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Style Python Docstrings](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct UndocumentedMagicMethod;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UndocumentedMagicMethod;
|
||||
|
||||
impl Violation for UndocumentedMagicMethod {
|
||||
#[derive_message_formats]
|
||||
|
@ -471,8 +471,8 @@ impl Violation for UndocumentedMagicMethod {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Style Python Docstrings](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct UndocumentedPublicNestedClass;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UndocumentedPublicNestedClass;
|
||||
|
||||
impl Violation for UndocumentedPublicNestedClass {
|
||||
#[derive_message_formats]
|
||||
|
@ -519,8 +519,8 @@ impl Violation for UndocumentedPublicNestedClass {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Style Python Docstrings](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct UndocumentedPublicInit;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UndocumentedPublicInit;
|
||||
|
||||
impl Violation for UndocumentedPublicInit {
|
||||
#[derive_message_formats]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_ast::str::{leading_quote, trailing_quote};
|
||||
use ruff_source_file::NewlineWithTrailingNewline;
|
||||
use ruff_text_size::Ranged;
|
||||
|
@ -32,8 +32,8 @@ use crate::docstrings::Docstring;
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
#[violation]
|
||||
pub struct FitsOnOneLine;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct FitsOnOneLine;
|
||||
|
||||
impl Violation for FitsOnOneLine {
|
||||
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::sync::LazyLock;
|
|||
|
||||
use ruff_diagnostics::{AlwaysFixableViolation, Violation};
|
||||
use ruff_diagnostics::{Diagnostic, Edit, Fix};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_ast::docstrings::{clean_space, leading_space};
|
||||
use ruff_python_ast::identifier::Identifier;
|
||||
use ruff_python_ast::ParameterWithDefault;
|
||||
|
@ -89,8 +89,8 @@ use crate::rules::pydocstyle::settings::Convention;
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct SectionNotOverIndented {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct SectionNotOverIndented {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -192,8 +192,8 @@ impl AlwaysFixableViolation for SectionNotOverIndented {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
#[violation]
|
||||
pub struct SectionUnderlineNotOverIndented {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct SectionUnderlineNotOverIndented {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -275,8 +275,8 @@ impl AlwaysFixableViolation for SectionUnderlineNotOverIndented {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct CapitalizeSectionName {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct CapitalizeSectionName {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -373,8 +373,8 @@ impl AlwaysFixableViolation for CapitalizeSectionName {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
#[violation]
|
||||
pub struct NewLineAfterSectionName {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct NewLineAfterSectionName {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -476,8 +476,8 @@ impl AlwaysFixableViolation for NewLineAfterSectionName {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
#[violation]
|
||||
pub struct DashedUnderlineAfterSection {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct DashedUnderlineAfterSection {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -582,8 +582,8 @@ impl AlwaysFixableViolation for DashedUnderlineAfterSection {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
#[violation]
|
||||
pub struct SectionUnderlineAfterName {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct SectionUnderlineAfterName {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -686,8 +686,8 @@ impl AlwaysFixableViolation for SectionUnderlineAfterName {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
#[violation]
|
||||
pub struct SectionUnderlineMatchesSectionLength {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct SectionUnderlineMatchesSectionLength {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -783,8 +783,8 @@ impl AlwaysFixableViolation for SectionUnderlineMatchesSectionLength {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Style Guide](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct NoBlankLineAfterSection {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct NoBlankLineAfterSection {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -876,8 +876,8 @@ impl AlwaysFixableViolation for NoBlankLineAfterSection {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
#[violation]
|
||||
pub struct NoBlankLineBeforeSection {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct NoBlankLineBeforeSection {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -971,8 +971,8 @@ impl AlwaysFixableViolation for NoBlankLineBeforeSection {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
#[violation]
|
||||
pub struct BlankLineAfterLastSection {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct BlankLineAfterLastSection {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -1060,8 +1060,8 @@ impl AlwaysFixableViolation for BlankLineAfterLastSection {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Style Guide](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct EmptyDocstringSection {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct EmptyDocstringSection {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -1137,8 +1137,8 @@ impl Violation for EmptyDocstringSection {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [Google Style Guide](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct SectionNameEndsInColon {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct SectionNameEndsInColon {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
@ -1220,8 +1220,8 @@ impl AlwaysFixableViolation for SectionNameEndsInColon {
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct UndocumentedParam {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UndocumentedParam {
|
||||
/// The name of the function being documented.
|
||||
definition: String,
|
||||
/// The names of the undocumented parameters.
|
||||
|
@ -1302,8 +1302,8 @@ impl Violation for UndocumentedParam {
|
|||
/// - [PEP 287 – reStructuredText Docstring Format](https://peps.python.org/pep-0287/)
|
||||
/// - [NumPy Style Guide](https://numpydoc.readthedocs.io/en/latest/format.html)
|
||||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
#[violation]
|
||||
pub struct BlankLinesBetweenHeaderAndContent {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct BlankLinesBetweenHeaderAndContent {
|
||||
name: String,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -39,8 +39,8 @@ use crate::rules::pydocstyle::helpers::normalize_word;
|
|||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/
|
||||
#[violation]
|
||||
pub struct DocstringStartsWithThis;
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct DocstringStartsWithThis;
|
||||
|
||||
impl Violation for DocstringStartsWithThis {
|
||||
#[derive_message_formats]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||
use ruff_python_ast::str::Quote;
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
|
@ -37,8 +37,8 @@ use crate::docstrings::Docstring;
|
|||
/// - [Google Python Style Guide - Docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)
|
||||
///
|
||||
/// [formatter]: https://docs.astral.sh/ruff/formatter/
|
||||
#[violation]
|
||||
pub struct TripleSingleQuotes {
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct TripleSingleQuotes {
|
||||
expected_quote: Quote,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue