-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
bugfix: Fix potential NME when converting ParameterType to envelope #1789
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?
bugfix: Fix potential NME when converting ParameterType to envelope #1789
Conversation
@luke-hill relatively straight-forward fix, although I'm not super pleased with the rspec test due to the method of interest being private. I don't think this warrants an update to any of the features since it's an admittedly weird way to declare a |
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.
Not sure I agree on no source location being provided when a bound method. because it still exists there.
But I've not dug into it in more detail
Also we need to keep the contract up. I might ask how the other flavours deal with it
@@ -30,6 +30,7 @@ refactored to use newer, less procedural ruby_) | |||
- Fixed an issue where a change to one example in compatibility testing wasn't fully adhered to ([luke-hill](https://github.com/luke-hill)) | |||
- Fixed Ruby 3.4+ issue where error backtraces weren't being formatted. ([#1771](https://github.com/cucumber/cucumber-ruby/pull/1771) [orien](https://github.com/orien)) | |||
- Fix some problematic specs that were leaking state and showcasing an issue on JRuby ([#1783](https://github.com/cucumber/cucumber-ruby/pull/1783) [luke-hill](https://github.com/luke-hill)) | |||
- Fixed an issue where NoMethodError could be raised when declaring a parameter-type that used bound methods ([#1789](https://github.com/cucumber/cucumber-ruby/pull/1789)) |
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.
This will conflict soon as I'm about to cut v10. I will happily cut another v10.0.1 soon after if desired
def source_reference_for(transformer) | ||
# #source_location may return nil if no definition was found | ||
# This is the case for transformers created using method(sym) or similar | ||
return nil if transformer.source_location.nil? |
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.
Not 100% we can do this as it might break the contract we have in messages.
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.
My understanding is that the sourceReference
field for ParameterType
has always been optional:
- cucumber-messages @ v22.0.0 -- first introduced here
- cucumber-messages @ v27.2.0 -- current HEAD
This is why I opted specifically to omit the entire SourceReference
object, rather than providing one with nil
interior values
let(:prefer_for_regexp_match) { true } | ||
|
||
before do | ||
allow(configuration).to receive_message_chain(:id_generator, :new_id).and_return(id) # rubocop:disable RSpec/MessageChain |
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'm trying to remove inline stuff, I don't mind it being added to the overall directive to be fixed up at a later date or if you can tackle it here that would be good
regular_expressions: [%("[^"]+")], | ||
prefer_for_regular_expression_match: true, | ||
use_for_snippets: false, | ||
source_reference: anything # tested in later cases |
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.
To avoid cop offenses can this be returned as something like :no_op
Description
Sets
source_reference
tonil
if the parameter type transformer does not provide a valid source location, i.e. isnil
.Fixes #1788
Type of change
Bug fix (non-breaking change which fixes an issue)
Checklist:
Your PR is ready for review once the following checklist is
complete. You can also add some checks if you want to.
bundle exec rubocop
reports no offenses