diff --git a/.rubocop.yml b/.rubocop.yml index 9f2ce215..249d6759 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,6 +2,8 @@ AllCops: TargetRubyVersion: 2.6 Exclude: - "lib/generators/**/templates/**/*" + SuggestExtensions: false + NewCops: disable Metrics/BlockLength: Exclude: @@ -15,7 +17,7 @@ Metrics/ModuleLength: Exclude: - "**/*_spec.rb" -Metrics/LineLength: +Layout/LineLength: Max: 120 Metrics/AbcSize: @@ -27,7 +29,10 @@ Metrics/CyclomaticComplexity: Metrics/PerceivedComplexity: Enabled: false -Layout/AlignParameters: +Gemspec/RequiredRubyVersion: + Enabled: false + +Layout/ParameterAlignment: EnforcedStyle: with_fixed_indentation Layout/CaseIndentation: @@ -63,5 +68,5 @@ Style/Not: Style/DoubleNegation: Enabled: false -Documentation: +Style/Documentation: Enabled: false # TODO: Enable again once we have more docs diff --git a/pundit.gemspec b/pundit.gemspec index 41e68e0b..2cfdb7d9 100644 --- a/pundit.gemspec +++ b/pundit.gemspec @@ -26,7 +26,7 @@ Gem::Specification.new do |gem| gem.add_development_dependency "pry" gem.add_development_dependency "rake" gem.add_development_dependency "rspec", ">= 3.0.0" - gem.add_development_dependency "rubocop", "0.74.0" + gem.add_development_dependency "rubocop", "1.24.0" gem.add_development_dependency "simplecov", ">= 0.17.0" gem.add_development_dependency "yard" end diff --git a/spec/policy_finder_spec.rb b/spec/policy_finder_spec.rb index 9dd9c925..11eb25a8 100644 --- a/spec/policy_finder_spec.rb +++ b/spec/policy_finder_spec.rb @@ -2,6 +2,7 @@ require "spec_helper" +class Foo; end RSpec.describe Pundit::PolicyFinder do let(:user) { double } let(:post) { Post.new(user) } @@ -114,7 +115,6 @@ context "with a class that doesn't have an associated policy" do it "returns nil" do - class Foo; end object = described_class.new(Foo) expect(object.policy).to eq nil diff --git a/spec/pundit_spec.rb b/spec/pundit_spec.rb index beb6b52e..91aefc34 100644 --- a/spec/pundit_spec.rb +++ b/spec/pundit_spec.rb @@ -12,8 +12,8 @@ let(:article) { Article.new } let(:artificial_blog) { ArtificialBlog.new } let(:article_tag) { ArticleTag.new } - let(:comments_relation) { CommentsRelation.new } - let(:empty_comments_relation) { CommentsRelation.new(true) } + let(:comments_relation) { CommentsRelation.new(empty: false) } + let(:empty_comments_relation) { CommentsRelation.new(empty: true) } let(:tag_four_five_six) { ProjectOneTwoThree::TagFourFiveSix.new(user) } let(:avatar_four_five_six) { ProjectOneTwoThree::AvatarFourFiveSix.new } let(:wiki) { Wiki.new } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4595d258..192146f2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -80,6 +80,7 @@ def self.policy_class class CommentScope attr_reader :original_object + def initialize(original_object) @original_object = original_object end @@ -114,7 +115,7 @@ class Comment end class CommentsRelation - def initialize(empty = false) + def initialize(empty: false) @empty = empty end @@ -232,6 +233,7 @@ def destroy? end class Wiki; end + class WikiPolicy class Scope # deliberate typo method @@ -242,6 +244,7 @@ def initalize; end class Thread def self.all; end end + class ThreadPolicy < Struct.new(:user, :thread) class Scope < Struct.new(:user, :scope) def resolve