Skip to content

Prefer inline access modifiers #901

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

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .rubocop-https---www-goodcop-style-base-yml
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,10 @@ Security/YAMLLoad:
Style/ArgumentsForwarding:
Enabled: true

Style/AccessModifierDeclarations:
Enabled: true
EnforcedStyle: inline

Style/ComparableClamp:
Enabled: true

Expand Down
188 changes: 0 additions & 188 deletions .rubocop-https---www-goodcop-style-rubocop-yml

This file was deleted.

20 changes: 9 additions & 11 deletions lib/phlex/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,32 +139,30 @@ def delimiter
","
end

private

def column(header = nil, value)
private def column(header = nil, value)
@_row_buffer << [header, value]
end

def each_item(&)
private def each_item(&)
collection.each(&)
end

# Override and set to `false` to disable rendering headers.
def render_headers?
private def render_headers?
true
end

# Override and set to `true` to strip leading and trailing whitespace from values.
def trim_whitespace?
private def trim_whitespace?
false
end

# Override and set to `false` to disable CSV injection escapes or `true` to enable.
def escape_csv_injection?
private def escape_csv_injection?
UNDEFINED
end

def __escape__(buffer, value, escape_csv_injection:, strip_whitespace:, escape_regex:)
private def __escape__(buffer, value, escape_csv_injection:, strip_whitespace:, escape_regex:)
value = case value
when String
value
Expand Down Expand Up @@ -218,12 +216,12 @@ def __escape__(buffer, value, escape_csv_injection:, strip_whitespace:, escape_r
end

# Handle legacy `view_template` method
def respond_to_missing?(method_name, include_private)
private def respond_to_missing?(method_name, include_private)
(method_name == :row_template && respond_to?(:view_template)) || super
end

# Handle legacy `view_template` method
def method_missing(method_name, ...)
private def method_missing(method_name, ...)
if method_name == :row_template && respond_to?(:view_template)
warn "Deprecated: Use `row_template` instead of `view_template` in Phlex CSVs."
self.class.alias_method :row_template, :view_template
Expand All @@ -233,7 +231,7 @@ def method_missing(method_name, ...)
end
end

def ensure_escape_csv_injection_configured!
private def ensure_escape_csv_injection_configured!
if escape_csv_injection? == UNDEFINED
raise <<~MESSAGE
You need to define `escape_csv_injection?` in #{self.class.name}.
Expand Down
4 changes: 1 addition & 3 deletions lib/phlex/fifo_cache_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def clear
@fifo.clear
end

private

def map_key(value)
private def map_key(value)
case value
when Array
value.map { |it| map_key(it) }
Expand Down
6 changes: 2 additions & 4 deletions lib/phlex/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

# @api private
module Phlex::Helpers
private

def mix(*args)
private def mix(*args)
args.each_with_object({}) do |object, result|
result.merge!(object) do |_key, old, new|
case [old, new].freeze
Expand Down Expand Up @@ -43,7 +41,7 @@ def mix(*args)
end
end

def grab(**bindings)
private def grab(**bindings)
if bindings.size > 1
bindings.values
else
Expand Down
Loading