-
Notifications
You must be signed in to change notification settings - Fork 31
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
add args to conversion to be returnable as json #1512
Conversation
Quality Gate passedIssues Measures |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1512 +/- ##
==========================================
+ Coverage 76.44% 76.51% +0.07%
==========================================
Files 618 618
Lines 46891 46894 +3
Branches 849 849
==========================================
+ Hits 35844 35881 +37
+ Misses 10952 10918 -34
Partials 95 95
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
@@ -67,6 +70,7 @@ def as_json(*_a) | |||
result['converted_type'] = @converted_type if @converted_type | |||
result['converted_bit_size'] = @converted_bit_size if @converted_bit_size | |||
result['converted_array_size'] = @converted_array_size if @converted_array_size | |||
result['args'] = JSON.generate(@args) if @args |
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.
as_json shouldn't call JSON.generate. The goal is return objects that are ready to be converted to JSON, but not return an actual JSON string yet. Change to "= @params.as_json(*a)" and remove underscore from the existing _a
@@ -61,4 +63,6 @@ def as_json(self): | |||
result["converted_bit_size"] = self.converted_bit_size | |||
if self.converted_array_size is not None: | |||
result["converted_array_size"] = self.converted_array_size | |||
if self.args is not None: | |||
result["args"] = json.dumps(self.args) |
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.
Same comment as in Ruby.
@@ -30,12 +30,15 @@ class Conversion | |||
attr_reader :converted_bit_size | |||
# @return [Integer] The size in bits of the converted array value | |||
attr_reader :converted_array_size | |||
# @return [] The Array of arguments passed in | |||
attr_reader :args |
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.
Probably rename to params. If you look at the as_json method in a lot of our existing conversion classes they already are reporting their arguments as 'params'
@@ -12,6 +12,8 @@ def initialize | |||
# Size of the converted type in bits | |||
# Use 0 for :STRING or :BLOCK where the size can be variable | |||
@converted_bit_size = 0 | |||
# return the arguments used | |||
@args = [] |
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 should default to nil, like in the base class.
@@ -40,6 +40,7 @@ def initialize(processor_name, result_name, converted_type = nil, converted_bit_ | |||
end | |||
@converted_bit_size = Integer(converted_bit_size) if ConfigParser.handle_nil(converted_bit_size) | |||
@converted_array_size = Integer(converted_array_size) if ConfigParser.handle_nil(converted_array_size) | |||
@params = [@processor_name, @result_name] |
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.
MIssing converted_ params
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.
Base class records those ... they are output in the to_config
method. as_json
outputs them separately and the remaining parameters get put into params
.
@@ -25,12 +25,14 @@ class Conversion: | |||
# attr_reader :converted_bit_size | |||
# # self.return [Integer] The size in bits of the converted array value | |||
# attr_reader :converted_array_size | |||
# attr_reader :args |
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.
Should be params
@@ -45,6 +45,7 @@ def __init__( | |||
self.converted_bit_size = int(converted_bit_size) | |||
if ConfigParser.handle_none(converted_array_size): | |||
self.converted_array_size = int(converted_array_size) | |||
self.params = [self.processor_name, self.result_name] |
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.
Missing converted_ params
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.
Base class records those ... they are output in the to_config method. as_json outputs them separately and the remaining parameters get put into params.
@@ -17,6 +17,7 @@ def __init__(self): | |||
# a string, integer, float, or array of values. | |||
# @param packet [Packet] The packet object where the conversion is defined | |||
# @param buffer [String] The raw packet buffer | |||
# @param args [Array] The arguments to return |
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.
Remove args
This ticket still needs to capture all params. |
Quality Gate passedIssues Measures |
Closes Issue #698