Skip to content

Panic when rule violation and no newline #425

@Khauri

Description

@Khauri

The following sql seems to panic unless a newline is included at the end of the file and only when a violation occurs. In this case I believe it reports both prefer-bigint and prefer-bigint-over-int. I have not tested with other rules.

ALTER TABLE test ADD COLUMN IF NOT EXISTS test INTEGER;

Error:

RUST_BACKTRACE=full npx squawk "test.sql"

thread 'main' panicked at cli/src/reporter.rs:399:25:
byte index 56 is out of bounds of `ALTER TABLE test ADD COLUMN IF NOT EXISTS test INTEGER;`
stack backtrace:
   0:        0x10120d98c - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hadba1856081fe8dc
   1:        0x101229dac - core::fmt::write::h5358bd20891469bc
   2:        0x10120a9e0 - std::io::Write::write_fmt::hbf0611cc5d72cc91
   3:        0x10120d840 - std::sys::backtrace::BacktraceLock::print::he2302a8c253c9a13
   4:        0x10120e78c - std::panicking::default_hook::{{closure}}::hec1f77a77d7e7ffc
   5:        0x10120e5c0 - std::panicking::default_hook::hdd59ab537dd27efb
   6:        0x10120ef7c - std::panicking::rust_panic_with_hook::h533a16f5f89e4278
   7:        0x10120ebf4 - std::panicking::begin_panic_handler::{{closure}}::h168c3a4362c8e4df
   8:        0x10120de50 - std::sys::backtrace::__rust_end_short_backtrace::h601e3529ca2053df
   9:        0x10120e8ac - _rust_begin_unwind
  10:        0x101242eb8 - core::panicking::panic_fmt::ha0f8363f677e0181
  11:        0x10122d778 - core::str::slice_error_fail_rt::h0afb9617ef8df6ae
  12:        0x1012432f8 - core::str::slice_error_fail::h02d4e1a395d5da1c
  13:        0x100f526d0 - <alloc::vec::into_iter::IntoIter<T,A> as core::iter::traits::iterator::Iterator>::fold::h4a1f27ac716fb297
  14:        0x100f32e1c - alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter::h5463917b03a28084
  15:        0x100f2c798 - squawk::reporter::process_violations::h9fb7de0f2e62a211
  16:        0x100f2cf14 - squawk::reporter::check_files::hd47696d5d3352d7f
  17:        0x100f50874 - squawk::main::he80031d6fa351c13
  18:        0x100f4dbc0 - std::sys::backtrace::__rust_begin_short_backtrace::hb6d10e075181b9fe
  19:        0x100f4c89c - std::rt::lang_start::{{closure}}::h8d9e51d31de07706
  20:        0x101205908 - std::rt::lang_start_internal::hacda2dedffd2edb4
  21:        0x100f52080 - _main

Additionally, after adding a newline, the reported violation seems to point to the wrong line.

Additional Info

Squawk Version: 1.6.0
OS: macOS 15.3.2
Node / NPM Version: v20.19.0 / 10.8.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions