@@ -6,8 +6,6 @@ use std::fmt;
6
6
7
7
use crate :: config:: ReportTactic ;
8
8
9
- const FIX_ME_CHARS : & [ char ] = & [ 'f' , 'i' , 'x' , 'm' , 'e' ] ;
10
-
11
9
// Enabled implementation detail is here because it is
12
10
// irrelevant outside the issues module
13
11
fn is_enabled ( report_tactic : ReportTactic ) -> bool {
@@ -16,7 +14,7 @@ fn is_enabled(report_tactic: ReportTactic) -> bool {
16
14
17
15
#[ derive( Clone , Copy ) ]
18
16
enum Seeking {
19
- Issue { fixme_idx : usize } ,
17
+ Issue { } ,
20
18
Number { issue : Issue , part : NumberPart } ,
21
19
}
22
20
@@ -30,7 +28,7 @@ enum NumberPart {
30
28
31
29
#[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
32
30
pub struct Issue {
33
- issue_type : IssueType ,
31
+ issue_type : Option < IssueType > ,
34
32
// Indicates whether we're looking for issues with missing numbers, or
35
33
// all issues of this type.
36
34
missing_number : bool ,
@@ -39,7 +37,7 @@ pub struct Issue {
39
37
impl fmt:: Display for Issue {
40
38
fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> Result < ( ) , fmt:: Error > {
41
39
let msg = match self . issue_type {
42
- IssueType :: Fixme => "FIXME " ,
40
+ _ => "" ,
43
41
} ;
44
42
let details = if self . missing_number {
45
43
" without issue number"
@@ -52,9 +50,7 @@ impl fmt::Display for Issue {
52
50
}
53
51
54
52
#[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
55
- enum IssueType {
56
- Fixme ,
57
- }
53
+ enum IssueType { }
58
54
59
55
enum IssueClassification {
60
56
Good ,
@@ -64,27 +60,25 @@ enum IssueClassification {
64
60
65
61
pub ( crate ) struct BadIssueSeeker {
66
62
state : Seeking ,
67
- report_fixme : ReportTactic ,
68
63
}
69
64
70
65
impl BadIssueSeeker {
71
- pub ( crate ) fn new ( report_fixme : ReportTactic ) -> BadIssueSeeker {
66
+ pub ( crate ) fn new ( ) -> BadIssueSeeker {
72
67
BadIssueSeeker {
73
- state : Seeking :: Issue { fixme_idx : 0 } ,
74
- report_fixme,
68
+ state : Seeking :: Issue { } ,
75
69
}
76
70
}
77
71
78
72
pub ( crate ) fn is_disabled ( & self ) -> bool {
79
- ! is_enabled ( self . report_fixme )
73
+ true
80
74
}
81
75
82
76
// Check whether or not the current char is conclusive evidence for an
83
77
// unnumbered TO-DO or FIX-ME.
84
78
pub ( crate ) fn inspect ( & mut self , c : char ) -> Option < Issue > {
85
79
match self . state {
86
- Seeking :: Issue { fixme_idx } => {
87
- self . state = self . inspect_issue ( c, fixme_idx ) ;
80
+ Seeking :: Issue { } => {
81
+ self . state = self . inspect_issue ( c, 0 ) ;
88
82
}
89
83
Seeking :: Number { issue, part } => {
90
84
let result = self . inspect_number ( c, issue, part) ;
@@ -93,7 +87,7 @@ impl BadIssueSeeker {
93
87
return None ;
94
88
}
95
89
96
- self . state = Seeking :: Issue { fixme_idx : 0 } ;
90
+ self . state = Seeking :: Issue { } ;
97
91
98
92
if let IssueClassification :: Bad ( issue) = result {
99
93
return Some ( issue) ;
@@ -106,25 +100,10 @@ impl BadIssueSeeker {
106
100
107
101
fn inspect_issue ( & mut self , c : char , mut fixme_idx : usize ) -> Seeking {
108
102
if let Some ( lower_case_c) = c. to_lowercase ( ) . next ( ) {
109
- if is_enabled ( self . report_fixme ) && lower_case_c == FIX_ME_CHARS [ fixme_idx] {
110
- // Exploit the fact that the character sets of todo and fixme
111
- // are disjoint by adding else.
112
- fixme_idx += 1 ;
113
- if fixme_idx == FIX_ME_CHARS . len ( ) {
114
- return Seeking :: Number {
115
- issue : Issue {
116
- issue_type : IssueType :: Fixme ,
117
- missing_number : matches ! ( self . report_fixme, ReportTactic :: Unnumbered ) ,
118
- } ,
119
- part : NumberPart :: OpenParen ,
120
- } ;
121
- }
122
- } else {
123
- fixme_idx = 0 ;
124
- }
103
+ fixme_idx = 0 ;
125
104
}
126
105
127
- Seeking :: Issue { fixme_idx }
106
+ Seeking :: Issue { }
128
107
}
129
108
130
109
fn inspect_number (
@@ -175,59 +154,32 @@ impl BadIssueSeeker {
175
154
#[ test]
176
155
fn find_unnumbered_issue ( ) {
177
156
fn check_fail ( text : & str , failing_pos : usize ) {
178
- let mut seeker = BadIssueSeeker :: new ( ReportTactic :: Unnumbered ) ;
157
+ let mut seeker = BadIssueSeeker :: new ( ) ;
179
158
assert_eq ! (
180
159
Some ( failing_pos) ,
181
160
text. find( |c| seeker. inspect( c) . is_some( ) )
182
161
) ;
183
162
}
184
163
185
164
fn check_pass ( text : & str ) {
186
- let mut seeker = BadIssueSeeker :: new ( ReportTactic :: Unnumbered ) ;
165
+ let mut seeker = BadIssueSeeker :: new ( ) ;
187
166
assert_eq ! ( None , text. find( |c| seeker. inspect( c) . is_some( ) ) ) ;
188
167
}
189
-
190
- check_fail ( " \n FIXME\n " , 8 ) ;
191
- check_fail ( "FIXME(\n " , 6 ) ;
192
- check_fail ( "FIXME(#\n " , 7 ) ;
193
- check_fail ( "FIXME(#1\n " , 8 ) ;
194
- check_fail ( "FIXME(#)1\n " , 7 ) ;
195
- check_pass ( "FIXME(#1222)\n " ) ;
196
- check_fail ( "FIXME(#12\n 22)\n " , 9 ) ;
197
- check_pass ( "FIXME(@maintainer, #1222, hello)\n " ) ;
198
168
}
199
169
200
170
#[ test]
201
171
fn find_issue ( ) {
202
- fn is_bad_issue ( text : & str , report_fixme : ReportTactic ) -> bool {
203
- let mut seeker = BadIssueSeeker :: new ( report_fixme ) ;
172
+ fn is_bad_issue ( text : & str ) -> bool {
173
+ let mut seeker = BadIssueSeeker :: new ( ) ;
204
174
text. chars ( ) . any ( |c| seeker. inspect ( c) . is_some ( ) )
205
175
}
206
-
207
- assert ! ( is_bad_issue( "This is a FIXME(#1)\n " , ReportTactic :: Always ) ) ;
208
-
209
- assert ! ( is_bad_issue(
210
- "This is a FixMe(#1) mixed case\n " ,
211
- ReportTactic :: Always ,
212
- ) ) ;
213
-
214
- assert ! ( !is_bad_issue( "bad FIXME\n " , ReportTactic :: Never ) ) ;
215
176
}
216
177
217
178
#[ test]
218
179
fn issue_type ( ) {
219
- let mut seeker = BadIssueSeeker :: new ( ReportTactic :: Unnumbered ) ;
180
+ let seeker = BadIssueSeeker :: new ( ) ;
220
181
let expected = Some ( Issue {
221
- issue_type : IssueType :: Fixme ,
182
+ issue_type : None ,
222
183
missing_number : true ,
223
184
} ) ;
224
-
225
- assert_eq ! (
226
- expected,
227
- "Test. FIXME: bad, bad, not good"
228
- . chars( )
229
- . map( |c| seeker. inspect( c) )
230
- . find( Option :: is_some)
231
- . unwrap( )
232
- ) ;
233
185
}
0 commit comments