From 05bc3c3dcc5abe42b06ca0fd7632810e11b5ced7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Guimar=C3=A3es?= Date: Wed, 12 Jan 2022 21:39:41 -0300 Subject: [PATCH 1/3] update rubocop to 1.24 --- .rubocop.yml | 8 +++++--- pundit.gemspec | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9f2ce215..d291133b 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,7 @@ Metrics/CyclomaticComplexity: Metrics/PerceivedComplexity: Enabled: false -Layout/AlignParameters: +Layout/ParameterAlignment: EnforcedStyle: with_fixed_indentation Layout/CaseIndentation: @@ -63,5 +65,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 From 5a5df7894db6b2bf04a466f3583def4705293cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Guimar=C3=A3es?= Date: Fri, 14 Jan 2022 11:05:30 -0300 Subject: [PATCH 2/3] improve syntax according rubocop 1.24 rules --- pundit.gemspec | 1 + spec/policy_finder_spec.rb | 2 +- spec/pundit_spec.rb | 4 ++-- spec/spec_helper.rb | 5 ++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pundit.gemspec b/pundit.gemspec index 2cfdb7d9..536899ba 100644 --- a/pundit.gemspec +++ b/pundit.gemspec @@ -18,6 +18,7 @@ Gem::Specification.new do |gem| gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] + gem.required_ruby_version = ">= 2.6.0" gem.add_dependency "activesupport", ">= 3.0.0" gem.add_development_dependency "actionpack", ">= 3.0.0" 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 From 4bb0c7d637f849768a82defed6b8136e3a84dfa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Guimar=C3=A3es?= Date: Fri, 14 Jan 2022 13:44:43 -0300 Subject: [PATCH 3/3] Removing ruby 2.6 as required version because JRuby jruby-9.2 considers itself to be compliant with MRI 2.5 so if we add 2.6 as required minimum version for ruby it will causes conflict errors on bundler --- .rubocop.yml | 3 +++ pundit.gemspec | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index d291133b..249d6759 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -29,6 +29,9 @@ Metrics/CyclomaticComplexity: Metrics/PerceivedComplexity: Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false + Layout/ParameterAlignment: EnforcedStyle: with_fixed_indentation diff --git a/pundit.gemspec b/pundit.gemspec index 536899ba..2cfdb7d9 100644 --- a/pundit.gemspec +++ b/pundit.gemspec @@ -18,7 +18,6 @@ Gem::Specification.new do |gem| gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - gem.required_ruby_version = ">= 2.6.0" gem.add_dependency "activesupport", ">= 3.0.0" gem.add_development_dependency "actionpack", ">= 3.0.0"