Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid TODOs in the codebase #1921

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ jobs:
name: dumps
path: ${{ env.VSCODE_CRASH_DIR }}
if: failure()
- name: Forbid TODOs
run: ./scripts/forbid-todo.sh
Comment on lines +75 to +76
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added to test workflow rather than pre-commit because if someone has our pre-commit hooks installed locally, we don't want to forbid them from commiting a TODO; we just want to ensure it doesn't get merged

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could still commit skipping the pre-commit hook? i.e. git commit --no-verify

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but I feel that fundamentally it's not a pre-commit requirement. It's a pre-merge requirement. Committing unfinished stuff is totally fine 🤷‍♂️

1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repos:
exclude_types: [svg]
exclude: patches/.*\.patch
- id: fix-byte-order-marker
- id: forbid-submodules
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found this one while looking for a pre-commit hook; seemed worth having

- id: mixed-line-ending
- id: trailing-whitespace
# Trailing whitespace breaks yaml files if you use a multiline string
Expand Down
4 changes: 0 additions & 4 deletions cursorless-talon-dev/src/default_vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

# https://github.com/talonhub/community/blob/9acb6c9659bb0c9b794a7b7126d025603b4ed726/core/keys/keys.py#L139C1-L171C2
punctuation_words = {
# TODO: I'm not sure why we need these, I think it has something to do with
# Dragon. Possibly it has been fixed by later improvements to talon? -rntz
# "`": "`",
# ",": ",", # <== these things
"back tick": "`",
"comma": ",",
# Workaround for issue with conformer b-series; see #946
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/testUtil/TestCaseSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type TestCaseSnapshot = {
documentContents: string;
selections: SelectionPlainObject[];
clipboard?: string;
// TODO Visible ranges are not asserted during testing, see:
// FIXME Visible ranges are not asserted during testing, see:
// https://github.com/cursorless-dev/cursorless/issues/160
visibleRanges?: RangePlainObject[];
marks?: SerializedMarks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ async function performEditsAndUpdateInternal(
return selectionInfosToSelections(selectionInfoMatrix);
}

// TODO: Remove this function if we don't end up using it for the next couple use cases, eg `that` mark and cursor history
// FIXME: Remove this function if we don't end up using it for the next couple use cases, eg `that` mark and cursor history
export async function performEditsAndUpdateSelectionInfos(
rangeUpdater: RangeUpdater,
editor: EditableTextEditor,
Expand Down
6 changes: 3 additions & 3 deletions packages/cursorless-engine/src/languages/clojure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function indexNodeFinder(
const nodeIndex = valueNodes.findIndex(({ id }) => id === node.id);

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

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

functionName: functionNameMatcher,

// TODO: Handle `let` declarations, defs, etc
// FIXME: Handle `let` declarations, defs, etc
name: functionNameMatcher,

anonymousFunction: cascadingMatcher(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class ParagraphTarget extends BaseTarget<CommonTargetParameters>
}

getRemovalRange(): Range {
// TODO: In the future we could get rid of this function if {@link
// FIXME: In the future we could get rid of this function if {@link
// getDelimitedSequenceRemovalRange} made a continuous range from the target
// past its delimiter target and then used the removal range of that.
const delimiterTarget =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function runTest(file: string, spyIde: SpyIDE) {
const fixture = yaml.load(buffer.toString()) as TestCaseFixtureLegacy;
const excludeFields: ExcludableSnapshotField[] = [];

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

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

// TODO Visible ranges are not asserted, see:
// FIXME Visible ranges are not asserted, see:
// https://github.com/cursorless-dev/cursorless/issues/160
const { visibleRanges, ...resultState } = await takeSnapshot(
excludeFields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function getViewColumn(editor: TextEditor): ViewColumn | undefined {
if (editor.viewColumn != null) {
return editor.viewColumn;
}
// TODO: tabGroups is not available on older versions of vscode we still support.
// FIXME: tabGroups is not available on older versions of vscode we still support.
// Remove any cast as soon as version is updated.
if (semver.lt(version, "1.67.0")) {
return undefined;
Expand Down
13 changes: 13 additions & 0 deletions scripts/forbid-todo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail
# Fail if there are any TODOs in the codebase

# Find the string 'TODO' in all files tracked by git, excluding
# this file
TODOS_FOUND=$(git grep --color=always -nw TODO -- ':!scripts/forbid-todo.sh' || true)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to just grep all files rather than try to find lint rules for different languages, to make sure we cover everything


if [ -n "$TODOS_FOUND" ]; then
printf "\e[1;31mERROR: \e[0mTODOs found in codebase:\n"
printf '%s\n' "$TODOS_FOUND"
exit 1
fi