Skip to content

buffrs lint exits 0 on rule violations #322

Open

Description

@overby-me

Summary

lint() collects violations, prints them, and unconditionally returns Ok(()) (command.rs:401-419):

violations
    .into_iter()
    .map(miette::Report::new)
    .for_each(|r| eprintln!("{r:?}"));

Ok(())

So lint cannot gate CI without scraping output.

Reproduction

buffrs init --lib my-protos
cd my-protos
printf 'syntax = "proto3";\npackage wrongpkg;\nmessage Foo { string bar = 1; }\n' > proto/my_protos.proto
buffrs lint; echo "exit=$?"
PackageName (https://helsing-ai.github.io/buffrs/reference/protocol-buffer-rules.html)

  × Make sure that the protobuf package name matches the buffer package name.
  ╰─▶   × package name is wrongpkg but should have my_protos prefix

   ╭─[my-protos/my_protos.proto:1:1]
   ╰────
exit=0

Note the violation goes to stderr, not stdout, so the obvious buffrs lint | grep ... workaround silently passes.

Expected

Non-zero exit when one or more violations are reported.

Actual

exit=0 regardless of violation count.

Impact

CI must do buffrs lint 2>&1 | grep -q '×' && exit 1, which is fragile and breaks on any output format change. Consumers are effectively unable to enforce lint.

Suggested fix

Return a non-zero exit status when the violation count is greater than zero. Since rules carry a severity Level already, gate on Level::Error by default and add --deny warnings / --allow warnings to make the threshold configurable.

Side note

While writing this I noticed IdentCasing is registered in the rule set but its check_entity returns Default::default() — identifier casing is never actually checked. That is a separate bug; happy to file it separately if useful.

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