Skip to content

Commit

Permalink
Fix most recent rubocop issues (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
coorasse authored Jul 6, 2022
1 parent 959eee1 commit 65a8521
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Style/Documentation:
Style/NonNilCheck:
IncludeSemanticChanges: true

Style/RedundantInitialize:
Enabled: false

Style/EmptyMethod:
Enabled: false

Expand Down
2 changes: 1 addition & 1 deletion cancancan.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'bundler', '~> 2.0'
s.add_development_dependency 'rake', '~> 10.1', '>= 10.1.1'
s.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
s.add_development_dependency 'rubocop', '~> 1.26'
s.add_development_dependency 'rubocop', '~> 1.31.1'
end
6 changes: 3 additions & 3 deletions lib/cancan/ability/rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def relevant_rules_for_match(action, subject)
next unless rule.only_raw_sql?

raise Error,
"The can? and cannot? call cannot be used with a raw sql 'can' definition."\
" The checking code cannot be determined for #{action.inspect} #{subject.inspect}"
"The can? and cannot? call cannot be used with a raw sql 'can' definition. " \
"The checking code cannot be determined for #{action.inspect} #{subject.inspect}"
end
end

Expand All @@ -72,7 +72,7 @@ def relevant_rules_for_query(action, subject)
rule.base_behavior == false && rule.attributes.present?
end
if rules.any?(&:only_block?)
raise Error, "The accessible_by call cannot be used with a block 'can' definition."\
raise Error, "The accessible_by call cannot be used with a block 'can' definition." \
"The SQL cannot be determined for #{action.inspect} #{subject.inspect}"
end
rules
Expand Down
2 changes: 1 addition & 1 deletion lib/cancan/controller_additions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def check_authorization(options = {})
next if options[:unless] && controller.send(options[:unless])

raise AuthorizationNotPerformed,
'This action failed the check_authorization because it does not authorize_resource. '\
'This action failed the check_authorization because it does not authorize_resource. ' \
'Add skip_authorization_check to bypass this check.'
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cancan/model_adapters/active_record_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def override_scope
def raise_override_scope_error
rule_found = @compressed_rules.detect { |rule| rule.conditions.is_a?(ActiveRecord::Relation) }
raise Error,
'Unable to merge an Active Record scope with other conditions. '\
'Unable to merge an Active Record scope with other conditions. ' \
"Instead use a hash or SQL for #{rule_found.actions.first} #{rule_found.subjects.first} ability."
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cancan/rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def parse_attributes_from_extra_args(args)
def condition_and_block_check(conditions, block, action, subject)
return unless conditions.is_a?(Hash) && block

raise BlockAndConditionsError, 'A hash of conditions is mutually exclusive with a block. '\
raise BlockAndConditionsError, 'A hash of conditions is mutually exclusive with a block. ' \
"Check \":#{action} #{subject}\" ability."
end

Expand Down
2 changes: 1 addition & 1 deletion spec/cancan/model_adapters/active_record_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class User < ActiveRecord::Base
@ability.can :read, Article, Article.where(secret: true)
expect { Article.accessible_by(@ability) }
.to raise_error(CanCan::Error,
'Unable to merge an Active Record scope with other conditions. '\
'Unable to merge an Active Record scope with other conditions. ' \
'Instead use a hash or SQL for read Article ability.')
end

Expand Down

0 comments on commit 65a8521

Please sign in to comment.