Skip to content

Commit

Permalink
Fix Rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Apr 8, 2024
1 parent f342bab commit db76973
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ AllCops:
- gemfiles/*
- spec/**/*

Gemspec/DevelopmentDependencies:
Enabled: false

Style/Documentation:
Enabled: false

Expand Down
14 changes: 3 additions & 11 deletions lib/ajax-datatables-rails/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,15 @@ def column_data(column)

# helper methods
def connected_columns
@connected_columns ||= begin
view_columns.keys.map do |field_name|
datatable.column_by(:data, field_name.to_s)
end.compact
end
@connected_columns ||= view_columns.keys.map { |field_name| datatable.column_by(:data, field_name.to_s) }.compact
end

def searchable_columns
@searchable_columns ||= begin
connected_columns.select(&:searchable?)
end
@searchable_columns ||= connected_columns.select(&:searchable?)
end

def search_columns
@search_columns ||= begin
searchable_columns.select(&:searched?)
end
@search_columns ||= searchable_columns.select(&:searched?)
end

def sanitize_data(data)
Expand Down
2 changes: 1 addition & 1 deletion lib/ajax-datatables-rails/datatable/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def casted_column
end

def validate_settings!
raise AjaxDatatablesRails::Error::InvalidSearchColumn, "Unknown column. Check that `data` field is filled on JS side with the column name" if column_name.empty?
raise AjaxDatatablesRails::Error::InvalidSearchColumn, 'Unknown column. Check that `data` field is filled on JS side with the column name' if column_name.empty?
raise AjaxDatatablesRails::Error::InvalidSearchColumn, "Check that column '#{column_name}' exists in view_columns" unless valid_search_column?(column_name)
raise AjaxDatatablesRails::Error::InvalidSearchCondition, cond unless valid_search_condition?(cond)
end
Expand Down

0 comments on commit db76973

Please sign in to comment.