Skip to content

Commit

Permalink
Rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 3, 2024
1 parent e1ad783 commit fb7002f
Show file tree
Hide file tree
Showing 82 changed files with 960 additions and 748 deletions.
2 changes: 2 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

appraise "rails-6.1" do
group :development do
gem "rails", "~> 6.1.0"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"
Expand Down
2 changes: 2 additions & 0 deletions lib/datagrid.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "action_view"
require "datagrid/configuration"
require "datagrid/engine"
Expand Down
2 changes: 2 additions & 0 deletions lib/datagrid/active_model.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Datagrid
# Required to be ActiveModel compatible
module ActiveModel
Expand Down
10 changes: 5 additions & 5 deletions lib/datagrid/column_names_attribute.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Datagrid
module ColumnNamesAttribute
extend ActiveSupport::Concern
Expand Down Expand Up @@ -45,7 +47,7 @@ def columns(*args, **options)
# If no mandatory columns specified than all of them considered mandatory
# @return [Array<Datagrid::Columns::Column>]
def mandatory_columns
available_columns.select { |c| c.mandatory? }
available_columns.select(&:mandatory?)
end

# Returns a list of enabled columns without <tt>mandatory: true</tt> option
Expand All @@ -68,17 +70,15 @@ def selected_column_names(*args)
column.is_a?(Datagrid::Columns::Column) ? column.name : column.to_sym
end
args
elsif column_names && column_names.any?
elsif column_names&.any?
column_names + mandatory_columns.map(&:name)
else
columns_enabled_by_default.map(&:name)
end
end

def columns_visibility_enabled?
columns_array.any? do |column|
column.mandatory_explicitly_set?
end
columns_array.any?(&:mandatory_explicitly_set?)
end

def columns_enabled_by_default
Expand Down
8 changes: 5 additions & 3 deletions lib/datagrid/columns.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "datagrid/utils"
require "active_support/core_ext/class/attribute"

Expand Down Expand Up @@ -488,7 +490,7 @@ def map_with_batches(&block)
end

def each_with_batches(&block)
if batch_size && batch_size > 0
if batch_size&.positive?
driver.batch_each(assets, batch_size, &block)
else
assets.each(&block)
Expand All @@ -498,7 +500,7 @@ def each_with_batches(&block)
def value_from_html_block(context, asset, column)
args = []
remaining_arity = column.html_block.arity
remaining_arity = 1 if remaining_arity < 0
remaining_arity = 1 if remaining_arity.negative?

asset = decorate(asset)

Expand All @@ -507,7 +509,7 @@ def value_from_html_block(context, asset, column)
remaining_arity -= 1
end

args << asset if remaining_arity > 0
args << asset if remaining_arity.positive?
args << self if remaining_arity > 1

context.instance_exec(*args, &column.html_block)
Expand Down
Loading

0 comments on commit fb7002f

Please sign in to comment.