Upgrade Rubocop to latest version (0.74)

Now that we don't need to support Ruby 2.1 or 2.2, we can use the latest
version of Rubocop (which dropped support for those versions).

Also remove things from Rubocop which are now defaults:

- FrozenStringLiteralComment is now on by default
- DisplayCopNames used to be off by default but now seems to be on
- This project doesn't seem to have ever had gemfiles or vendor
  directories - my guess is that this was a copy-paste from another
  project.
This commit is contained in:
Duncan Stuart 2019-08-14 13:51:03 +02:00
parent 81d4913e9e
commit 28dd15074e
5 changed files with 7 additions and 13 deletions

View File

@ -1,9 +1,6 @@
AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.2
TargetRubyVersion: 2.3
Exclude:
- "gemfiles/**/*"
- "vendor/**/*"
- "lib/generators/**/*"
Metrics/BlockLength:
@ -46,9 +43,6 @@ Layout/AccessModifierIndentation:
Layout/EndAlignment:
EnforcedStyleAlignWith: variable
Style/FrozenStringLiteralComment:
Enabled: true
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%w': "[]"

View File

@ -15,7 +15,7 @@ class Pundit::Error < StandardError; end # rubocop:disable Style/ClassAndModuleC
# @api public
module Pundit
SUFFIX = "Policy".freeze
SUFFIX = "Policy"
# @api private
module Generators; end
@ -124,7 +124,7 @@ module Pundit
# @return [Object, nil] instance of policy class with query methods
def policy(user, record)
policy = PolicyFinder.new(record).policy
policy.new(user, pundit_model(record)) if policy
policy&.new(user, pundit_model(record))
rescue ArgumentError
raise InvalidConstructorError, "Invalid #<#{policy}> constructor is called"
end

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module Pundit
VERSION = "2.1.0".freeze
VERSION = "2.1.0"
end

View File

@ -26,6 +26,6 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "pry"
gem.add_development_dependency "rake"
gem.add_development_dependency "rspec", ">= 2.0.0"
gem.add_development_dependency "rubocop", "0.57.2"
gem.add_development_dependency "rubocop", "0.74.0"
gem.add_development_dependency "yard"
end

View File

@ -201,9 +201,9 @@ end
class Controller
include Pundit
# Mark protected methods public so they may be called in test
# rubocop:disable Layout/AccessModifierIndentation, Style/AccessModifierDeclarations
# rubocop:disable Style/AccessModifierDeclarations
public(*Pundit.protected_instance_methods)
# rubocop:enable Layout/AccessModifierIndentation, Style/AccessModifierDeclarations
# rubocop:enable Style/AccessModifierDeclarations
attr_reader :current_user, :action_name, :params