summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Ernerfeldt <emil.ernerfeldt@gmail.com>2024-03-26 11:48:24 +0100
committerGitHub <noreply@github.com>2024-03-26 11:48:24 +0100
commitf8d7d0ebaa9f991d9796f379fdee9c1014e5d009 (patch)
tree1c100f789ed3205d1665ba8b8ed316d4082dbe7a
parent8a10f81ca01b2ba4e0bd6e08d02fdd2063f1ddcc (diff)
Enforce writing username in TODO comments (#4235)
-rw-r--r--crates/eframe/src/web/events.rs4
-rw-r--r--crates/egui-winit/src/lib.rs4
-rw-r--r--crates/egui/src/context.rs2
-rw-r--r--crates/egui/src/input_state.rs2
-rw-r--r--crates/egui/src/interaction.rs4
-rw-r--r--crates/egui/src/memory.rs2
-rw-r--r--crates/egui/src/text_selection/label_text_selection.rs6
-rw-r--r--crates/egui/src/widgets/image.rs2
-rw-r--r--crates/egui/src/widgets/text_edit/builder.rs2
-rw-r--r--crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs2
-rw-r--r--crates/egui_extras/src/loaders.rs2
-rw-r--r--crates/egui_plot/src/axis.rs4
-rw-r--r--crates/egui_plot/src/items/values.rs2
-rw-r--r--crates/egui_plot/src/lib.rs2
-rw-r--r--crates/epaint/src/stats.rs2
-rw-r--r--crates/epaint/src/tessellator.rs2
-rw-r--r--crates/epaint/src/text/text_layout.rs2
-rw-r--r--examples/test_viewports/src/main.rs2
-rwxr-xr-xscripts/lint.py8
19 files changed, 31 insertions, 25 deletions
diff --git a/crates/eframe/src/web/events.rs b/crates/eframe/src/web/events.rs
index 5e5f7b22..30775733 100644
--- a/crates/eframe/src/web/events.rs
+++ b/crates/eframe/src/web/events.rs
@@ -88,7 +88,7 @@ pub(crate) fn install_document_events(runner_ref: &WebRunner) -> Result<(), JsVa
if let Some(key) = egui_key {
runner.input.raw.events.push(egui::Event::Key {
key,
- physical_key: None, // TODO
+ physical_key: None, // TODO(fornwall)
pressed: true,
repeat: false, // egui will fill this in for us!
modifiers,
@@ -155,7 +155,7 @@ pub(crate) fn install_document_events(runner_ref: &WebRunner) -> Result<(), JsVa
if let Some(key) = translate_key(&event.key()) {
runner.input.raw.events.push(egui::Event::Key {
key,
- physical_key: None, // TODO
+ physical_key: None, // TODO(fornwall)
pressed: false,
repeat: false,
modifiers,
diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs
index 418c39ec..41db0495 100644
--- a/crates/egui-winit/src/lib.rs
+++ b/crates/egui-winit/src/lib.rs
@@ -308,7 +308,7 @@ impl State {
consumed: false,
}
}
- // WindowEvent::TouchpadPressure {device_id, pressure, stage, .. } => {} // TODO
+ // WindowEvent::TouchpadPressure {device_id, pressure, stage, .. } => {} // TODO(emilk)
WindowEvent::Touch(touch) => {
self.on_touch(window, touch);
let consumed = match touch.phase {
@@ -1298,7 +1298,7 @@ fn process_viewport_command(
ViewportCommand::StartDrag => {
// If `is_viewport_focused` is not checked on x11 the input will be permanently taken until the app is killed!
- // TODO: check that the left mouse-button was pressed down recently,
+ // TODO(emilk): check that the left mouse-button was pressed down recently,
// or we will have bugs on Windows.
// See https://github.com/emilk/egui/pull/1108
if is_viewport_focused {
diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs
index ea61cd7d..258c39bf 100644
--- a/crates/egui/src/context.rs
+++ b/crates/egui/src/context.rs
@@ -2770,7 +2770,7 @@ impl Context {
/// The `Context` lock is held while the given closure is called!
///
/// Returns `None` if acesskit is off.
- // TODO: consider making both RO and RW versions
+ // TODO(emilk): consider making both RO and RW versions
#[cfg(feature = "accesskit")]
pub fn accesskit_node_builder<R>(
&self,
diff --git a/crates/egui/src/input_state.rs b/crates/egui/src/input_state.rs
index 2a196c86..b2284d45 100644
--- a/crates/egui/src/input_state.rs
+++ b/crates/egui/src/input_state.rs
@@ -236,7 +236,7 @@ impl InputState {
// So we smooth it out over several frames for a nicer user experience when scrolling in egui.
unprocessed_scroll_delta += raw_scroll_delta;
let dt = stable_dt.at_most(0.1);
- let t = crate::emath::exponential_smooth_factor(0.90, 0.1, dt); // reach _% in _ seconds. TODO: parameterize
+ let t = crate::emath::exponential_smooth_factor(0.90, 0.1, dt); // reach _% in _ seconds. TODO(emilk): parameterize
for d in 0..2 {
if unprocessed_scroll_delta[d].abs() < 1.0 {
diff --git a/crates/egui/src/interaction.rs b/crates/egui/src/interaction.rs
index d5812d4d..8ee3f259 100644
--- a/crates/egui/src/interaction.rs
+++ b/crates/egui/src/interaction.rs
@@ -247,8 +247,8 @@ pub(crate) fn interact(
hits.click.iter().chain(&hits.drag).map(|w| w.id).collect()
} else {
// Whatever is topmost is what we are hovering.
- // TODO: consider handle hovering over multiple top-most widgets?
- // TODO: allow hovering close widgets?
+ // TODO(emilk): consider handle hovering over multiple top-most widgets?
+ // TODO(emilk): allow hovering close widgets?
hits.contains_pointer
.last()
.map(|w| w.id)
diff --git a/crates/egui/src/memory.rs b/crates/egui/src/memory.rs
index 068347b5..dc611787 100644
--- a/crates/egui/src/memory.rs
+++ b/crates/egui/src/memory.rs
@@ -243,7 +243,7 @@ impl Options {
pub fn ui(&mut self, ui: &mut crate::Ui) {
let Self {
style, // covered above
- zoom_factor: _, // TODO
+ zoom_factor: _, // TODO(emilk)
zoom_with_keyboard,
tessellation_options,
repaint_on_widget_change,
diff --git a/crates/egui/src/text_selection/label_text_selection.rs b/crates/egui/src/text_selection/label_text_selection.rs
index af9e3039..ec5a4729 100644
--- a/crates/egui/src/text_selection/label_text_selection.rs
+++ b/crates/egui/src/text_selection/label_text_selection.rs
@@ -8,7 +8,7 @@ use super::{
};
/// Turn on to help debug this
-const DEBUG: bool = false; // TODO: don't merge this while `true`
+const DEBUG: bool = false; // Don't merge `true`!
fn paint_selection(
ui: &Ui,
@@ -169,7 +169,7 @@ impl LabelSelectionState {
if ctx.input(|i| i.pointer.any_pressed() && !i.modifiers.shift) {
// Maybe a new selection is about to begin, but the old one is over:
- // state.selection = None; // TODO: this makes sense, but doesn't work as expected.
+ // state.selection = None; // TODO(emilk): this makes sense, but doesn't work as expected.
}
state.selection_bbox_last_frame = state.selection_bbox_this_frame;
@@ -562,7 +562,7 @@ impl LabelSelectionState {
old.widget_id != new_primary.widget_id || old.ccursor != new_primary.ccursor
});
if primary_changed && new_primary.widget_id == widget_id {
- let is_fully_visible = ui.clip_rect().contains_rect(response.rect); // TODO: remove this HACK workaround for https://github.com/emilk/egui/issues/1531
+ let is_fully_visible = ui.clip_rect().contains_rect(response.rect); // TODO(emilk): remove this HACK workaround for https://github.com/emilk/egui/issues/1531
if selection_changed && !is_fully_visible {
// Scroll to keep primary cursor in view:
let row_height = estimate_row_height(galley);
diff --git a/crates/egui/src/widgets/image.rs b/crates/egui/src/widgets/image.rs
index 1d1ec581..90176018 100644
--- a/crates/egui/src/widgets/image.rs
+++ b/crates/egui/src/widgets/image.rs
@@ -452,7 +452,7 @@ impl ImageSize {
}
}
-// TODO: unit-tests
+// TODO(jprochazk): unit-tests
fn scale_to_fit(image_size: Vec2, available_size: Vec2, maintain_aspect_ratio: bool) -> Vec2 {
if maintain_aspect_ratio {
let ratio_x = available_size.x / image_size.x;
diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs
index bed9b6a6..e5745389 100644
--- a/crates/egui/src/widgets/text_edit/builder.rs
+++ b/crates/egui/src/widgets/text_edit/builder.rs
@@ -687,7 +687,7 @@ impl<'t> TextEdit<'t> {
let primary_cursor_rect =
cursor_rect(galley_pos, &galley, &cursor_range.primary, row_height);
- let is_fully_visible = ui.clip_rect().contains_rect(rect); // TODO: remove this HACK workaround for https://github.com/emilk/egui/issues/1531
+ let is_fully_visible = ui.clip_rect().contains_rect(rect); // TODO(emilk): remove this HACK workaround for https://github.com/emilk/egui/issues/1531
if (response.changed || selection_changed) && !is_fully_visible {
// Scroll to keep primary cursor in view:
ui.scroll_to_rect(primary_cursor_rect, None);
diff --git a/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs b/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs
index 0971abd4..2a44d78f 100644
--- a/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs
+++ b/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs
@@ -261,7 +261,7 @@ The style characters are chosen to be similar to what they are representing:
`$` = $small$
`^` = ^raised^
-# TODO
+# To do
- Sub-headers (`## h2`, `### h3` etc)
- Hotkey Editor
- International keyboard algorithm for non-letter keys
diff --git a/crates/egui_extras/src/loaders.rs b/crates/egui_extras/src/loaders.rs
index cc775a2c..05df9bc8 100644
--- a/crates/egui_extras/src/loaders.rs
+++ b/crates/egui_extras/src/loaders.rs
@@ -1,4 +1,4 @@
-// TODO: automatic cache eviction
+// TODO(jprochazk): automatic cache eviction
/// Installs a set of image loaders.
///
diff --git a/crates/egui_plot/src/axis.rs b/crates/egui_plot/src/axis.rs
index df182631..3c2972e6 100644
--- a/crates/egui_plot/src/axis.rs
+++ b/crates/egui_plot/src/axis.rs
@@ -106,7 +106,7 @@ pub struct AxisHints {
pub(super) label_spacing: Rangef,
}
-// TODO: this just a guess. It might cease to work if a user changes font size.
+// TODO(JohannesProgrammiert): this just a guess. It might cease to work if a user changes font size.
const LINE_HEIGHT: f32 = 12.0;
impl AxisHints {
@@ -366,7 +366,7 @@ impl AxisWidget {
match HPlacement::from(self.hints.placement) {
HPlacement::Left => {
- let angle = 0.0; // TODO: allow users to rotate text
+ let angle = 0.0; // TODO(emilk): allow users to rotate text
if angle == 0.0 {
let x = self.rect.max.x - galley.size().x;
diff --git a/crates/egui_plot/src/items/values.rs b/crates/egui_plot/src/items/values.rs
index 8ed6d38f..5f9fe818 100644
--- a/crates/egui_plot/src/items/values.rs
+++ b/crates/egui_plot/src/items/values.rs
@@ -156,7 +156,7 @@ impl Default for Orientation {
pub enum PlotPoints {
Owned(Vec<PlotPoint>),
Generator(ExplicitGenerator),
- // Borrowed(&[PlotPoint]), // TODO: Lifetimes are tricky in this case.
+ // Borrowed(&[PlotPoint]), // TODO(EmbersArc): Lifetimes are tricky in this case.
}
impl Default for PlotPoints {
diff --git a/crates/egui_plot/src/lib.rs b/crates/egui_plot/src/lib.rs
index ed133d7e..e9962c84 100644
--- a/crates/egui_plot/src/lib.rs
+++ b/crates/egui_plot/src/lib.rs
@@ -800,7 +800,7 @@ impl Plot {
let plot_id = id.unwrap_or_else(|| ui.make_persistent_id(id_source));
let ([x_axis_widgets, y_axis_widgets], plot_rect) = axis_widgets(
- PlotMemory::load(ui.ctx(), plot_id).as_ref(), // TODO: avoid loading plot memory twice
+ PlotMemory::load(ui.ctx(), plot_id).as_ref(), // TODO(emilk): avoid loading plot memory twice
show_axes,
complete_rect,
[&x_axes, &y_axes],
diff --git a/crates/epaint/src/stats.rs b/crates/epaint/src/stats.rs
index 3bb51e14..c63d5a0d 100644
--- a/crates/epaint/src/stats.rs
+++ b/crates/epaint/src/stats.rs
@@ -192,7 +192,7 @@ impl PaintStats {
fn add(&mut self, shape: &Shape) {
match shape {
Shape::Vec(shapes) => {
- // self += PaintStats::from_shapes(&shapes); // TODO
+ // self += PaintStats::from_shapes(&shapes); // TODO(emilk)
self.shapes += AllocInfo::from_slice(shapes);
self.shape_vec += AllocInfo::from_slice(shapes);
for shape in shapes {
diff --git a/crates/epaint/src/tessellator.rs b/crates/epaint/src/tessellator.rs
index bf419e99..49d5ab8a 100644
--- a/crates/epaint/src/tessellator.rs
+++ b/crates/epaint/src/tessellator.rs
@@ -1864,7 +1864,7 @@ impl Tessellator {
.filter(|(_, clipped_shape)| should_parallelize(&clipped_shape.shape))
.map(|(index, clipped_shape)| {
crate::profile_scope!("tessellate_big_shape");
- // TODO: reuse tessellator in a thread local
+ // TODO(emilk): reuse tessellator in a thread local
let mut tessellator = (*self).clone();
let mut mesh = Mesh::default();
tessellator.tessellate_shape(clipped_shape.shape.clone(), &mut mesh);
diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs
index 9b055edc..322026da 100644
--- a/crates/epaint/src/text/text_layout.rs
+++ b/crates/epaint/src/text/text_layout.rs
@@ -960,7 +960,7 @@ fn is_kana(c: char) -> bool {
#[inline]
fn is_cjk(c: char) -> bool {
- // TODO: Add support for Korean Hangul.
+ // TODO(bigfarts): Add support for Korean Hangul.
is_cjk_ideograph(c) || is_kana(c)
}
diff --git a/examples/test_viewports/src/main.rs b/examples/test_viewports/src/main.rs
index 69be9177..05679668 100644
--- a/examples/test_viewports/src/main.rs
+++ b/examples/test_viewports/src/main.rs
@@ -441,7 +441,7 @@ fn drag_source<R>(
}
}
-// TODO: Update to be more like `crates/egui_demo_lib/src/debo/drag_and_drop.rs`
+// TODO(emilk): Update to be more like `crates/egui_demo_lib/src/debo/drag_and_drop.rs`
fn drop_target<R>(
ui: &mut egui::Ui,
body: impl FnOnce(&mut egui::Ui) -> R,
diff --git a/scripts/lint.py b/scripts/lint.py
index 59322ad2..221d980d 100755
--- a/scripts/lint.py
+++ b/scripts/lint.py
@@ -36,7 +36,7 @@ def lint_lines(filepath, lines_in):
for line_nr, line in enumerate(lines_in):
line_nr = line_nr + 1
- # TODO: only # and /// on lines before a keyword
+ # TODO(emilk): only # and /// on lines before a keyword
pattern = (
r"^\s*((///)|((pub(\(\w*\))? )?((impl|fn|struct|enum|union|trait)\b))).*$"
@@ -66,6 +66,12 @@ def lint_lines(filepath, lines_in):
)
lines_out.append("#[inline]")
+
+ if re.search(r"TODO[^(]", line):
+ errors.append(
+ f"{filepath}:{line_nr}: write 'TODO(username):' instead"
+ )
+
if (
"(target_os" in line
and filepath.startswith("./crates/egui/")