Skip to content

Commit

Permalink
Autocorrect masked rubocop offences
Browse files Browse the repository at this point in the history
Process:
* Remove inclusion of todo file
* Run rubocop -a
* Restore inclusion of todo file
  • Loading branch information
mvz committed Aug 12, 2015
1 parent 067ee9a commit 2342518
Show file tree
Hide file tree
Showing 26 changed files with 56 additions and 46 deletions.
4 changes: 1 addition & 3 deletions app/controllers/admin/feedback_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/admin/migrations_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,4 +18,3 @@ def migrator
@migrator ||= Migrator.new
end
end

6 changes: 3 additions & 3 deletions app/controllers/admin/seo_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/themes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'),
Expand Down
4 changes: 1 addition & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions app/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/models/article/factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion app/models/config_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/models/theme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion lib/backpack_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion lib/publify_login_system/access_control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ class ProjectModule

def initialize(name, controller = nil)
@name = name
@controllers, @menus, @submenus = [], [], []
@controllers = []
@menus = []
@submenus = []
@controllers << controller
end

Expand Down
2 changes: 1 addition & 1 deletion lib/publify_textfilter_twitterfilter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions lib/sidebar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/text_filter_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions spec/controllers/admin/dashboard_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/seo_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/settings_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/trackbacks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions spec/lib/publify_time_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions spec/models/article_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions spec/support/mocks/flickr_mock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2342518

Please sign in to comment.