ruff_dev::generate_rules_table previously documented which rules are
autofixable via DiagnosticKind::fixable ... since the DiagnosticKind was
obtained via Rule::kind (and Violation::placeholder) which we both want
to get rid of we have to obtain the autofixability via another way.
This commit implements such another way by adding an AUTOFIX
associated constant to the Violation trait. The constant is of the type
Option<AutoFixkind>, AutofixKind is a new struct containing an
Availability enum { Sometimes, Always}, letting us additionally document
that some autofixes are only available sometimes (which previously
wasn't documented). We intentionally introduce this information in a
struct so that we can easily introduce further autofix metadata in the
future such as autofix applicability[1].
[1]: https://doc.rust-lang.org/stable/nightly-rustc/rustc_errors/enum.Applicability.html
65 lines
1.3 KiB
Rust
65 lines
1.3 KiB
Rust
//! This is the library for the [Ruff] Python linter.
|
|
//!
|
|
//! **The API is currently completely unstable**
|
|
//! and subject to change drastically.
|
|
//!
|
|
//! [Ruff]: https://github.com/charliermarsh/ruff
|
|
#![allow(
|
|
clippy::collapsible_else_if,
|
|
clippy::collapsible_if,
|
|
clippy::implicit_hasher,
|
|
clippy::match_same_arms,
|
|
clippy::missing_errors_doc,
|
|
clippy::missing_panics_doc,
|
|
clippy::module_name_repetitions,
|
|
clippy::must_use_candidate,
|
|
clippy::similar_names,
|
|
clippy::too_many_lines
|
|
)]
|
|
#![forbid(unsafe_code)]
|
|
|
|
mod ast;
|
|
mod autofix;
|
|
pub mod cache;
|
|
mod checkers;
|
|
mod cst;
|
|
mod directives;
|
|
mod doc_lines;
|
|
mod docstrings;
|
|
pub mod fix;
|
|
pub mod flake8_to_ruff;
|
|
pub mod fs;
|
|
mod lex;
|
|
pub mod linter;
|
|
pub mod logging;
|
|
pub mod message;
|
|
mod noqa;
|
|
mod python;
|
|
pub mod registry;
|
|
pub mod resolver;
|
|
mod rules;
|
|
mod rustpython_helpers;
|
|
pub mod settings;
|
|
pub mod source_code;
|
|
mod vendor;
|
|
mod violation;
|
|
mod violations;
|
|
mod visibility;
|
|
|
|
use cfg_if::cfg_if;
|
|
pub use violation::{AutofixKind, Availability as AutofixAvailability};
|
|
pub use violations::IOError;
|
|
|
|
cfg_if! {
|
|
if #[cfg(not(target_family = "wasm"))] {
|
|
pub mod packaging;
|
|
|
|
|
|
mod lib_native;
|
|
pub use lib_native::check;
|
|
} else {
|
|
mod lib_wasm;
|
|
pub use lib_wasm::check;
|
|
}
|
|
}
|