Skip to content

Commit fe8ae82

Browse files
committed
Fix ref_option lint issues
1 parent 6cee321 commit fe8ae82

File tree

15 files changed

+34
-60
lines changed

15 files changed

+34
-60
lines changed

src/application.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ where ModuleProvider: module::ModuleProvider + Send + 'static
128128
}
129129

130130
fn filepath_from_args(args: &Args) -> Result<String, Exit> {
131-
args.todo_file_path().as_ref().map(String::from).ok_or_else(|| {
131+
args.todo_file_path().map(String::from).ok_or_else(|| {
132132
Exit::new(
133133
ExitStatus::StateError,
134134
build_help(Some(String::from("A todo file path must be provided."))).as_str(),
@@ -238,7 +238,6 @@ mod tests {
238238
assert_eq!(exit.get_status(), &ExitStatus::StateError);
239239
assert!(
240240
exit.get_message()
241-
.as_ref()
242241
.unwrap()
243242
.contains("A todo file path must be provided")
244243
);
@@ -252,12 +251,7 @@ mod tests {
252251
Application::new(&args(&["todofile"]), event_provider, create_mocked_crossterm());
253252
let exit = application_error!(application);
254253
assert_eq!(exit.get_status(), &ExitStatus::StateError);
255-
assert!(
256-
exit.get_message()
257-
.as_ref()
258-
.unwrap()
259-
.contains("Unable to load Git repository: ")
260-
);
254+
assert!(exit.get_message().unwrap().contains("Unable to load Git repository: "));
261255
});
262256
}
263257

@@ -342,7 +336,6 @@ mod tests {
342336
assert_eq!(exit.get_status(), &ExitStatus::Good);
343337
assert!(
344338
exit.get_message()
345-
.as_ref()
346339
.unwrap()
347340
.contains("An empty rebase was provided, nothing to edit")
348341
);
@@ -404,12 +397,7 @@ mod tests {
404397

405398
let exit = application.run_until_finished().unwrap_err();
406399
assert_eq!(exit.get_status(), &ExitStatus::StateError);
407-
assert!(
408-
exit.get_message()
409-
.as_ref()
410-
.unwrap()
411-
.starts_with("Failed to join runtime:")
412-
);
400+
assert!(exit.get_message().unwrap().starts_with("Failed to join runtime:"));
413401
});
414402
}
415403

@@ -449,7 +437,7 @@ mod tests {
449437
let exit = application.run_until_finished().unwrap_err();
450438
assert_eq!(exit.get_status(), &ExitStatus::StateError);
451439
assert_eq!(
452-
exit.get_message().as_ref().unwrap(),
440+
exit.get_message().unwrap(),
453441
"Attempt made to run application a second time"
454442
);
455443
});

src/arguments.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ impl Args {
2323
&self.mode
2424
}
2525

26-
pub(crate) const fn todo_file_path(&self) -> &Option<String> {
27-
&self.todo_file_path
26+
pub(crate) fn todo_file_path(&self) -> Option<&str> {
27+
self.todo_file_path.as_deref()
2828
}
2929
}
3030

@@ -90,7 +90,7 @@ mod tests {
9090
fn todo_file_ok() {
9191
let args = Args::try_from(create_args(&["todofile"])).unwrap();
9292
assert_eq!(args.mode(), &Mode::Editor);
93-
assert_eq!(args.todo_file_path(), &Some(String::from("todofile")));
93+
assert_eq!(args.todo_file_path(), Some("todofile"));
9494
}
9595

9696
#[test]

src/exit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ impl Exit {
1414
}
1515
}
1616

17-
pub(crate) const fn get_message(&self) -> &Option<String> {
18-
&self.message
17+
pub(crate) fn get_message(&self) -> Option<&str> {
18+
self.message.as_deref()
1919
}
2020

2121
pub(crate) const fn get_status(&self) -> &ExitStatus {
@@ -51,14 +51,14 @@ mod tests {
5151
#[test]
5252
fn exit_new() {
5353
let exit = Exit::new(ExitStatus::StateError, "This is an error");
54-
assert_eq!(exit.get_message(), &Some(String::from("This is an error")));
54+
assert_eq!(exit.get_message(), Some("This is an error"));
5555
assert_eq!(exit.get_status(), &ExitStatus::StateError);
5656
}
5757

5858
#[test]
5959
fn exit_from_exit_status() {
6060
let exit = Exit::from(ExitStatus::Kill);
61-
assert_eq!(exit.get_message(), &None);
61+
assert_eq!(exit.get_message(), None);
6262
assert_eq!(exit.get_status(), &ExitStatus::Kill);
6363
}
6464
}

src/git/commit.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ impl Commit {
2525
/// Get the reference to the commit
2626
#[must_use]
2727
#[allow(dead_code)]
28-
pub(crate) const fn reference(&self) -> &Option<Reference> {
29-
&self.reference
28+
pub(crate) const fn reference(&self) -> Option<&Reference> {
29+
self.reference.as_ref()
3030
}
3131

3232
/// Get the author of the commit.
@@ -38,14 +38,14 @@ impl Commit {
3838
/// Get the author of the commit.
3939
#[must_use]
4040
#[allow(dead_code)]
41-
pub(crate) const fn authored_date(&self) -> &Option<DateTime<Local>> {
42-
&self.authored_date
41+
pub(crate) const fn authored_date(&self) -> Option<&DateTime<Local>> {
42+
self.authored_date.as_ref()
4343
}
4444

4545
/// Get the committer of the commit.
4646
#[must_use]
47-
pub(crate) const fn committer(&self) -> &Option<User> {
48-
&self.committer
47+
pub(crate) const fn committer(&self) -> Option<&User> {
48+
self.committer.as_ref()
4949
}
5050

5151
/// Get the committed date of the commit.

src/git/commit_diff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ impl CommitDiff {
3939
/// The parent commit for the diff
4040
#[must_use]
4141
#[allow(dead_code)]
42-
pub(crate) const fn parent(&self) -> &Option<Commit> {
43-
&self.parent
42+
pub(crate) const fn parent(&self) -> Option<&Commit> {
43+
self.parent.as_ref()
4444
}
4545

4646
/// The file statuses

src/help.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ mod tests {
3939
assert!(
4040
run()
4141
.get_message()
42-
.as_ref()
4342
.unwrap()
4443
.contains("Full feature terminal based sequence editor for git interactive rebase.")
4544
);

src/license.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ mod tests {
3535
assert!(
3636
run()
3737
.get_message()
38-
.as_ref()
3938
.unwrap()
4039
.contains("Sequence Editor for Git Interactive Rebase")
4140
);

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn run(os_args: Vec<OsString>) -> Exit {
7979
#[cfg(not(tarpaulin_include))]
8080
fn main() {
8181
let exit = run(env::args_os().skip(1).collect());
82-
if let Some(message) = exit.get_message().as_ref() {
82+
if let Some(message) = exit.get_message() {
8383
eprintln!("{message}");
8484
}
8585
std::process::exit(exit.get_status().to_code());

src/modules/show_commit/view_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl ViewBuilder {
117117
]));
118118
}
119119

120-
if let Some(committer) = commit.committer().as_ref() {
120+
if let Some(committer) = commit.committer() {
121121
updater.push_line(ViewLine::from(vec![
122122
LineSegment::new_with_color(
123123
if is_full_width { "Committer: " } else { "C: " },

src/test_helpers/assertions/assert_rendered_output/render_view_line.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(crate) fn render_view_line(view_line: &ViewLine, options: Option<AssertRende
3232
}
3333
line.push_str(segment.get_content());
3434
}
35-
if let Some(padding) = view_line.get_padding().as_ref() {
35+
if let Some(padding) = view_line.get_padding() {
3636
if opts.contains(AssertRenderOptions::INCLUDE_STYLE) {
3737
let style = render_style(padding);
3838
if style != last_style {

0 commit comments

Comments
 (0)