Skip to content

Commit 6230ecb

Browse files
authored
Forbid TODOs in the codebase (#1921)
- Fixes #1920 Here's a screenshot of a failed run: <img width="1218" alt="image" src="https://github.com/cursorless-dev/cursorless/assets/755842/7b12179c-0582-4cf8-ba7d-59ef4a2e453e"> ## Checklist - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [-] I have not broken the cheatsheet
1 parent 1164e2f commit 6230ecb

File tree

10 files changed

+25
-13
lines changed

10 files changed

+25
-13
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,5 @@ jobs:
7272
name: dumps
7373
path: ${{ env.VSCODE_CRASH_DIR }}
7474
if: failure()
75+
- name: Forbid TODOs
76+
run: ./scripts/forbid-todo.sh

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ repos:
3232
exclude_types: [svg]
3333
exclude: patches/.*\.patch
3434
- id: fix-byte-order-marker
35+
- id: forbid-submodules
3536
- id: mixed-line-ending
3637
- id: trailing-whitespace
3738
# Trailing whitespace breaks yaml files if you use a multiline string

cursorless-talon-dev/src/default_vocabulary.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313

1414
# https://github.com/talonhub/community/blob/9acb6c9659bb0c9b794a7b7126d025603b4ed726/core/keys/keys.py#L139C1-L171C2
1515
punctuation_words = {
16-
# TODO: I'm not sure why we need these, I think it has something to do with
17-
# Dragon. Possibly it has been fixed by later improvements to talon? -rntz
18-
# "`": "`",
19-
# ",": ",", # <== these things
2016
"back tick": "`",
2117
"comma": ",",
2218
# Workaround for issue with conformer b-series; see #946

packages/common/src/testUtil/TestCaseSnapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type TestCaseSnapshot = {
99
documentContents: string;
1010
selections: SelectionPlainObject[];
1111
clipboard?: string;
12-
// TODO Visible ranges are not asserted during testing, see:
12+
// FIXME Visible ranges are not asserted during testing, see:
1313
// https://github.com/cursorless-dev/cursorless/issues/160
1414
visibleRanges?: RangePlainObject[];
1515
marks?: SerializedMarks;

packages/cursorless-engine/src/core/updateSelections/updateSelections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ async function performEditsAndUpdateInternal(
330330
return selectionInfosToSelections(selectionInfoMatrix);
331331
}
332332

333-
// TODO: Remove this function if we don't end up using it for the next couple use cases, eg `that` mark and cursor history
333+
// FIXME: Remove this function if we don't end up using it for the next couple use cases, eg `that` mark and cursor history
334334
export async function performEditsAndUpdateSelectionInfos(
335335
rangeUpdater: RangeUpdater,
336336
editor: EditableTextEditor,

packages/cursorless-engine/src/languages/clojure.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function indexNodeFinder(
5858
const nodeIndex = valueNodes.findIndex(({ id }) => id === node.id);
5959

6060
if (nodeIndex === -1) {
61-
// TODO: In the future we might conceivably try to handle saying "take
61+
// FIXME: In the future we might conceivably try to handle saying "take
6262
// item" when the selection is inside a comment between the key and value
6363
return null;
6464
}
@@ -154,7 +154,7 @@ const nodeMatchers: Partial<
154154
),
155155
value: matcher(mapParityNodeFinder(1)),
156156

157-
// TODO: Handle formal parameters
157+
// FIXME: Handle formal parameters
158158
argumentOrParameter: matcher(
159159
indexNodeFinder(patternFinder(functionCallPattern), (nodeIndex: number) =>
160160
nodeIndex !== 0 ? nodeIndex : -1,
@@ -176,7 +176,7 @@ const nodeMatchers: Partial<
176176

177177
functionName: functionNameMatcher,
178178

179-
// TODO: Handle `let` declarations, defs, etc
179+
// FIXME: Handle `let` declarations, defs, etc
180180
name: functionNameMatcher,
181181

182182
anonymousFunction: cascadingMatcher(

packages/cursorless-engine/src/processTargets/targets/ParagraphTarget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default class ParagraphTarget extends BaseTarget<CommonTargetParameters>
3434
}
3535

3636
getRemovalRange(): Range {
37-
// TODO: In the future we could get rid of this function if {@link
37+
// FIXME: In the future we could get rid of this function if {@link
3838
// getDelimitedSequenceRemovalRange} made a continuous range from the target
3939
// past its delimiter target and then used the removal range of that.
4040
const delimiterTarget =

packages/cursorless-vscode-e2e/src/suite/recorded.vscode.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function runTest(file: string, spyIde: SpyIDE) {
6868
const fixture = yaml.load(buffer.toString()) as TestCaseFixtureLegacy;
6969
const excludeFields: ExcludableSnapshotField[] = [];
7070

71-
// TODO The snapshot gets messed up with timing issues when running the recorded tests
71+
// FIXME The snapshot gets messed up with timing issues when running the recorded tests
7272
// "Couldn't find token default.a"
7373
const usePrePhraseSnapshot = false;
7474

@@ -180,7 +180,7 @@ async function runTest(file: string, spyIde: SpyIDE) {
180180
excludeFields.push("instanceReferenceMark");
181181
}
182182

183-
// TODO Visible ranges are not asserted, see:
183+
// FIXME Visible ranges are not asserted, see:
184184
// https://github.com/cursorless-dev/cursorless/issues/160
185185
const { visibleRanges, ...resultState } = await takeSnapshot(
186186
excludeFields,

packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function getViewColumn(editor: TextEditor): ViewColumn | undefined {
5353
if (editor.viewColumn != null) {
5454
return editor.viewColumn;
5555
}
56-
// TODO: tabGroups is not available on older versions of vscode we still support.
56+
// FIXME: tabGroups is not available on older versions of vscode we still support.
5757
// Remove any cast as soon as version is updated.
5858
if (semver.lt(version, "1.67.0")) {
5959
return undefined;

scripts/forbid-todo.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
# Fail if there are any TODOs in the codebase
4+
5+
# Find the string 'TODO' in all files tracked by git, excluding
6+
# this file
7+
TODOS_FOUND=$(git grep --color=always -nw TODO -- ':!scripts/forbid-todo.sh' || true)
8+
9+
if [ -n "$TODOS_FOUND" ]; then
10+
printf "\e[1;31mERROR: \e[0mTODOs found in codebase:\n"
11+
printf '%s\n' "$TODOS_FOUND"
12+
exit 1
13+
fi

0 commit comments

Comments
 (0)