From b2c01392bac66b5d4cbfe2555a892dea817e0431 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Tue, 9 Jan 2024 17:19:29 +0100 Subject: [PATCH 1/4] Add RuboCop --- .github/workflows/rubocop.yml | 32 ++++++++++++++++++++++++++++++++ .rubocop.yml | 14 ++++++++++++++ Gemfile | 6 ++++++ 3 files changed, 52 insertions(+) create mode 100644 .github/workflows/rubocop.yml create mode 100644 .rubocop.yml diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..db8b171 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,32 @@ +name: Rubocop + +on: + push: + branches: [ master, develop ] + pull_request: + branches: [ master, develop ] + +permissions: + contents: read + +jobs: + rubocop: + name: Rubocop + runs-on: ${{ matrix.os }} + env: + BUNDLE_JOBS: 4 + BUNDLE_RETRY: 3 + strategy: + matrix: + os: [ubuntu-latest] + ruby-version: ['3.3'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: Ruby linter + run: bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..60284a0 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,14 @@ +require: + - rubocop-packaging + - rubocop-performance + - rubocop-rake + - rubocop-rspec + +AllCops: + TargetRubyVersion: 3.0 + NewCops: enable + DisplayStyleGuide: true + ExtraDetails: true + Exclude: + - 'gemfiles/**/*' + - 'vendor/bundle/**/*' diff --git a/Gemfile b/Gemfile index b627549..014c422 100644 --- a/Gemfile +++ b/Gemfile @@ -9,5 +9,11 @@ gem 'rspec' gem 'simplecov' gem 'webmock' +gem 'rubocop' +gem 'rubocop-packaging' +gem 'rubocop-performance' +gem 'rubocop-rake' +gem 'rubocop-rspec' + # Specify your gem's dependencies in omniauth-cas.gemspec gemspec From 2b4b95d5a87a2512bfa713a37d287e1727557816 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Tue, 9 Jan 2024 17:21:21 +0100 Subject: [PATCH 2/4] Autofix offenses in non-production code Coverage stay the same at 97.34% --- Rakefile | 7 +- .../strategies/cas/logout_request_spec.rb | 28 ++-- .../cas/service_ticket_validator_spec.rb | 31 ++-- spec/omniauth/strategies/cas_spec.rb | 135 +++++++++--------- spec/spec_helper.rb | 5 +- 5 files changed, 107 insertions(+), 99 deletions(-) mode change 100644 => 100755 Rakefile diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 index af92638..8dc254d --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,10 @@ #!/usr/bin/env rake +# frozen_string_literal: true + require 'bundler/gem_tasks' require 'rspec/core/rake_task' + desc 'Default: run specs.' task default: :spec @@ -9,7 +12,3 @@ desc 'Run specs' RSpec::Core::RakeTask.new(:spec) do |t| t.rspec_opts = '--require spec_helper --color --order rand' end - -task :test do - fail %q{This application uses RSpec. Try running "rake spec"} -end diff --git a/spec/omniauth/strategies/cas/logout_request_spec.rb b/spec/omniauth/strategies/cas/logout_request_spec.rb index 9294410..03f5ad7 100644 --- a/spec/omniauth/strategies/cas/logout_request_spec.rb +++ b/spec/omniauth/strategies/cas/logout_request_spec.rb @@ -1,26 +1,28 @@ +# frozen_string_literal: true + require 'spec_helper' describe OmniAuth::Strategies::CAS::LogoutRequest do + subject { described_class.new(strategy, request).call(options) } + let(:strategy) { double('strategy') } let(:env) do - { 'rack.input' => StringIO.new('','r') } + { 'rack.input' => StringIO.new('', 'r') } end - let(:request) { double('request', params:params, env:env) } + let(:request) { double('request', params: params, env: env) } let(:params) { { 'url' => url, 'logoutRequest' => logoutRequest } } let(:url) { 'http://example.org/signed_in' } let(:logoutRequest) do - %Q[ - + %( + @NOT_USED@ ST-123456-123abc456def - ] + ) end - subject { described_class.new(strategy, request).call(options) } - describe 'SAML attributes' do - let(:callback) { Proc.new{} } + let(:callback) { proc {} } let(:options) do { on_single_sign_out: callback } end @@ -61,7 +63,7 @@ let(:response_body) { subject[2].respond_to?(:body) ? subject[2].body : subject[2] } context 'that returns TRUE' do - let(:callback) { Proc.new{true} } + let(:callback) { proc { true } } it 'responds with OK' do expect(subject[0]).to eq 200 @@ -70,7 +72,7 @@ end context 'that returns Nil' do - let(:callback) { Proc.new{} } + let(:callback) { proc {} } it 'responds with OK' do expect(subject[0]).to eq 200 @@ -79,7 +81,7 @@ end context 'that returns a tuple' do - let(:callback) { Proc.new{ [400,{},'Bad Request'] } } + let(:callback) { proc { [400, {}, 'Bad Request'] } } it 'responds with OK' do expect(subject[0]).to eq 400 @@ -88,8 +90,8 @@ end context 'that raises an error' do - let(:exception) { RuntimeError.new('error' )} - let(:callback) { Proc.new{raise exception} } + let(:exception) { RuntimeError.new('error') } + let(:callback) { proc { raise exception } } before do allow(strategy).to receive(:fail!) diff --git a/spec/omniauth/strategies/cas/service_ticket_validator_spec.rb b/spec/omniauth/strategies/cas/service_ticket_validator_spec.rb index 92f40d1..fb68cb1 100644 --- a/spec/omniauth/strategies/cas/service_ticket_validator_spec.rb +++ b/spec/omniauth/strategies/cas/service_ticket_validator_spec.rb @@ -1,30 +1,30 @@ +# frozen_string_literal: true + require 'spec_helper' describe OmniAuth::Strategies::CAS::ServiceTicketValidator do let(:strategy) do double('strategy', - service_validate_url: 'https://example.org/serviceValidate' - ) + service_validate_url: 'https://example.org/serviceValidate') end let(:provider_options) do double('provider_options', - disable_ssl_verification?: false, - merge_multivalued_attributes: false, - ca_path: '/etc/ssl/certsZOMG' - ) + disable_ssl_verification?: false, + merge_multivalued_attributes: false, + ca_path: '/etc/ssl/certsZOMG') end let(:validator) do - OmniAuth::Strategies::CAS::ServiceTicketValidator.new( strategy, provider_options, '/foo', nil ) + described_class.new(strategy, provider_options, '/foo', nil) end describe '#call' do + subject { validator.call } + before do stub_request(:get, 'https://example.org/serviceValidate?') .to_return(status: 200, body: '') end - subject { validator.call } - it 'returns itself' do expect(subject).to eq validator end @@ -36,6 +36,8 @@ end describe '#user_info' do + subject { validator.user_info } + let(:ok_fixture) do File.expand_path(File.join(File.dirname(__FILE__), '../../../fixtures/cas_success.xml')) end @@ -43,12 +45,10 @@ before do stub_request(:get, 'https://example.org/serviceValidate?') - .to_return(status: 200, body:service_response) + .to_return(status: 200, body: service_response) validator.call end - subject { validator.user_info } - context 'with default settings' do it 'parses user info from the response' do expect(subject).to include 'user' => 'psegel' @@ -59,10 +59,9 @@ context 'when merging multivalued attributes' do let(:provider_options) do double('provider_options', - disable_ssl_verification?: false, - merge_multivalued_attributes: true, - ca_path: '/etc/ssl/certsZOMG' - ) + disable_ssl_verification?: false, + merge_multivalued_attributes: true, + ca_path: '/etc/ssl/certsZOMG') end it 'parses multivalued user info from the response' do diff --git a/spec/omniauth/strategies/cas_spec.rb b/spec/omniauth/strategies/cas_spec.rb index 350161e..57a385b 100644 --- a/spec/omniauth/strategies/cas_spec.rb +++ b/spec/omniauth/strategies/cas_spec.rb @@ -1,39 +1,46 @@ +# frozen_string_literal: true + require 'spec_helper' describe OmniAuth::Strategies::CAS, type: :strategy do include Rack::Test::Methods - let(:my_cas_provider) { Class.new(OmniAuth::Strategies::CAS) } - before do - stub_const 'MyCasProvider', my_cas_provider - end + let(:my_cas_provider) { Class.new(described_class) } let(:app) do - Rack::Builder.new { + Rack::Builder.new do use OmniAuth::Test::PhonySession use MyCasProvider, - name: :cas, - host: 'cas.example.org', - ssl: false, - port: 8080, - uid_field: :employeeid, - fetch_raw_info: Proc.new { |v, opts, ticket, info, node| - info.empty? ? {} : { - "roles" => node.xpath('//cas:roles').map(&:text), + name: :cas, + host: 'cas.example.org', + ssl: false, + port: 8080, + uid_field: :employeeid, + fetch_raw_info: proc { |_v, _opts, _ticket, info, node| + if info.empty? + {} + else + { + 'roles' => node.xpath('//cas:roles').map(&:text) + } + end } - } - run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] } - }.to_app + run ->(env) { [404, { 'Content-Type' => 'text/plain' }, [env.key?('omniauth.auth').to_s]] } + end.to_app + end + + before do + stub_const 'MyCasProvider', my_cas_provider end # TODO: Verify that these are even useful tests shared_examples_for 'a CAS redirect response' do - let(:redirect_params) { 'service=' + Rack::Utils.escape("http://example.org/auth/cas/callback?url=#{Rack::Utils.escape(return_url)}") } + subject { last_response } - before { get url, nil, request_env } + let(:redirect_params) { "service=#{Rack::Utils.escape("http://example.org/auth/cas/callback?url=#{Rack::Utils.escape(return_url)}")}" } - subject { last_response } + before { get url, nil, request_env } - it { should be_redirect } + it { is_expected.to be_redirect } it 'redirects to the CAS server' do expect(subject.headers).to include 'Location' => "http://cas.example.org:8080/login?#{redirect_params}" @@ -41,43 +48,43 @@ end describe '#cas_url' do - let(:params) { Hash.new } - let(:provider) { MyCasProvider.new(nil, params) } - subject { provider.cas_url } + let(:params) { {} } + let(:provider) { MyCasProvider.new(nil, params) } + it 'raises an ArgumentError' do - expect{subject}.to raise_error ArgumentError, %r{:host and :login_url MUST be provided} + expect { subject }.to raise_error ArgumentError, /:host and :login_url MUST be provided/ end context 'with an explicit :url option' do let(:url) { 'https://example.org:8080/my_cas' } - let(:params) { super().merge url:url } + let(:params) { super().merge url: url } before { subject } - it { should eq url } + it { is_expected.to eq url } it 'parses the URL into it the appropriate strategy options' do - expect(provider.options).to include ssl:true - expect(provider.options).to include host:'example.org' - expect(provider.options).to include port:8080 - expect(provider.options).to include path:'/my_cas' + expect(provider.options).to include ssl: true + expect(provider.options).to include host: 'example.org' + expect(provider.options).to include port: 8080 + expect(provider.options).to include path: '/my_cas' end end context 'with explicit URL component' do - let(:params) { super().merge host:'example.org', port:1234, ssl:true, path:'/a/path' } + let(:params) { super().merge host: 'example.org', port: 1234, ssl: true, path: '/a/path' } before { subject } - it { should eq 'https://example.org:1234/a/path' } + it { is_expected.to eq 'https://example.org:1234/a/path' } it 'parses the URL into it the appropriate strategy options' do - expect(provider.options).to include ssl:true - expect(provider.options).to include host:'example.org' - expect(provider.options).to include port:1234 - expect(provider.options).to include path:'/a/path' + expect(provider.options).to include ssl: true + expect(provider.options).to include host: 'example.org' + expect(provider.options).to include port: 1234 + expect(provider.options).to include path: '/a/path' end end end @@ -85,7 +92,7 @@ describe 'defaults' do subject { MyCasProvider.default_options.to_hash } - it { should include('ssl' => true) } + it { is_expected.to include('ssl' => true) } end describe 'GET /auth/cas' do @@ -110,11 +117,11 @@ describe 'GET /auth/cas/callback' do context 'without a ticket' do - before { get '/auth/cas/callback' } - subject { last_response } - it { should be_redirect } + before { get '/auth/cas/callback' } + + it { is_expected.to be_redirect } it 'redirects with a failure message' do expect(subject.headers).to include 'Location' => '/auth/failure?message=no_ticket&strategy=cas' @@ -122,15 +129,15 @@ end context 'with an invalid ticket' do + subject { last_response } + before do - stub_request(:get, /^http:\/\/cas.example.org:8080?\/serviceValidate\?([^&]+&)?ticket=9391d/). - to_return( body: File.read('spec/fixtures/cas_failure.xml') ) + stub_request(:get, %r{^http://cas.example.org:8080?/serviceValidate\?([^&]+&)?ticket=9391d}) + .to_return(body: File.read('spec/fixtures/cas_failure.xml')) get '/auth/cas/callback?ticket=9391d' end - subject { last_response } - - it { should be_redirect } + it { is_expected.to be_redirect } it 'redirects with a failure message' do expect(subject.headers).to include 'Location' => '/auth/failure?message=invalid_ticket&strategy=cas' @@ -138,11 +145,11 @@ end describe 'with a valid ticket' do - shared_examples :successful_validation do + shared_examples 'successful validation' do before do - stub_request(:get, /^http:\/\/cas.example.org:8080?\/serviceValidate\?([^&]+&)?ticket=593af/) + stub_request(:get, %r{^http://cas.example.org:8080?/serviceValidate\?([^&]+&)?ticket=593af}) .with { |request| @request_uri = request.uri.to_s } - .to_return( body: File.read("spec/fixtures/#{xml_file_name}") ) + .to_return(body: File.read("spec/fixtures/#{xml_file_name}")) get "/auth/cas/callback?ticket=593af&url=#{return_url}" end @@ -154,15 +161,15 @@ it 'properly encodes the service URL' do expect(WebMock).to have_requested(:get, 'http://cas.example.org:8080/serviceValidate') .with(query: { - ticket: '593af', - service: 'http://example.org/auth/cas/callback?url=' + Rack::Utils.escape('http://127.0.0.10/?some=parameter') - }) + ticket: '593af', + service: "http://example.org/auth/cas/callback?url=#{Rack::Utils.escape('http://127.0.0.10/?some=parameter')}" + }) end context "request.env['omniauth.auth']" do subject { last_request.env['omniauth.auth'] } - it { should be_kind_of Hash } + it { is_expected.to be_a Hash } it 'identifes the provider' do expect(subject.provider).to eq :cas @@ -194,7 +201,7 @@ expect(subject.user).to eq 'psegel' expect(subject.employeeid).to eq '54' expect(subject.hire_date).to eq '2004-07-13' - expect(subject.roles).to eq %w(senator lobbyist financier) + expect(subject.roles).to eq %w[senator lobbyist financier] end end @@ -217,38 +224,38 @@ context 'with JASIG flavored XML' do let(:xml_file_name) { 'cas_success_jasig.xml' } - it_behaves_like :successful_validation + it_behaves_like 'successful validation' end context 'with classic XML' do let(:xml_file_name) { 'cas_success.xml' } - it_behaves_like :successful_validation + it_behaves_like 'successful validation' end end end describe 'POST /auth/cas/callback' do describe 'with a Single Sign-Out logoutRequest' do + subject do + post 'auth/cas/callback', logoutRequest: logoutRequest + end + let(:logoutRequest) do - %Q[ - + %( + @NOT_USED@ ST-123456-123abc456def - ] + ) end - let(:logout_request) { double('logout_request', call:[200,{},'OK']) } - - subject do - post 'auth/cas/callback', logoutRequest:logoutRequest - end + let(:logout_request) { double('logout_request', call: [200, {}, 'OK']) } before do allow_any_instance_of(MyCasProvider) .to receive(:logout_request_service) - .and_return double('LogoutRequest', new:logout_request) + .and_return double('LogoutRequest', new: logout_request) subject end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e5f0a48..5829920 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if ENV['CI'] || ENV['COVERAGE'] require 'simplecov' @@ -6,7 +8,6 @@ end end -require 'bundler/setup' require 'awesome_print' RSpec.configure do |c| @@ -18,4 +19,4 @@ require 'webmock/rspec' require 'omniauth-cas' -OmniAuth.config.logger = Logger.new( '/dev/null' ) +OmniAuth.config.logger = Logger.new('/dev/null') From 444db86f5433352b46fba81626d303f9880c060a Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Tue, 9 Jan 2024 17:30:38 +0100 Subject: [PATCH 3/4] Auto generate RuboCop config --- .gitattributes | 1 + .rubocop.yml | 2 + .rubocop_todo.yml | 330 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 333 insertions(+) create mode 100644 .gitattributes create mode 100644 .rubocop_todo.yml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6fd6061 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.rubocop_todo.yml linguist-generated diff --git a/.rubocop.yml b/.rubocop.yml index 60284a0..ac85a33 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +inherit_from: .rubocop_todo.yml + require: - rubocop-packaging - rubocop-performance diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..7e087dc --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,330 @@ +# This configuration was generated by +# `rubocop --auto-gen-config --no-offense-counts --no-auto-gen-timestamp` +# using RuboCop version 1.59.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IndentationWidth. +# SupportedStyles: outdent, indent +Layout/AccessModifierIndentation: + EnforcedStyle: outdent + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_argument, with_fixed_indentation +Layout/ArgumentAlignment: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAfterColon: + Exclude: + - 'lib/omniauth/strategies/cas/logout_request.rb' + +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAfterComma: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + - 'lib/omniauth/strategies/cas/logout_request.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingEmptyLines: + Exclude: + - 'lib/omniauth/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +Lint/EnsureReturn: + Exclude: + - 'lib/omniauth/strategies/cas/logout_request.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/UselessAssignment: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +Lint/UselessRescue: + Exclude: + - 'lib/omniauth/strategies/cas/logout_request.rb' + +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 26 + +# Configuration parameters: CountBlocks. +Metrics/BlockNesting: + Max: 4 + +# Configuration parameters: CountComments, CountAsOne. +Metrics/ClassLength: + Max: 149 + +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/CyclomaticComplexity: + Max: 9 + +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Max: 18 + +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/PerceivedComplexity: + Max: 11 + +Naming/AccessorMethodName: + Exclude: + - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' + +Naming/ConstantName: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# CheckDefinitionPathHierarchyRoots: lib, spec, test, src +# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS +Naming/FileName: + Exclude: + - 'lib/omniauth-cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/omniauth/strategies/cas/logout_request.rb' + +RSpec/AnyInstance: + Exclude: + - 'spec/omniauth/strategies/cas_spec.rb' + +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/omniauth/strategies/cas/logout_request_spec.rb' + - 'spec/omniauth/strategies/cas_spec.rb' + +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 8 + +RSpec/ExpectInHook: + Exclude: + - 'spec/omniauth/strategies/cas/logout_request_spec.rb' + +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/FilePath: + Exclude: + - 'spec/omniauth/strategies/cas/logout_request_spec.rb' + - 'spec/omniauth/strategies/cas/service_ticket_validator_spec.rb' + - 'spec/omniauth/strategies/cas_spec.rb' + +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Exclude: + - 'spec/omniauth/strategies/cas/logout_request_spec.rb' + - 'spec/omniauth/strategies/cas_spec.rb' + +RSpec/MultipleExpectations: + Max: 8 + +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 10 + +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only +RSpec/NamedSubject: + Exclude: + - 'spec/omniauth/strategies/cas/logout_request_spec.rb' + - 'spec/omniauth/strategies/cas/service_ticket_validator_spec.rb' + - 'spec/omniauth/strategies/cas_spec.rb' + +# Configuration parameters: AllowedGroups. +RSpec/NestedGroups: + Max: 5 + +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Exclude: + - '**/spec/routing/**/*' + - 'spec/omniauth/strategies/cas/logout_request_spec.rb' + - 'spec/omniauth/strategies/cas/service_ticket_validator_spec.rb' + - 'spec/omniauth/strategies/cas_spec.rb' + +# Configuration parameters: EnforcedStyle, AllowedPatterns. +# SupportedStyles: snake_case, camelCase +RSpec/VariableName: + Exclude: + - 'spec/omniauth/strategies/cas/logout_request_spec.rb' + - 'spec/omniauth/strategies/cas_spec.rb' + +# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. +RSpec/VerifiedDoubles: + Exclude: + - 'spec/omniauth/strategies/cas/logout_request_spec.rb' + - 'spec/omniauth/strategies/cas/service_ticket_validator_spec.rb' + - 'spec/omniauth/strategies/cas_spec.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: prefer_alias, prefer_alias_method +Style/Alias: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: is_a?, kind_of? +Style/ClassCheck: + Exclude: + - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' + +# Configuration parameters: AllowedConstants. +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'lib/omniauth/strategies/cas.rb' + - 'lib/omniauth/strategies/cas/logout_request.rb' + - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' + +# This cop supports safe autocorrection (--autocorrect). +Style/EmptyLiteral: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'lib/omniauth-cas.rb' + - 'lib/omniauth/cas.rb' + - 'lib/omniauth/cas/version.rb' + - 'lib/omniauth/strategies/cas.rb' + - 'lib/omniauth/strategies/cas/logout_request.rb' + - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. +Style/GuardClause: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +Style/IfUnlessModifier: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/omniauth/cas/version.rb' + - 'lib/omniauth/strategies/cas.rb' + - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' + +# This cop supports safe autocorrection (--autocorrect). +Style/ParallelAssignment: + Exclude: + - 'lib/omniauth/strategies/cas/logout_request.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +Style/Proc: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowedCompactTypes. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'lib/omniauth/strategies/cas/logout_request.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'lib/omniauth/strategies/cas/logout_request.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'lib/omniauth/strategies/cas.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 210 From 6d0ec6704bcb07c32ee3579e8d32410799ecb962 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Tue, 9 Jan 2024 19:29:26 +0100 Subject: [PATCH 4/4] Fix trivial offenses in non-production code - RSpec/ExpectInHook - RSpec/FilePath - RSpec/SpecFilePathFormat --- .rubocop.yml | 8 +++++++ .rubocop_todo.yml | 21 ------------------- .../strategies/cas/logout_request_spec.rb | 1 - 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ac85a33..2f96046 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,3 +14,11 @@ AllCops: Exclude: - 'gemfiles/**/*' - 'vendor/bundle/**/*' + +RSpec/FilePath: + CustomTransform: + OmniAuth: omniauth + +RSpec/SpecFilePathFormat: + CustomTransform: + OmniAuth: omniauth diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7e087dc..6b9d58f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -138,18 +138,6 @@ RSpec/ContextWording: RSpec/ExampleLength: Max: 8 -RSpec/ExpectInHook: - Exclude: - - 'spec/omniauth/strategies/cas/logout_request_spec.rb' - -# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/FilePath: - Exclude: - - 'spec/omniauth/strategies/cas/logout_request_spec.rb' - - 'spec/omniauth/strategies/cas/service_ticket_validator_spec.rb' - - 'spec/omniauth/strategies/cas_spec.rb' - # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: @@ -175,15 +163,6 @@ RSpec/NamedSubject: RSpec/NestedGroups: Max: 5 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. -# Include: **/*_spec.rb -RSpec/SpecFilePathFormat: - Exclude: - - '**/spec/routing/**/*' - - 'spec/omniauth/strategies/cas/logout_request_spec.rb' - - 'spec/omniauth/strategies/cas/service_ticket_validator_spec.rb' - - 'spec/omniauth/strategies/cas_spec.rb' - # Configuration parameters: EnforcedStyle, AllowedPatterns. # SupportedStyles: snake_case, camelCase RSpec/VariableName: diff --git a/spec/omniauth/strategies/cas/logout_request_spec.rb b/spec/omniauth/strategies/cas/logout_request_spec.rb index 03f5ad7..1452023 100644 --- a/spec/omniauth/strategies/cas/logout_request_spec.rb +++ b/spec/omniauth/strategies/cas/logout_request_spec.rb @@ -46,7 +46,6 @@ before do allow(strategy).to receive(:fail!) subject - expect(strategy).to have_received(:fail!) end it 'responds with an error' do