From f9172d553eb1ec543f22944587216a6a6c1d4cb3 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Wed, 4 Nov 2015 22:22:41 +0100 Subject: [PATCH] Rubocop: simplify regexp literals with slashes in them --- .rubocop_todo.yml | 9 --------- app/models/app.rb | 2 +- config/initializers/ssl_enforcer.rb | 2 +- config/load.rb | 2 +- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3b2ff31..0df2d92 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -220,15 +220,6 @@ Style/Proc: - 'app/models/notice.rb' - 'app/models/problem.rb' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. -Style/RegexpLiteral: - Exclude: - - 'app/models/app.rb' - - 'config/initializers/ssl_enforcer.rb' - - 'config/load.rb' - # Offense count: 1 # Configuration parameters: Methods. Style/SingleLineBlockParams: diff --git a/app/models/app.rb b/app/models/app.rb index b66a771..6de9262 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -214,7 +214,7 @@ protected github_host = URI.parse(Errbit::Config.github_url).host github_host = Regexp.escape(github_host) github_repo.strip! - github_repo.sub!(/(git@|https?:\/\/)#{github_host}(\/|:)/, '') + github_repo.sub!(%r{(git@|https?://)#{github_host}(/|:)}, '') github_repo.sub!(/\.git$/, '') end end diff --git a/config/initializers/ssl_enforcer.rb b/config/initializers/ssl_enforcer.rb index d950a5f..6ce44ed 100644 --- a/config/initializers/ssl_enforcer.rb +++ b/config/initializers/ssl_enforcer.rb @@ -3,6 +3,6 @@ if Errbit::Config.enforce_ssl require 'rack/ssl-enforcer' ActionMailer::Base.default_url_options.merge!(:protocol => 'https://') Rails.application.configure do - config.middleware.use Rack::SslEnforcer, :except => /^\/deploys/ + config.middleware.use Rack::SslEnforcer, :except => %r{^/deploys} end end diff --git a/config/load.rb b/config/load.rb index 0afccc0..3f6fb7e 100644 --- a/config/load.rb +++ b/config/load.rb @@ -30,7 +30,7 @@ Errbit::Config = Configurator.run({ # github github_url: ['GITHUB_URL', ->(values) { - values[:github_url].gsub(/\/*\z/, '') + values[:github_url].gsub(%r{/*\z}, '') }], github_authentication: ['GITHUB_AUTHENTICATION'], github_client_id: ['GITHUB_CLIENT_ID'], -- libgit2 0.21.2