File tree Expand file tree Collapse file tree 10 files changed +35
-29
lines changed Expand file tree Collapse file tree 10 files changed +35
-29
lines changed Original file line number Diff line number Diff line change 3
3
#![ forbid( unsafe_code) ]
4
4
#![ forbid( missing_docs) ]
5
5
#![ deny( clippy:: all) ]
6
- #![ deny( clippy:: result_unwrap_used ) ]
6
+ #![ deny( clippy:: unwrap_used ) ]
7
7
#![ deny( clippy:: panic) ]
8
8
9
9
pub mod cached;
Original file line number Diff line number Diff line change @@ -219,8 +219,10 @@ fn raw_diff_to_file_diff<'a>(
219
219
} ;
220
220
221
221
let new_file_diff = if diff. deltas ( ) . len ( ) == 1 {
222
- // it's safe to unwrap here because we check first that diff.deltas has a single element.
223
- let delta: DiffDelta = diff. deltas ( ) . next ( ) . unwrap ( ) ;
222
+ let delta: DiffDelta = diff
223
+ . deltas ( )
224
+ . next ( )
225
+ . expect ( "it's safe to unwrap here because we check first that diff.deltas has a single element" ) ;
224
226
225
227
if delta. status ( ) == Delta :: Untracked {
226
228
let relative_path =
@@ -272,7 +274,10 @@ fn raw_diff_to_file_diff<'a>(
272
274
}
273
275
274
276
if !current_lines. is_empty ( ) {
275
- adder ( & current_hunk. unwrap ( ) , & current_lines) ;
277
+ adder (
278
+ & current_hunk. expect ( "invalid hunk" ) ,
279
+ & current_lines,
280
+ ) ;
276
281
}
277
282
278
283
if new_file_diff {
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ pub fn stage_hunk(
23
23
24
24
let mut opt = ApplyOptions :: new ( ) ;
25
25
opt. hunk_callback ( |hunk| {
26
- let header = HunkHeader :: from ( hunk. unwrap ( ) ) ;
26
+ let header =
27
+ HunkHeader :: from ( hunk. expect ( "hunk unavailable" ) ) ;
27
28
hash ( & header) == hunk_hash
28
29
} ) ;
29
30
@@ -117,7 +118,8 @@ pub fn unstage_hunk(
117
118
let mut hunk_idx = 0 ;
118
119
let mut opt = ApplyOptions :: new ( ) ;
119
120
opt. hunk_callback ( |_hunk| {
120
- let res = if hunk_idx == hunk_index. unwrap ( ) {
121
+ let res = if hunk_idx == hunk_index. expect ( "invalid hunk" )
122
+ {
121
123
count += 1 ;
122
124
true
123
125
} else {
Original file line number Diff line number Diff line change 2
2
3
3
#![ forbid( unsafe_code) ]
4
4
#![ forbid( missing_docs) ]
5
- #![ deny( clippy:: result_unwrap_used ) ]
5
+ #![ deny( clippy:: unwrap_used ) ]
6
6
7
7
use std:: time:: Instant ;
8
8
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ impl FileTreeComponent {
109
109
if let Some ( item) = self . tree . selected_item ( ) {
110
110
match item. kind {
111
111
FileTreeItemKind :: File ( _) => true ,
112
- _ => false ,
112
+ FileTreeItemKind :: Path ( .. ) => false ,
113
113
}
114
114
} else {
115
115
false
@@ -206,7 +206,7 @@ impl FileTreeComponent {
206
206
StatusItemType :: New => '+' ,
207
207
StatusItemType :: Deleted => '-' ,
208
208
StatusItemType :: Renamed => 'R' ,
209
- _ => ' ' ,
209
+ StatusItemType :: Typechange => ' ' ,
210
210
}
211
211
}
212
212
}
Original file line number Diff line number Diff line change @@ -192,7 +192,8 @@ impl FileTreeItems {
192
192
index : usize ,
193
193
) -> usize {
194
194
if let Some ( parent_path) = Path :: new ( path) . parent ( ) {
195
- let parent_path = parent_path. to_str ( ) . unwrap ( ) ;
195
+ let parent_path =
196
+ parent_path. to_str ( ) . expect ( "invalid path" ) ;
196
197
for i in ( 0 ..=index) . rev ( ) {
197
198
let item = & self . items [ i] ;
198
199
let item_path = & item. info . full_path ;
@@ -216,18 +217,16 @@ impl FileTreeItems {
216
217
ancestors. reverse ( ) ;
217
218
218
219
for c in & ancestors {
219
- if c. parent ( ) . is_some ( ) {
220
- let path_string = String :: from ( c. to_str ( ) . unwrap ( ) ) ;
221
- if !paths_added. contains ( c) {
222
- paths_added. insert ( c) ;
223
- let is_collapsed =
224
- collapsed. contains ( & path_string) ;
225
- nodes. push ( FileTreeItem :: new_path (
226
- c,
227
- path_string,
228
- is_collapsed,
229
- ) ?) ;
230
- }
220
+ if c. parent ( ) . is_some ( ) && !paths_added. contains ( c) {
221
+ paths_added. insert ( c) ;
222
+ let path_string =
223
+ String :: from ( c. to_str ( ) . expect ( "invalid path" ) ) ;
224
+ let is_collapsed = collapsed. contains ( & path_string) ;
225
+ nodes. push ( FileTreeItem :: new_path (
226
+ c,
227
+ path_string,
228
+ is_collapsed,
229
+ ) ?) ;
231
230
}
232
231
}
233
232
Original file line number Diff line number Diff line change @@ -332,8 +332,8 @@ impl StatusTree {
332
332
inner_collapsed = Some ( format ! ( "{}/" , & item_path) ) ;
333
333
}
334
334
335
- if prefix. is_none ( )
336
- | | item_path. starts_with ( prefix. unwrap ( ) )
335
+ if prefix
336
+ . map_or ( true , |prefix | item_path. starts_with ( prefix) )
337
337
{
338
338
self . tree [ i] . info . visible = true
339
339
} else {
Original file line number Diff line number Diff line change 2
2
#![ deny( clippy:: cargo) ]
3
3
#![ deny( clippy:: pedantic) ]
4
4
#![ deny( clippy:: nursery) ]
5
- #![ deny( clippy:: result_unwrap_used ) ]
5
+ #![ deny( clippy:: unwrap_used ) ]
6
6
#![ deny( clippy:: panic) ]
7
7
#![ allow( clippy:: module_name_repetitions) ]
8
8
#![ allow( clippy:: multiple_crate_versions) ]
@@ -141,8 +141,8 @@ fn main() -> Result<()> {
141
141
{
142
142
app. update_git ( ev) ?
143
143
}
144
+ QueueEvent :: GitEvent ( ..) => ( ) ,
144
145
QueueEvent :: SpinnerUpdate => unreachable ! ( ) ,
145
- _ => ( ) ,
146
146
}
147
147
148
148
draw ( & mut terminal, & app) ?;
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ impl Status {
137
137
match self . focus {
138
138
Focus :: WorkDir => self . index_wd . is_file_seleted ( ) ,
139
139
Focus :: Stage => self . index . is_file_seleted ( ) ,
140
- _ => false ,
140
+ Focus :: Diff => false ,
141
141
}
142
142
}
143
143
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ impl Theme {
110
110
StatusItemType :: Renamed => {
111
111
Style :: default ( ) . fg ( self . diff_file_moved )
112
112
}
113
- _ => Style :: default ( ) ,
113
+ StatusItemType :: Typechange => Style :: default ( ) ,
114
114
} ;
115
115
116
116
self . apply_select ( style, selected)
@@ -155,7 +155,7 @@ impl Theme {
155
155
DiffLineType :: Header => Style :: default ( )
156
156
. fg ( self . disabled_fg )
157
157
. modifier ( Modifier :: BOLD ) ,
158
- _ => Style :: default ( ) . fg ( if selected {
158
+ DiffLineType :: None => Style :: default ( ) . fg ( if selected {
159
159
self . command_fg
160
160
} else {
161
161
Color :: Reset
You can’t perform that action at this time.
0 commit comments