Skip to content
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

Improve encoding test #12

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Improve encoding test #12

merged 2 commits into from
Nov 20, 2024

Conversation

lloeki
Copy link
Contributor

@lloeki lloeki commented Nov 14, 2024

No description provided.

@lloeki lloeki requested a review from a team as a code owner November 20, 2024 09:44
@lloeki lloeki changed the base branch from main to lloeki/add-missing-platform-directive November 20, 2024 09:46
unless "".respond_to?(:match?)
String.instance_eval do
def match?(other)
(Regexp === other) ? other.match?(self) : (self == other)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Suggested change
(Regexp === other) ? other.match?(self) : (self == other)
(other.is_a?(Regexp)) ? other.match?(self) : (self == other)
Do not use === (...read more)

The case equality operator === in Ruby is used to test equality within a when clause of a case statement. However, it's often considered a bad practice to use this operator explicitly outside of a case statement. This is because its behavior can be quite unpredictable and confusing, as it behaves differently for different classes.

The use of the === operator can lead to code that is harder to read and understand. It's also potentially prone to bugs, as it might not behave as expected with certain objects. Therefore, it's recommended to avoid the explicit use of the === operator.

Instead of using the === operator, it's better to use more explicit methods that clearly indicate what you're trying to achieve. For example, if you're trying to check if a string matches a regular expression, you can use the match? method. If you want to check if an object is an instance of a certain class, you can use the is_a? method. These methods are much more clear and straightforward, leading to better, more maintainable code.

View in Datadog  Leave us feedback  Documentation

Base automatically changed from lloeki/add-missing-platform-directive to main November 20, 2024 10:49
@lloeki lloeki merged commit 52d10e3 into main Nov 20, 2024
37 checks passed
@lloeki lloeki deleted the lloeki/improve-test branch November 20, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants