-
Notifications
You must be signed in to change notification settings - Fork 88
Add better line break issue handling. #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thanks! We'll check it over :) |
It looks fine, we could just do with adding tests for it before merging in. Do you have any sample data that causes the failures? |
lib/csvlint/validate.rb
Outdated
if message.match(/^Unquoted fields do not allow new line/i) | ||
return :line_breaks | ||
end | ||
|
||
if message.match(/^New line must be/i) | ||
return :inconsistent_line_breaks | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read the linter correctly .match
does not return a boolean therefore it is creating a object for nothing.
To fix it, we should use .match?
.
if message.match(/^Unquoted fields do not allow new line/i) | |
return :line_breaks | |
end | |
if message.match(/^New line must be/i) | |
return :inconsistent_line_breaks | |
end | |
if message.match?(/^Unquoted fields do not allow new line/i) | |
return :line_breaks | |
end | |
if message.match?(/^New line must be/i) | |
return :inconsistent_line_breaks | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're probably right, yes!
spec.require_paths = ["lib"] | ||
|
||
spec.required_ruby_version = [">= 2.5", "< 3.4"] | ||
spec.required_ruby_version = [">= 2.5", "< 3.5"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create another PR for this change.
It is out of scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for another PR, there's already one open to make that change, but it's waiting on a bugfix for cucumber.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've merged that now, might be able to just rebase this.
It's probably best to treat this as a feature request / bug report rather than a traditional PR.
We ran into a couple of validation issues that were coded as
unknown_error
when they were better understood with a more specific error type in customer provided CSVs.This adds better error classification for those cases, and allows us to move forward but we do not understand enough of the overall structure of the program or how to add good specs for this behavior. We're just moving fast and sharing this code in the hope that knowing someone might need better classification in this case is helpful to you upstream.
Thank you for your work, and sorry we're not able to put together a better PR at this time. I did not quite understand how this method is supposed to work.