Skip to content

Track remaining lint ideas #235

Open

Description

@Rigidity

Tracks the lint ideas that weren't in #234.

Correctness and security

  • unchecked_puzzle_call (or untrusted_tree_hash): a function-typed value (for example an inner_puzzle parameter of main) is called, but its tree_hash is never compared against a curried or otherwise trusted hash. This is the classic puzzle bug. It needs a dataflow analysis to avoid false positives. A first version could flag function-typed parameters of entrypoints that are called but never passed to tree_hash.
  • discarded_condition: a Condition struct is built but never reaches the returned condition list. For example, it's only used in a branch that drops it. unused_binding doesn't catch this when the binding is used.
  • non_exhaustive_union_guard: an if x is A { .. } else if x is B { .. } chain over A | B | C that never handles C and falls into a raise. This would build on the existing narrowing.

Style

  • bool_bitwise_operator: & / | on Bool. This needs care, since & is used on purpose to avoid branching (for example parent_is_cat & (extra_delta == 0) in examples/puzzles/cat.rue). It should be allow by default, or only fire when the right side may raise or is expensive enough that short-circuiting matters.
  • missing_entrypoint_return_type: entrypoints whose return type is Any or inferred, since puzzle outputs should be explicit.

Follow-ups from #234

  • Lint groups for the new lints (for example style and complexity), so they can be turned off together.
  • Configurable thresholds for large_inline, which currently uses fixed HIR node counts. A size estimate based on the lowered code would also be more meaningful than HIR nodes.
  • repeated_expensive_call could use a cost model, rather than treating every function call as expensive.

Cleanups from #234

  • Hir::children() allocates a Vec for every node that the lint walk visits. An iterator or a callback would avoid that.
  • Skipping a struct's default field values is implemented twice, in crates/rue-lint/src/visit.rs and crates/rue-lint/src/lints/recursion.rs. It should be one shared helper.
  • unnecessary_parens in crates/rue-lint/src/lints/syntax.rs has its own copy of the word spacing check. separate_words in crates/rue-lint/src/context.rs already does this for every machine-applicable suggestion, so the lint can rely on it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions