Skip to content

Commit

Permalink
fix(cli): clippy errors in tests (#330)
Browse files Browse the repository at this point in the history
* test: Fix clippy errors in tests

- Add dead_code flag to footer and raw of Message struct

* Update src/message.rs

---------

Co-authored-by: Daniel Havlíček <daniel.havlicek@braiins.cz>
Co-authored-by: KeisukeYamashita <19yamashita15@gmail.com>
  • Loading branch information
3 people authored Jul 26, 2024
1 parent 2755233 commit fc74af5
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub struct Message {

/// Description part of the commit message.
pub description: Option<String>,

/// Footers part of the commit message.
pub footers: Option<HashMap<String, String>>,

#[allow(dead_code)]
/// Raw commit message (or any input from stdin) including the body and footers.
pub raw: String,

Expand Down
18 changes: 12 additions & 6 deletions src/rule/description_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ mod tests {

#[test]
fn test_invalid_description_format() {
let mut rule = DescriptionFormat::default();
rule.format = Some(r"^[a-z].*".to_string());
let rule = DescriptionFormat {
format: Some(r"^[a-z].*".to_string()),
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -96,8 +98,10 @@ mod tests {

#[test]
fn test_valid_description_format() {
let mut rule = DescriptionFormat::default();
rule.format = Some(r"^[a-z].*".to_string());
let rule = DescriptionFormat {
format: Some(r"^[a-z].*".to_string()),
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -120,8 +124,10 @@ mod tests {

#[test]
fn test_invalid_regex() {
let mut rule = DescriptionFormat::default();
rule.format = Some(r"(".to_string());
let rule = DescriptionFormat {
format: Some(r"(".to_string()),
..Default::default()
};

let message = Message {
body: None,
Expand Down
24 changes: 16 additions & 8 deletions src/rule/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ mod tests {
use super::*;
#[test]
fn test_empty_scope() {
let mut rule = Scope::default();
rule.options = vec!["api".to_string(), "web".to_string()];
let rule = Scope {
options: vec!["api".to_string(), "web".to_string()],
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -164,8 +166,10 @@ mod tests {

#[test]
fn test_none_scope() {
let mut rule = Scope::default();
rule.options = vec!["api".to_string(), "web".to_string()];
let rule = Scope {
options: vec!["api".to_string(), "web".to_string()],
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -188,8 +192,10 @@ mod tests {

#[test]
fn test_valid_scope() {
let mut rule = Scope::default();
rule.options = vec!["api".to_string(), "web".to_string()];
let rule = Scope {
options: vec!["api".to_string(), "web".to_string()],
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -206,8 +212,10 @@ mod tests {

#[test]
fn test_invalid_scope() {
let mut rule = Scope::default();
rule.options = vec!["api".to_string(), "web".to_string()];
let rule = Scope {
options: vec!["api".to_string(), "web".to_string()],
..Default::default()
};

let message = Message {
body: None,
Expand Down
18 changes: 12 additions & 6 deletions src/rule/scope_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ mod tests {

#[test]
fn test_invalid_description_format() {
let mut rule = ScopeFormat::default();
rule.format = Some(r"^[a-z].*".to_string());
let rule = ScopeFormat {
format: Some(r"^[a-z].*".to_string()),
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -96,8 +98,10 @@ mod tests {

#[test]
fn test_valid_description_format() {
let mut rule = ScopeFormat::default();
rule.format = Some(r"^[a-z].*".to_string());
let rule = ScopeFormat {
format: Some(r"^[a-z].*".to_string()),
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -120,8 +124,10 @@ mod tests {

#[test]
fn test_invalid_regex() {
let mut rule = ScopeFormat::default();
rule.format = Some(r"(".to_string());
let rule = ScopeFormat {
format: Some(r"(".to_string()),
..Default::default()
};

let message = Message {
body: None,
Expand Down
24 changes: 16 additions & 8 deletions src/rule/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ mod tests {
use super::*;
#[test]
fn test_empty_type() {
let mut rule = Type::default();
rule.options = vec!["feat".to_string(), "chore".to_string()];
let rule = Type {
options: vec!["feat".to_string(), "chore".to_string()],
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -163,8 +165,10 @@ mod tests {

#[test]
fn test_none_type() {
let mut rule = Type::default();
rule.options = vec!["feat".to_string(), "chore".to_string()];
let rule = Type {
options: vec!["feat".to_string(), "chore".to_string()],
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -187,8 +191,10 @@ mod tests {

#[test]
fn test_valid_type() {
let mut rule = Type::default();
rule.options = vec!["feat".to_string(), "chore".to_string()];
let rule = Type {
options: vec!["feat".to_string(), "chore".to_string()],
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -205,8 +211,10 @@ mod tests {

#[test]
fn test_invalid_type() {
let mut rule = Type::default();
rule.options = vec!["feat".to_string(), "chore".to_string()];
let rule = Type {
options: vec!["feat".to_string(), "chore".to_string()],
..Default::default()
};

let message = Message {
body: None,
Expand Down
18 changes: 12 additions & 6 deletions src/rule/type_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ mod tests {

#[test]
fn test_invalid_description_format() {
let mut rule = TypeFormat::default();
rule.format = Some(r"^[a-z].*".to_string());
let rule = TypeFormat {
format: Some(r"^[a-z].*".to_string()),
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -96,8 +98,10 @@ mod tests {

#[test]
fn test_valid_description_format() {
let mut rule = TypeFormat::default();
rule.format = Some(r"^[a-z].*".to_string());
let rule = TypeFormat {
format: Some(r"^[a-z].*".to_string()),
..Default::default()
};

let message = Message {
body: None,
Expand All @@ -120,8 +124,10 @@ mod tests {

#[test]
fn test_invalid_regex() {
let mut rule = TypeFormat::default();
rule.format = Some(r"(".to_string());
let rule = TypeFormat {
format: Some(r"(".to_string()),
..Default::default()
};

let message = Message {
body: None,
Expand Down

0 comments on commit fc74af5

Please sign in to comment.