Skip to content

Commit 882b7e0

Browse files
authored
refactor: Move TextField.maybeNegate() to end and make static (#1044)
* refactor: Move private method maybeNegate() to end of TextField This was code review feedback on #790 * refactor: Make method maybeNegate() static, as spotted by WebStorm
1 parent a5d7bff commit 882b7e0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Query/Filter/TextField.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ import { FilterOrErrorMessage } from './Filter';
88
* value, such as the description or file path.
99
*/
1010
export abstract class TextField extends Field {
11-
private maybeNegate(match: boolean, filterMethod: String) {
12-
return filterMethod.match(/not/) ? !match : match;
13-
}
1411
public createFilterOrErrorMessage(line: string): FilterOrErrorMessage {
1512
const result = new FilterOrErrorMessage();
1613
const match = Field.getMatch(this.filterRegexp(), line);
1714
if (match !== null) {
1815
const filterMethod = match[1];
1916
if (['includes', 'does not include'].includes(filterMethod)) {
2017
result.filter = (task: Task) =>
21-
this.maybeNegate(
18+
TextField.maybeNegate(
2219
TextField.stringIncludesCaseInsensitive(
2320
this.value(task),
2421
match[2],
@@ -35,7 +32,7 @@ export abstract class TextField extends Field {
3532

3633
if (query !== null) {
3734
result.filter = (task: Task) =>
38-
this.maybeNegate(
35+
TextField.maybeNegate(
3936
this.value(task).match(
4037
new RegExp(query[1], query[2]),
4138
) !== null,
@@ -76,4 +73,8 @@ export abstract class TextField extends Field {
7673
* @protected
7774
*/
7875
protected abstract value(task: Task): string;
76+
77+
private static maybeNegate(match: boolean, filterMethod: String) {
78+
return filterMethod.match(/not/) ? !match : match;
79+
}
7980
}

0 commit comments

Comments
 (0)