Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 13, 2024
1 parent 5bf9208 commit ee983ff
Show file tree
Hide file tree
Showing 22 changed files with 201 additions and 213 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ group :development do
gem "pry-byebug"
gem "rails-dom-testing", "~> 2.2"
gem "rspec"
gem "rubocop", "~> 1.68"
gem "sequel"
gem "sqlite3", "~> 1.7.0"
gem "rubocop", "~> 1.68"

group :mongo do
gem "bson"
gem "mongoid", "~> 9.0"
end
end

3 changes: 0 additions & 3 deletions lib/datagrid/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ def attributes
# grid.attributes = {first_name: 'John', last_name: 'Smith'}
# grid.first_name # => 'John'
# grid.last_name # => 'Smith'
def attributes=(value)
super
end

# @return [Object] Any datagrid attribute value
def [](attribute)
Expand Down
3 changes: 1 addition & 2 deletions lib/datagrid/filters/boolean_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
module Datagrid
module Filters
class BooleanFilter < Datagrid::Filters::BaseFilter

# @!visibility private
def initialize(grid, name, **opts)
super(grid, name, **opts)
super
options[:default] ||= false
end

Expand Down
8 changes: 2 additions & 6 deletions lib/datagrid/filters/date_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def default_input_options
end

def apply(grid_object, scope, value)
if value.is_a?(Range)
value = value.begin&.beginning_of_day..value.end&.end_of_day
end
value = value.begin&.beginning_of_day..value.end&.end_of_day if value.is_a?(Range)
super
end

Expand All @@ -31,9 +29,7 @@ def format(value)
end

def default_filter_where(scope, value)
if driver.is_timestamp?(scope, name)
value = Datagrid::Utils.format_date_as_timestamp(value)
end
value = Datagrid::Utils.format_date_as_timestamp(value) if driver.is_timestamp?(scope, name)
super
end

Expand Down
6 changes: 3 additions & 3 deletions lib/datagrid/filters/dynamic_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class DynamicFilter < Datagrid::Filters::BaseFilter
def initialize(grid, name, **options, &block)
options[:select] ||= default_select
options[:operations] ||= DEFAULT_OPERATIONS
options[:include_blank] = false unless options.key?(:include_blank)
super(grid, name, **options, &block)
options[:include_blank] = false unless options.key?(:include_blank)
super
end

def default_input_options
{**super, type: nil}
{ **super, type: nil }
end

def parse_values(filter)
Expand Down
2 changes: 1 addition & 1 deletion lib/datagrid/filters/enum_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EnumFilter < Datagrid::Filters::BaseFilter
# @!visibility private
def initialize(grid, name, **options, &block)
options[:multiple] = true if options[:checkboxes]
super(grid, name, **options, &block)
super
raise Datagrid::ConfigurationError, ":select option not specified" unless options[:select]
end

Expand Down
4 changes: 1 addition & 3 deletions lib/datagrid/filters/integer_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def parse(value)
end
return value if value.is_a?(Range)

if value.to_i == 0 && value.is_a?(String) && value !~ %r{\A\s*-?0}
return nil
end
return nil if value.to_i.zero? && value.is_a?(String) && value !~ %r{\A\s*-?0}

value.to_i
end
Expand Down
2 changes: 1 addition & 1 deletion lib/datagrid/filters/ranged_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Datagrid
module Filters
module RangedFilter
SERIALIZED_RANGE = %r{\A(.*)\.{2,3}(.*)\z}.freeze
SERIALIZED_RANGE = %r{\A(.*)\.{2,3}(.*)\z}

def parse_values(value)
return super unless range?
Expand Down
8 changes: 3 additions & 5 deletions lib/datagrid/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module FormBuilder
# @param filter_or_attribute [Datagrid::Filters::BaseFilter, String, Symbol] filter object or filter name
# @param options [Hash] options of rails form input helper
# @return [String] a form input html for the corresponding filter
def datagrid_filter(filter_or_attribute, **options, &block)
def datagrid_filter(filter_or_attribute, ...)
filter = datagrid_get_filter(filter_or_attribute)
send(filter.form_builder_helper_name, filter, **options, &block)
send(filter.form_builder_helper_name, filter, ...)
end

# @param filter_or_attribute [Datagrid::Filters::BaseFilter, String, Symbol] filter object or filter name
Expand Down Expand Up @@ -44,9 +44,7 @@ def datagrid_filter_input(attribute_or_filter, **options, &block)
text_area filter.name, value: object.filter_value_as_string(filter), **options, &block
when :checkbox
value = options.fetch(:value, 1).to_s
if filter.enum_checkboxes? && enum_checkbox_checked?(filter, value)
options = {checked: true, **options}
end
options = { checked: true, **options } if filter.enum_checkboxes? && enum_checkbox_checked?(filter, value)
check_box filter.name, options, value
when :hidden
hidden_field filter.name, **options
Expand Down
Loading

0 comments on commit ee983ff

Please sign in to comment.