-
Notifications
You must be signed in to change notification settings - Fork 21
Update events intake specs for v2 Events post endpoint #2495
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
Update events intake specs for v2 Events post endpoint #2495
Conversation
| # check to see if the attribute exists and convert string to symbol for hash key | ||
| attributes = attributes.each_with_object({}) { |(k, v), h| | ||
| if (!self.class.attribute_map.key?(k.to_sym)) | ||
| fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AlertEventCustomAttributesLinksItems`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect |
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.
⚪ Code Quality Violation
Consider using string interpolation or formatting instead of concatenation. (...read more)
The rule "Avoid string concatenation" is an important coding practice in Ruby for ensuring efficient and clean code. String concatenation in Ruby using the '+' operator creates a new string object, which can lead to excessive memory usage and slower performance when dealing with large strings or performing the operation multiple times.
Instead, Ruby provides alternatives that are more efficient. The string interpolation syntax #{} allows you to insert variables directly into strings without creating new string objects. This is not only more memory efficient, but also provides cleaner and more readable code.
Another alternative is the format method, which allows you to create a formatted string with placeholders for variables. This method is particularly useful when dealing with more complex strings, as it provides a clear and concise way to format your strings.
By following this rule, you can write more efficient and cleaner Ruby code, leading to better performance and readability.
| self.additional_properties[k.to_sym] = v | ||
| else | ||
| h[k.to_sym] = v | ||
| fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::ChangeEventCustomAttributesImpactedResourcesItems`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect |
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.
⚪ Code Quality Violation
Consider using string interpolation or formatting instead of concatenation. (...read more)
The rule "Avoid string concatenation" is an important coding practice in Ruby for ensuring efficient and clean code. String concatenation in Ruby using the '+' operator creates a new string object, which can lead to excessive memory usage and slower performance when dealing with large strings or performing the operation multiple times.
Instead, Ruby provides alternatives that are more efficient. The string interpolation syntax #{} allows you to insert variables directly into strings without creating new string objects. This is not only more memory efficient, but also provides cleaner and more readable code.
Another alternative is the format method, which allows you to create a formatted string with placeholders for variables. This method is particularly useful when dealing with more complex strings, as it provides a clear and concise way to format your strings.
By following this rule, you can write more efficient and cleaner Ruby code, leading to better performance and readability.
| self.additional_properties[k.to_sym] = v | ||
| else | ||
| h[k.to_sym] = v | ||
| fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::EventPayload`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect |
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.
⚪ Code Quality Violation
Consider using string interpolation or formatting instead of concatenation. (...read more)
The rule "Avoid string concatenation" is an important coding practice in Ruby for ensuring efficient and clean code. String concatenation in Ruby using the '+' operator creates a new string object, which can lead to excessive memory usage and slower performance when dealing with large strings or performing the operation multiple times.
Instead, Ruby provides alternatives that are more efficient. The string interpolation syntax #{} allows you to insert variables directly into strings without creating new string objects. This is not only more memory efficient, but also provides cleaner and more readable code.
Another alternative is the format method, which allows you to create a formatted string with placeholders for variables. This method is particularly useful when dealing with more complex strings, as it provides a clear and concise way to format your strings.
By following this rule, you can write more efficient and cleaner Ruby code, leading to better performance and readability.
| enum_values: [ | ||
| "datadoghq.com", | ||
| "us3.datadoghq.com", | ||
| "us5.datadoghq.com", | ||
| "ap1.datadoghq.com", | ||
| "datadoghq.eu", | ||
| "ddog-gov.com" | ||
| ] |
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.
⚪ Code Quality Violation
Consider using the %W syntax instead (...read more)
The rule "Prefer %w to the literal array syntax" is a Ruby style guideline that encourages the use of %w notation instead of the traditional array syntax when defining arrays of strings. This rule is part of the Ruby community's efforts to promote readability and simplicity in Ruby code.
This rule is important because it helps to keep the code concise and easy to read. The %w notation allows you to define an array of strings without having to use quotes and commas. This can make the code cleaner and easier to understand, especially when dealing with large arrays.
To follow this rule, replace the traditional array syntax with the %w notation. For example, instead of writing ['foo', 'bar', 'baz'], you should write %w[foo bar baz]. This will create the same array, but in a more readable and concise way. By following this rule, you can help to make your Ruby code cleaner and easier to understand.
| # check to see if the attribute exists and convert string to symbol for hash key | ||
| attributes = attributes.each_with_object({}) { |(k, v), h| | ||
| if (!self.class.attribute_map.key?(k.to_sym)) | ||
| fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AlertEventCustomAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect |
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.
⚪ Code Quality Violation
Consider using string interpolation or formatting instead of concatenation. (...read more)
The rule "Avoid string concatenation" is an important coding practice in Ruby for ensuring efficient and clean code. String concatenation in Ruby using the '+' operator creates a new string object, which can lead to excessive memory usage and slower performance when dealing with large strings or performing the operation multiple times.
Instead, Ruby provides alternatives that are more efficient. The string interpolation syntax #{} allows you to insert variables directly into strings without creating new string objects. This is not only more memory efficient, but also provides cleaner and more readable code.
Another alternative is the format method, which allows you to create a formatted string with placeholders for variables. This method is particularly useful when dealing with more complex strings, as it provides a clear and concise way to format your strings.
By following this rule, you can write more efficient and cleaner Ruby code, leading to better performance and readability.
| self.additional_properties[k.to_sym] = v | ||
| else | ||
| h[k.to_sym] = v | ||
| fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::ChangeEventCustomAttributesAuthor`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect |
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.
⚪ Code Quality Violation
Consider using string interpolation or formatting instead of concatenation. (...read more)
The rule "Avoid string concatenation" is an important coding practice in Ruby for ensuring efficient and clean code. String concatenation in Ruby using the '+' operator creates a new string object, which can lead to excessive memory usage and slower performance when dealing with large strings or performing the operation multiple times.
Instead, Ruby provides alternatives that are more efficient. The string interpolation syntax #{} allows you to insert variables directly into strings without creating new string objects. This is not only more memory efficient, but also provides cleaner and more readable code.
Another alternative is the format method, which allows you to create a formatted string with placeholders for variables. This method is particularly useful when dealing with more complex strings, as it provides a clear and concise way to format your strings.
By following this rule, you can write more efficient and cleaner Ruby code, leading to better performance and readability.
| self.additional_properties[k.to_sym] = v | ||
| else | ||
| h[k.to_sym] = v | ||
| fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::ChangeEventCustomAttributesChangedResource`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect |
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.
⚪ Code Quality Violation
Consider using string interpolation or formatting instead of concatenation. (...read more)
The rule "Avoid string concatenation" is an important coding practice in Ruby for ensuring efficient and clean code. String concatenation in Ruby using the '+' operator creates a new string object, which can lead to excessive memory usage and slower performance when dealing with large strings or performing the operation multiple times.
Instead, Ruby provides alternatives that are more efficient. The string interpolation syntax #{} allows you to insert variables directly into strings without creating new string objects. This is not only more memory efficient, but also provides cleaner and more readable code.
Another alternative is the format method, which allows you to create a formatted string with placeholders for variables. This method is particularly useful when dealing with more complex strings, as it provides a clear and concise way to format your strings.
By following this rule, you can write more efficient and cleaner Ruby code, leading to better performance and readability.
| self.additional_properties[k.to_sym] = v | ||
| else | ||
| h[k.to_sym] = v | ||
| fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::ChangeEventCustomAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect |
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.
⚪ Code Quality Violation
Consider using string interpolation or formatting instead of concatenation. (...read more)
The rule "Avoid string concatenation" is an important coding practice in Ruby for ensuring efficient and clean code. String concatenation in Ruby using the '+' operator creates a new string object, which can lead to excessive memory usage and slower performance when dealing with large strings or performing the operation multiple times.
Instead, Ruby provides alternatives that are more efficient. The string interpolation syntax #{} allows you to insert variables directly into strings without creating new string objects. This is not only more memory efficient, but also provides cleaner and more readable code.
Another alternative is the format method, which allows you to create a formatted string with placeholders for variables. This method is particularly useful when dealing with more complex strings, as it provides a clear and concise way to format your strings.
By following this rule, you can write more efficient and cleaner Ruby code, leading to better performance and readability.
| end | ||
|
|
||
| if attributes.key?(:'links') | ||
| if (value = attributes[:'links']).is_a?(Array) |
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.
⚪ Code Quality Violation
Consider using Array() to ensure the type is that of an array (...read more)
The rule "Use Array() to ensure your variable is an array" is important for ensuring your code behaves as expected, regardless of the type of data it receives. It is common in Ruby to need to iterate through an array of items. However, if the variable is not an array, this can lead to unexpected behavior or errors.
The Array() method in Ruby is a Kernel method that converts its argument to an Array. If the argument is already an Array, it returns the argument. If the argument is nil, it returns an empty Array. This can be used to ensure that a variable is an array before trying to iterate over it, preventing potential errors or unexpected behavior.
By using Array(foos), you can ensure that foos is an array before you try to iterate over it with each. This prevents the need to check if foos is an array with foos.is_a?(Array) and makes your code cleaner and easier to understand.
Datadog ReportBranch report: ✅ 0 Failed, 3123 Passed, 87 Skipped, 4m 4.14s Total Time |
e2ee4b1 to
1a07cca
Compare
1a07cca to
bf5d545
Compare
Co-authored-by: ci.datadog-api-spec <[email protected]> a9e5e45
See DataDog/datadog-api-spec#4001
Test branch datadog-api-spec/test/revert-3991-revert-3949-yuqing.bian/update-event-post-v2