Skip to content

Conversation

@beanieboi
Copy link
Member

@beanieboi beanieboi commented Sep 8, 2025

fix identified RuboCop issues

@beanieboi beanieboi marked this pull request as ready for review September 8, 2025 16:53
Copy link

@troycoll troycoll left a comment

Choose a reason for hiding this comment

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

No AI agents were harmed in the reviewing of this PR.

metrics.map { |k, v| ["#{type}##{k}", v] }.to_h
end

private_class_method :add_prefix
Copy link
Contributor

Choose a reason for hiding this comment

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

This is technically a breaking change.

Copy link
Member Author

@beanieboi beanieboi Sep 9, 2025

Choose a reason for hiding this comment

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

Yes, thats correct. My plan is to cut Pliny 2. I want to make some other breaking changes as well. PLINY_ENV is deprecated in favor of APP_ENV and I would like to remove support for PLINY_ENV.

Comment on lines -45 to +48
-> (v) do
if v
v.split(",").map{|a| cast(a, method) }
end
->(v) do
v&.split(",")&.map { |a| cast(a, method) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this one is curious because it's not exactly equivalent. Is it a safe correction?

We know that String#split will always return an array but RuboCop doesn't because we don't have any type definitions. Before, it would cause an error if it suddenly returned nil and now it will instead return that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thats true. The only way I can think of this happening if we have a custom split() method on what ever we are passing to the config block. The context here is mapping ENV vars to methods and casting the input (ENV var) to primitives (int, string, symbol) I think it should not be possible to get nil from split()

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not saying there's anything wrong with the correction in our concrete case. I was just curious if RuboCop thought it was equivalent.

Copy link
Member Author

@beanieboi beanieboi Sep 9, 2025

Choose a reason for hiding this comment

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

The RuboCop rules don't go that deep. It just sees the first safe navigator and then assumes that all following method calls need it as well. It's complaining about Lint/SafeNavigationChain

It's a combination of 2 rules. first it sees the if v and replaces that with v& and after that the Lint/SafeNavigationChain kicks in

Co-authored-by: Troels Thomsen <19824+tt@users.noreply.github.com>
@beanieboi beanieboi merged commit e9696b1 into main Sep 9, 2025
15 checks passed
@beanieboi beanieboi deleted the bf/fix-rubocop branch September 9, 2025 11:54
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.

4 participants