1use quickcheck::{Arbitrary, Gen};
2use strum_macros::EnumIter;
3
4#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter)]
8#[repr(i32)]
9pub enum Code {
10 InitialNotMatchedToAuthor = 3,
12 UnparsableAuthorFile,
14 StaleAuthor,
16 DuplicatedTrailers,
18 PivotalTrackerIdMissing,
20 JiraIssueKeyMissing,
22 GitHubIdMissing,
24 SubjectNotSeparateFromBody,
26 SubjectLongerThan72Characters,
28 SubjectNotCapitalized,
30 SubjectEndsWithPeriod,
32 BodyWiderThan72Characters,
34 NotConventionalCommit,
36 NotEmojiLog,
38}
39
40impl Arbitrary for Code {
41 fn arbitrary(g: &mut Gen) -> Self {
42 *g.choose(&Self::get_codes()).unwrap()
43 }
44
45 fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
46 quickcheck::empty_shrinker()
47 }
48}
49
50impl Code {
51 const fn get_codes() -> [Self; 14] {
52 [
53 Self::InitialNotMatchedToAuthor,
54 Self::UnparsableAuthorFile,
55 Self::StaleAuthor,
56 Self::DuplicatedTrailers,
57 Self::PivotalTrackerIdMissing,
58 Self::JiraIssueKeyMissing,
59 Self::GitHubIdMissing,
60 Self::SubjectNotSeparateFromBody,
61 Self::SubjectLongerThan72Characters,
62 Self::SubjectNotCapitalized,
63 Self::SubjectEndsWithPeriod,
64 Self::BodyWiderThan72Characters,
65 Self::NotConventionalCommit,
66 Self::NotEmojiLog,
67 ]
68 }
69}