Skip to content

Code quality issue: inconsistent Ruby to Rust string conversion #107

@nickysn

Description

@nickysn

This is a refactor task.

The code in gems/codetracer-ruby-recorder/ext/native_tracer/src/lib.rs contains several similar repeated patterns of code for converting from Ruby strings to Rust strings. To reveal them, search for RSTRING_PTR in the code. These patters should probably be unified and extracted to a function or two. However, they differ in various corner cases, so we should carefully decide which version to use:

  1. Some convert NIL values to "", some don't bother with this check.
  2. Some use String::from_utf8_lossy, others use std::str::from_utf8. These vary in the way they handle invalid UTF-8 data.
  3. Some convert non-string types to string, others don't.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions