mit_lint/lib.rs
1//! A set of lints to use with mit-commit
2//!
3//! # Examples
4//!
5//! ``` rust
6//! use mit_commit::CommitMessage;
7//! use mit_lint::{Code, lint, Problem, Lints, Lint};
8//! use std::option::Option::None;
9//!
10//! let message:String = "x".repeat(73).into();
11//! let expected = vec![Problem::new(
12//! "Your subject is longer than 72 characters".into(),
13//! "It's important to keep the subject of the commit less than 72 characters because when you look at the git log, that's where it truncates the message. This means that people won't get the entirety of the information in your commit.\n\nPlease keep the subject line 72 characters or under"
14//! .into(),
15//! Code::SubjectLongerThan72Characters,&message.clone().into(),Some(vec![(String::from("Too long"), 72, 1)]),
16//! Some("https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines".parse().unwrap()),
17//! )];
18//! let lints = Lints::new(vec![Lint::SubjectLongerThan72Characters].into_iter().collect());
19//! let actual = lint(&CommitMessage::from(message), &lints);
20//! assert_eq!(
21//! actual, expected,
22//! "Expected {:?}, found {:?}",
23//! expected, actual
24//! );
25//! ```
26
27#![warn(clippy::nursery)]
28#![deny(
29 unused,
30 nonstandard_style,
31 future_incompatible,
32 missing_copy_implementations,
33 missing_debug_implementations,
34 missing_docs,
35 clippy::pedantic,
36 clippy::cargo,
37 clippy::complexity,
38 clippy::correctness,
39 clippy::pedantic,
40 clippy::perf,
41 clippy::style,
42 clippy::suspicious,
43 non_fmt_panics
44)]
45#![allow(clippy::multiple_crate_versions)]
46
47#[cfg(test)]
48#[macro_use(quickcheck)]
49extern crate quickcheck_macros;
50
51pub use cmd::{async_lint, lint};
52pub use model::{CONFIG_KEY_PREFIX, Code, Error, Lint, LintError, Lints, Problem};
53
54mod checks;
55mod cmd;
56mod model;
57
58#[cfg(doctest)]
59mod test_readme {
60 macro_rules! external_doc_test {
61 ($x:expr) => {
62 #[doc = $x]
63 unsafe extern "C" {}
64 };
65 }
66
67 external_doc_test!(include_str!("../README.md"));
68}