Skip to content

Commit

Permalink
Enforce writing username in TODO comments (#4235)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk authored Mar 26, 2024
1 parent 8a10f81 commit f8d7d0e
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 25 deletions.
4 changes: 2 additions & 2 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/input_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions crates/egui/src/text_selection/label_text_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/widgets/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO: automatic cache eviction
// TODO(jprochazk): automatic cache eviction

/// Installs a set of image loaders.
///
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_plot/src/axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_plot/src/items/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion crates/epaint/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/epaint/src/tessellator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion crates/epaint/src/text/text_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/test_viewports/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion scripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))).*$"
Expand Down Expand Up @@ -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/")
Expand Down

0 comments on commit f8d7d0e

Please sign in to comment.