Skip to content

Conversation

@rami3l
Copy link

@rami3l rami3l commented Aug 11, 2025

Note

This PR was made by an LLM agent.

  • Fix type mismatch errors in reader.mbt by using Int::unsafe_to_char() for String indexing
  • Replace deprecated @math.minimum with @cmp.minimum in nyacsv.mbt
  • Replace deprecated @math.maximum with @cmp.maximum in nyacsv.mbt
  • Replace deprecated Bytes::of_string with str.to_bytes() in nyacsv.mbt and test files

All tests continue to pass after these fixes.

moonagent added 2 commits August 11, 2025 06:51
- Fix type mismatch errors in reader.mbt by using Int::unsafe_to_char() for String indexing
- Replace deprecated @math.minimum with @cmp.minimum in nyacsv.mbt
- Replace deprecated @math.maximum with @cmp.maximum in nyacsv.mbt
- Replace deprecated Bytes::of_string with str.to_bytes() in nyacsv.mbt and test files

All tests continue to pass after these fixes.
@rami3l rami3l added the moonagent Created by MoonAgent. label Aug 11, 2025
@peter-jerry-ye-code-review
Copy link

Potential unsafe character conversion without bounds checking

Category
Correctness
Code Snippet
impl CSVReader for StringReader with read_char(self) -> Char? {
if self.pos < self.source.length() {
let ch = Int::unsafe_to_char(self.source[self.pos])
self.pos += 1
Some(ch)
} else {
None
}
}
Recommendation
Consider adding validation or using a safe conversion method if available, or document why unsafe conversion is acceptable here
Reasoning
The use of Int::unsafe_to_char() suggests this conversion bypasses safety checks. While the bounds check ensures we're within string length, there's no validation that the integer value represents a valid character.

Inconsistent trailing comma usage in function parameters

Category
Maintainability
Code Snippet
pub fn CSV::from_array(
data : Array[Array[String]],
has_header~ : Bool = true,
generate_headers~ : Bool = true,
) -> CSV {
Recommendation
Remove the trailing comma after the last parameter to maintain consistency with other function definitions in the codebase
Reasoning
Most other function definitions in the diff don't use trailing commas on parameters. Consistency in code style improves readability and reduces cognitive load.

Duplicate test function names could cause confusion

Category
Maintainability
Code Snippet
test "CSV::parse_string/quoted_with_internal_quotes" {
let data = "a,b\n1,"ha ""ha"" ha"\n3,4\n"
let csv = CSV::parse_string(data)
// ... same test repeated twice
Recommendation
Remove the duplicate test or rename one of them to test a different scenario
Reasoning
Having two identical test functions with the same name can lead to confusion and one test potentially overriding the other depending on the test framework behavior.

@rami3l rami3l requested a review from xunyoyo August 11, 2025 07:04
@xunyoyo xunyoyo merged commit 752da7b into main Aug 12, 2025
1 check passed
@rami3l rami3l deleted the fix-compiler-warnings-20250811-065657 branch August 12, 2025 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

moonagent Created by MoonAgent.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants