Skip to content

Limitations of relying solely on AST #65

@KurtWagner

Description

@KurtWagner

Tracking bug for limitations associated with relying solely on the Zig AST. Ideally these would be solved by moving closer to the build system and compiler.

The bug description will be updated over time:

  • exclude_test features - excluding code dedicated to testing may have limitations without some sort of multi build system where builds are compared to see what only appears in what (This could also have false positives due to logic being unused and only used in tests -which could be a lint rule itself but definitely needs some sort of multibuild)

    • Simple case like if its encased in test {...} block is fairly trivial but not whether its only ever called from within a test { ... } or whether its excluded by some build time flag like builtin.is_test
  • exclude_debug similar to exclude test excluding based on whether builtin.mode is debug is limited

  • no_unused rule is limited in that it can't inform you whether it's unused in everything except tests, which will give false negatives if your project is well tested, i.e., always referenced by some test. Potentially this could be improved by ignoring references in test { ... } blocks but it wouldn't be perfect

  • The potential no_dead_branches has a similar issue to no_unused in that you probably could get an idea whether something is truly dead (e.g., if (true) and maybe some simple cases of if (local_var_never_set_to_false)) but to do well we really want to to see whether its dead in all builds and would be far easier to rely on the compiler than to try and do it ourselves with the AST

Metadata

Metadata

Assignees

No one assigned

    Labels

    designSomething needing thoughtdocumentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions