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 GitLabIdMissing,
40}
41
42impl Arbitrary for Code {
43 fn arbitrary(g: &mut Gen) -> Self {
44 *g.choose(&Self::get_codes()).unwrap()
45 }
46
47 fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
48 quickcheck::empty_shrinker()
49 }
50}
51
52impl Code {
53 const fn get_codes() -> [Self; 15] {
54 [
55 Self::InitialNotMatchedToAuthor,
56 Self::UnparsableAuthorFile,
57 Self::StaleAuthor,
58 Self::DuplicatedTrailers,
59 Self::PivotalTrackerIdMissing,
60 Self::JiraIssueKeyMissing,
61 Self::GitHubIdMissing,
62 Self::GitLabIdMissing,
63 Self::SubjectNotSeparateFromBody,
64 Self::SubjectLongerThan72Characters,
65 Self::SubjectNotCapitalized,
66 Self::SubjectEndsWithPeriod,
67 Self::BodyWiderThan72Characters,
68 Self::NotConventionalCommit,
69 Self::NotEmojiLog,
70 ]
71 }
72}