Skip to content

Conversation

@api-clients-generation-pipeline
Copy link
Contributor

end

if attributes.key?(:'inputs')
if (value = attributes[:'inputs']).is_a?(Array)

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.

View in Datadog  Leave us feedback  Documentation

@datadog-datadog-prod-us1
Copy link

Datadog Report

Branch report: datadog-api-spec/generated/3994
Commit report: 44d6441
Test service: datadog-api-client-ruby

✅ 0 Failed, 1047 Passed, 2115 Skipped, 2m 14.37s Total duration (1m 12.83s time saved)

@github-actions
Copy link

This PR has been automatically marked as stale because it has not had activity in the last 30 days.
If there is no activity for another 90 days, this issue will be automatically closed.

@github-actions github-actions bot added the stale label Jul 25, 2025
@dd-devtools-worker dd-devtools-worker bot deleted the datadog-api-spec/generated/3994 branch October 25, 2025 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant