Skip to content

Conversation

@naitoh
Copy link
Contributor

@naitoh naitoh commented Sep 13, 2025

Why?

Improve maintainability by optimizing the process so that the parsing process proceeds using StringScanner.

## Why?
If parse_id_invalid_details_system is called, always `accept_external_id == true` and `@source.match?(Private::EXTERNAL_ID_SYSTEM_PATTERN) == true`.
# Why?
accept_external_id is always true.
# Why?
If `accept_public_id == true` and `@source.match?(Private::PUBLIC_ID_PATTERN) == true`,
the `parse_id_invalid_details_public` method is not reached.
@naitoh naitoh requested review from Copilot and kou and removed request for Copilot September 13, 2025 14:17
end

def parse_id(base_error_message,
accept_external_id:,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this keyword argument because it's always true, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

id = parse_id(base_error_message,
accept_external_id: true,

id = parse_id(base_error_message,
accept_external_id: true,

end
"garbage after system literal"
if @source.match?(/(?:\s+[^'"]|\s*[\[>])/um)
details = "public ID literal is missing"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about raising here for better backtrace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see.

@naitoh naitoh force-pushed the parse_id_invalid_details branch from e9b3969 to d42a439 Compare September 14, 2025 08:26
@naitoh naitoh requested a review from kou September 14, 2025 08:30
@kou kou merged commit 5474ab2 into ruby:master Sep 14, 2025
67 checks passed
@naitoh naitoh deleted the parse_id_invalid_details branch September 14, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants