Skip to content

Commit

Permalink
Cleanup Rubocop config, fix offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Sep 6, 2024
1 parent 5b6ffee commit 2fd1569
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 33 deletions.
54 changes: 25 additions & 29 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,50 @@ AllCops:
- gemfiles/*
- spec/**/*

Gemspec/DevelopmentDependencies:
Enabled: false
#########
# STYLE #
#########

Style/Documentation:
Enabled: false

Layout/HashAlignment:
Enabled: false
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma

Layout/EmptyLines:
Enabled: false
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma

Layout/EmptyLinesAroundClassBody:
Enabled: false
##########
# LAYOUT #
##########

Layout/EmptyLinesAroundBlockBody:
Enabled: false
Layout/LineLength:
Exclude:
- ajax-datatables-rails.gemspec

Layout/EmptyLinesAroundModuleBody:
Layout/EmptyLines:
Enabled: false

Layout/EmptyLineBetweenDefs:
Enabled: false

Metrics/CyclomaticComplexity:
Max: 7
Layout/EmptyLinesAroundClassBody:
Enabled: false

Metrics/LineLength:
Layout/EmptyLinesAroundBlockBody:
Enabled: false

Metrics/BlockLength:
Max: 30
Layout/EmptyLinesAroundModuleBody:
Enabled: false

Metrics/MethodLength:
Max: 15
Layout/HashAlignment:
EnforcedColonStyle: table
EnforcedHashRocketStyle: table

Metrics/ClassLength:
Max: 130

Naming/AccessorMethodName:
Enabled: false
##########
# NAMING #
##########

Naming/FileName:
Exclude:
- lib/ajax-datatables-rails.rb

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma
4 changes: 2 additions & 2 deletions lib/ajax-datatables-rails/base.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module AjaxDatatablesRails
class Base
class Base # rubocop:disable Metrics/ClassLength

class << self
def default_db_adapter
Expand Down Expand Up @@ -40,7 +40,7 @@ def view_columns
ERROR
end

def get_raw_records
def get_raw_records # rubocop:disable Naming/AccessorMethodName
raise(NotImplementedError, <<~ERROR)
You should implement this method in your class and specify
Expand Down
4 changes: 3 additions & 1 deletion lib/ajax-datatables-rails/datatable/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Column
attr_reader :datatable, :index, :options, :column_name
attr_writer :search

def initialize(datatable, index, options)
def initialize(datatable, index, options) # rubocop:disable Metrics/MethodLength
@datatable = datatable
@index = index
@options = options
Expand Down Expand Up @@ -99,11 +99,13 @@ def casted_column
@casted_column ||= ::Arel::Nodes::NamedFunction.new('CAST', [table[field].as(type_cast)])
end

# rubocop:disable Layout/LineLength
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, "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
# rubocop:enable Layout/LineLength

def valid_search_column?(column_name)
!datatable.view_columns[column_name].nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/ajax-datatables-rails/datatable/column/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def use_regex?
# The solution is to bypass regex_search and use non_regex_search with :in operator
def regex_search
if use_regex?
::Arel::Nodes::Regexp.new((custom_field? ? field : table[field]), ::Arel::Nodes.build_quoted(formatted_value))
::Arel::Nodes::Regexp.new((custom_field? ? field : table[field]), ::Arel::Nodes.build_quoted(formatted_value)) # rubocop:disable Layout/LineLength
else
non_regex_search
end
Expand Down

0 comments on commit 2fd1569

Please sign in to comment.