Permalink
Browse files

Autocorrect masked rubocop offences

Process:
* Remove inclusion of todo file
* Run rubocop -a
* Restore inclusion of todo file
  • Loading branch information...
1 parent 067ee9a commit 234251819ba1faef743ce6606db65085b46ec26e @mvz mvz committed Aug 12, 2015
@@ -19,9 +19,7 @@ def destroy
@record = Feedback.find params[:id]
unless @record.article.user_id == current_user.id
- unless current_user.admin?
- return redirect_to admin_feedback_index_url
- end
+ return redirect_to admin_feedback_index_url unless current_user.admin?
end
begin
@@ -1,6 +1,6 @@
class Admin::MigrationsController < Admin::BaseController
cache_sweeper :blog_sweeper
- skip_before_filter :look_for_needed_db_updates
+ skip_before_action :look_for_needed_db_updates
def show
@current_version = migrator.current_schema_version
@@ -18,4 +18,3 @@ def migrator
@migrator ||= Migrator.new
end
end
-
@@ -5,8 +5,8 @@ class Admin::SeoController < Admin::BaseController
def show
if @setting.permalink_format != '/%year%/%month%/%day%/%title%' &&
- @setting.permalink_format != '/%year%/%month%/%title%' &&
- @setting.permalink_format != '/%title%'
+ @setting.permalink_format != '/%year%/%month%/%title%' &&
+ @setting.permalink_format != '/%title%'
@setting.custom_permalink = @setting.permalink_format
@setting.permalink_format = 'custom'
end
@@ -32,7 +32,7 @@ def settings_params
@settings_params ||= params.require(:setting).permit!
end
- VALID_SECTIONS = ['general', 'titles', 'permalinks']
+ VALID_SECTIONS = %w(general titles permalinks)
def set_section
section = params[:section]
@@ -15,8 +15,8 @@ def index
def preview
theme = Theme.find(params[:theme])
- send_file File.join(theme.path, "preview.png"),
- type: 'image/png', disposition: 'inline', stream: false
+ send_file File.join(theme.path, 'preview.png'),
+ type: 'image/png', disposition: 'inline', stream: false
end
def switchto
@@ -2,7 +2,7 @@ module Admin::BaseHelper
include ActionView::Helpers::DateHelper
def toggle_element(element, label = t('.change'))
- link_to(label, "##{element}", :"data-toggle" => :collapse)
+ link_to(label, "##{element}", "data-toggle": :collapse)
end
def dashboard_action_links
@@ -125,7 +125,7 @@ def button_to_edit(item)
end
def button_to_delete(item)
- confirm_text = t("admin.shared.destroy.are_you_sure",
+ confirm_text = t('admin.shared.destroy.are_you_sure',
element: item.class.name.downcase)
link_to(
content_tag(:span, '', class: 'glyphicon glyphicon-trash'),
@@ -43,9 +43,7 @@ def render_deprecated_sidebar_view_in_view_root(sidebar)
def themeable_stylesheet_link_tag(name)
src = this_blog.current_theme.path + "/stylesheets/#{name}.css"
- if File.exist? src
- stylesheet_link_tag "/stylesheets/theme/#{name}.css"
- end
+ stylesheet_link_tag "/stylesheets/theme/#{name}.css" if File.exist? src
end
def articles?
@@ -183,12 +183,12 @@ def self.find_by_permalink(params)
req_params[:published_at] = date_range if date_range
return if req_params.empty? # no search if no params send
- article = published.where(req_params).first
+ article = published.find_by(req_params)
return article if article
if params[:title]
req_params[:permalink] = CGI.escape(params[:title])
- article = published.where(req_params).first
+ article = published.find_by(req_params)
return article if article
end
end
@@ -2,7 +2,8 @@ class Article::Factory
attr_reader :blog, :user
def initialize(blog, user)
- @blog, @user = blog, user
+ @blog = blog
+ @user = user
end
def default
@@ -11,7 +11,9 @@ def fields
def setting(name, type = :object, default = nil)
item = Item.new
- item.name, item.ruby_type, item.default = name.to_s, type, default
+ item.name = name.to_s
+ item.ruby_type = type
+ item.default = default
fields[name.to_s] = item
add_setting_accessor(item)
end
@@ -32,7 +32,7 @@ class Content < ActiveRecord::Base
scope :published_at_like, lambda { |date_at|
where(published_at: (PublifyTime.delta_like(date_at))
- )
+ )
}
serialize :whiteboard
@@ -84,7 +84,7 @@ def self.search_with(params)
scoped = scoped.searchstring(params[:searchstring])
end
- if params[:published_at].present? && %r{(\d\d\d\d)-(\d\d)} =~ params[:published_at]
+ if params[:published_at].present? && /(\d\d\d\d)-(\d\d)/ =~ params[:published_at]
scoped = scoped.published_at_like(params[:published_at])
end
View
@@ -26,7 +26,7 @@ def self.create_from_article!(article)
end
def self.find_by_name_or_display_name(tagname, name)
- where(%(name = ? OR display_name = ? OR display_name = ?), tagname, tagname, name).first
+ find_by(%(name = ? OR display_name = ? OR display_name = ?), tagname, tagname, name)
end
def ensure_naming_conventions
View
@@ -5,7 +5,8 @@ class Theme
attr_accessor :name, :path, :description_html
def initialize(name, path)
- @name, @path = name, path
+ @name = name
+ @path = path
end
def layout(action = :default)
View
@@ -60,7 +60,7 @@ def display_names
end
def self.authenticate(login, pass)
- where('login = ? AND password = ? AND state = ?', login, password_hash(pass), 'active').first
+ find_by('login = ? AND password = ? AND state = ?', login, password_hash(pass), 'active')
end
def update_connection_time
View
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
-require ::File.expand_path('../config/environment', __FILE__)
+require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
View
@@ -8,7 +8,8 @@ class BackpackAPI
attr_accessor :username, :token, :current_page_id
def initialize(username, token)
- @username, @token = username, token
+ @username = username
+ @token = token
connect
end
@@ -107,7 +107,9 @@ class ProjectModule
def initialize(name, controller = nil)
@name = name
- @controllers, @menus, @submenus = [], [], []
+ @controllers = []
+ @menus = []
+ @submenus = []
@controllers << controller
end
@@ -20,7 +20,7 @@ def self.filtertext(_blog, _content, text, _params)
# @mention
text.to_s.split.grep(/@\w+/) do |item|
- uri = URI.escape("https://twitter.com/#{item.strip_html.gsub('@', '')}")
+ uri = URI.escape("https://twitter.com/#{item.strip_html.delete('@')}")
text = text.gsub(item, "<a href='#{uri}'>#{item.strip_html}</a>")
end
View
@@ -10,7 +10,9 @@ class Field
include ActionView::Helpers::FormOptionsHelper
def initialize(key, default, options = {})
- @key, @default, @options = key.to_s, default, options
+ @key = key.to_s
+ @default = default
+ @options = options
end
def label
@@ -174,7 +176,7 @@ def self.description(desc = nil)
end
def self.short_name
- to_s.underscore.split(%r{_}).first
+ to_s.underscore.split(/_/).first
end
def self.path_name
@@ -76,12 +76,12 @@ def self.attributes_parse(string)
string.gsub(/([^ =]+="[^"]*")/) do |match|
key, value = match.split(/=/, 2)
- attributes[key] = value.gsub(/"/, '')
+ attributes[key] = value.delete("\"")
end
string.gsub(/([^ =]+='[^']*')/) do |match|
key, value = match.split(/=/, 2)
- attributes[key] = value.gsub(/'/, '')
+ attributes[key] = value.delete("'")
end
attributes
@@ -169,9 +169,11 @@
describe '#index' do
context 'with pending migrations' do
let!(:blog) { create(:blog) }
- let(:user) { create(:user,
- login: 'henri',
- profile: create(:profile_admin, label: Profile::ADMIN)) }
+ let(:user) do
+ create(:user,
+ login: 'henri',
+ profile: create(:profile_admin, label: Profile::ADMIN))
+ end
let(:migrator) { double('migrator') }
before do
@@ -21,7 +21,7 @@
before { get :show, section: :permalinks }
it 'renders the general section' do
- expect(response).to render_template('_permalinks')
+ expect(response).to render_template('_permalinks')
end
end
@@ -32,7 +32,7 @@
describe '#update' do
before do
- post :update, setting: { blog_name: 'New name'}
+ post :update, setting: { blog_name: 'New name' }
end
it 'updates the settings' do
@@ -28,7 +28,7 @@
let(:article) { create :article }
it 'creates a Trackback when given valid params' do
post :create, article_id: article.id, blog_name: 'Foo',
- excerpt: 'Tracking you back!', title: 'Bar', url: 'http://www.foo.com/bar'
+ excerpt: 'Tracking you back!', title: 'Bar', url: 'http://www.foo.com/bar'
expect(Trackback.last.excerpt).to eq 'Tracking you back!'
end
end
@@ -88,7 +88,9 @@
@a.save!
params = @a.permalink_url.gsub('http://myblog.net/', '').split('/')
- @year, @month, @day = params[0], params[1], params[2]
+ @year = params[0]
+ @month = params[1]
+ @day = params[2]
end
it 'delta given year' do
@@ -131,7 +133,9 @@
@a.save!
params = @a.permalink_url.gsub('http://myblog.net/', '').split('/')
- @year, @month, @day = params[0], params[1], params[2]
+ @year = params[0]
+ @month = params[1]
+ @day = params[2]
end
it 'delta given year' do
@@ -159,9 +159,11 @@
let(:referenced_url) { 'http://anotherblog.org/a-post' }
let!(:blog) { create(:blog, send_outbound_pings: 1) }
let(:mock_pinger) { instance_double('Ping::Pinger') }
- let(:article) { Article.new(body: %(<a href="#{referenced_url}">),
- title: 'Test the pinging',
- published: true) }
+ let(:article) do
+ Article.new(body: %(<a href="#{referenced_url}">),
+ title: 'Test the pinging',
+ published: true)
+ end
before do
# Check supposition
@@ -20,9 +20,7 @@ def getSizes(_params) # rubocop:disable MethodName
class Photo
def initialize(photoid)
- unless photoid == '31366117'
- raise 'Photo not found'
- end
+ raise 'Photo not found' unless photoid == '31366117'
end
def description

0 comments on commit 2342518

Please sign in to comment.