Permalink
Browse files

Merge pull request #835 from publify/update-rubocop

Update for rubocop 0.52.0
  • Loading branch information...
mvz committed Dec 16, 2017
2 parents 677d8a3 + e25f41c commit eda50186f5199801c10b5a4b0f7b3f244db38dd8
View
@@ -42,6 +42,10 @@ Layout/MultilineMethodCallIndentation:
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
# Uniform block layout
Layout/SpaceBeforeBlockBraces:
EnforcedStyleForEmptyBraces: space
# Assume the programmer knows how bracketed block syntax works
Lint/AmbiguousBlockAssociation:
Enabled: false
@@ -147,6 +151,11 @@ Style/EachWithObject:
Style/FormatString:
Enabled: false
# This cop has too many false positives
# TODO: Re-enable once fixed
Style/FormatStringToken:
Enabled: false
# TODO: Re-enable?
Style/NumericPredicate:
Enabled: false
View
@@ -1,20 +1,16 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-10-20 14:42:54 +0200 using RuboCop version 0.51.0.
# on 2017-12-16 14:03:40 +0100 using RuboCop version 0.52.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.
# Offense count: 8
Lint/RescueWithoutErrorClass:
# Offense count: 1
# Cop supports --auto-correct.
Layout/EmptyLinesAroundArguments:
Exclude:
- 'db/migrate/20150808052637_add_blog_ids.publify_core_engine.rb'
- 'lib/publify_textfilter_flickr.rb'
- 'publify_core/app/controllers/admin/dashboard_controller.rb'
- 'publify_core/app/helpers/base_helper.rb'
- 'publify_core/db/migrate/20150808052637_add_blog_ids.rb'
- 'publify_textfilter_code/lib/publify_app/textfilter_code.rb'
- 'publify_core/app/models/static_sidebar.rb'
# Offense count: 3
Lint/UriEscapeUnescape:
@@ -37,6 +33,30 @@ Naming/PredicateName:
- 'publify_core/app/models/user.rb'
- 'publify_core/lib/spam_protection.rb'
# Offense count: 23
# Configuration parameters: Include.
# Include: db/migrate/*.rb
Rails/CreateTableWithTimestamps:
Exclude:
- 'db/migrate/113_initial_schema.publify_core_engine.rb'
- 'db/migrate/20150807134129_simplify_redirect_relations.publify_core_engine.rb'
- 'db/migrate/20160110094906_remove_profiles_rights.publify_core_engine.rb'
- 'db/migrate/20160605154632_remove_profiles.publify_core_engine.rb'
# Offense count: 6
# Cop supports --auto-correct.
Rails/Presence:
Exclude:
- 'publify_core/app/helpers/base_helper.rb'
- 'publify_core/app/models/blog.rb'
- 'publify_core/app/models/user.rb'
# Offense count: 3
# Cop supports --auto-correct.
Rails/RedundantReceiverInWithOptions:
Exclude:
- 'publify_core/app/controllers/content_controller.rb'
# Offense count: 3
Security/Eval:
Exclude:
@@ -69,7 +89,34 @@ Style/DateTime:
- 'publify_core/spec/models/feedback_spec.rb'
- 'spec/factories.rb'
# Offense count: 24
# Offense count: 4
# Cop supports --auto-correct.
Style/EmptyLambdaParameter:
Exclude:
- 'publify_core/app/models/blog.rb'
- 'publify_core/app/models/feedback.rb'
- 'publify_core/app/models/sidebar.rb'
# Offense count: 3
Style/EvalWithLocation:
Exclude:
- 'publify_core/app/models/content_base.rb'
- 'publify_core/lib/publify_plugins.rb'
# Offense count: 21
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, explicit
Style/RescueStandardError:
Exclude:
- 'db/migrate/20150808052637_add_blog_ids.publify_core_engine.rb'
- 'lib/publify_textfilter_flickr.rb'
- 'publify_core/app/controllers/admin/dashboard_controller.rb'
- 'publify_core/app/helpers/base_helper.rb'
- 'publify_core/db/migrate/20150808052637_add_blog_ids.rb'
- 'publify_textfilter_code/lib/publify_app/textfilter_code.rb'
@@ -6,9 +6,7 @@ def up
add_column :redirects, :content_id, :integer
Redirect.find_each do |redirect|
redirections = Redirection.where(redirect_id: redirect.id)
if redirections.count > 1
raise "Expected zero or one redirections, found #{redirections.count}"
end
raise "Expected zero or one redirections, found #{redirections.count}" if redirections.count > 1
redirection = redirections.first
next unless redirection
redirect.content_id = redirection.content_id
@@ -12,9 +12,7 @@ def show
end
def update
if settings_params[:permalink_format] == 'custom'
settings_params[:permalink_format] = settings_params[:custom_permalink]
end
settings_params[:permalink_format] = settings_params[:custom_permalink] if settings_params[:permalink_format] == 'custom'
if @setting.update_attributes(settings_params)
flash[:success] = I18n.t('admin.settings.update.success')
redirect_to admin_seo_path(section: @section)
@@ -13,9 +13,7 @@ def create
remember_author_info_for @comment
partial = '/articles/comment_failed'
if recaptcha_ok_for?(@comment) && @comment.save
partial = '/articles/comment'
end
partial = '/articles/comment' if recaptcha_ok_for?(@comment) && @comment.save
respond_to do |format|
format.js { render partial }
format.html { redirect_to URI.parse(@article.permalink_url).path }
@@ -52,9 +50,7 @@ def new_comment_defaults
def remember_author_info_for(comment)
add_to_cookies(:author, comment.author)
add_to_cookies(:url, comment.url)
if comment.email.present?
add_to_cookies(:gravatar_id, Digest::MD5.hexdigest(comment.email.strip))
end
add_to_cookies(:gravatar_id, Digest::MD5.hexdigest(comment.email.strip)) if comment.email.present?
end
def set_article
@@ -99,9 +99,7 @@ def self.last_draft(article_id)
def self.search_with(params)
params ||= {}
scoped = super(params)
if %w(no_draft drafts published withdrawn pending).include?(params[:state])
scoped = scoped.send(params[:state])
end
scoped = scoped.send(params[:state]) if %w(no_draft drafts published withdrawn pending).include?(params[:state])
scoped.order('created_at DESC')
end
@@ -202,9 +200,7 @@ def comments_closed?
def html_urls
urls = []
html.gsub(/<a\s+[^>]*>/) do |tag|
if tag =~ /\bhref=(["']?)([^ >"]+)\1/
urls.push(Regexp.last_match[2].strip)
end
urls.push(Regexp.last_match[2].strip) if tag =~ /\bhref=(["']?)([^ >"]+)\1/
end
urls.uniq
end
@@ -179,9 +179,7 @@ def url_for(options = {}, extra_params = {})
host: host_with_port,
script_name: root_path)
cache_key = merged_opts.values.prepend('blog-urlfor-withbaseurl').join('-')
unless Rails.cache.exist?(cache_key)
Rails.cache.write(cache_key, super(merged_opts))
end
Rails.cache.write(cache_key, super(merged_opts)) unless Rails.cache.exist?(cache_key)
Rails.cache.read(cache_key)
else
raise "Invalid URL in url_for: #{options.inspect}"
@@ -219,13 +217,9 @@ def rss_limit_params
end
def permalink_has_identifier
unless permalink_format =~ /(%title%)/
errors.add(:base, I18n.t('errors.permalink_need_a_title'))
end
errors.add(:base, I18n.t('errors.permalink_need_a_title')) unless permalink_format =~ /(%title%)/
if permalink_format =~ /\.(atom|rss)$/
errors.add(:permalink_format, I18n.t('errors.cant_end_with_rss_or_atom'))
end
errors.add(:permalink_format, I18n.t('errors.cant_end_with_rss_or_atom')) if permalink_format =~ /\.(atom|rss)$/
end
def root_path
@@ -258,9 +252,7 @@ def host_with_port
def split_base_url
unless @split_base_url
unless base_url =~ %r{(https?)://([^/]*)(.*)}
raise "Invalid base_url: #{base_url}"
end
raise "Invalid base_url: #{base_url}" unless base_url =~ %r{(https?)://([^/]*)(.*)}
@split_base_url = { protocol: Regexp.last_match[1], host_with_port: Regexp.last_match[2], root_path: Regexp.last_match[3].gsub(%r{/$}, '') }
end
@split_base_url
@@ -89,17 +89,11 @@ def self.find_already_published(limit)
def self.search_with(params)
params ||= {}
scoped = unscoped
if params[:searchstring].present?
scoped = scoped.searchstring(params[:searchstring])
end
scoped = scoped.searchstring(params[:searchstring]) if params[:searchstring].present?
if params[:published_at].present? && /(\d\d\d\d)-(\d\d)/ =~ params[:published_at]
scoped = scoped.published_at_like(params[:published_at])
end
scoped = scoped.published_at_like(params[:published_at]) if params[:published_at].present? && /(\d\d\d\d)-(\d\d)/ =~ params[:published_at]
if params[:user_id].present? && params[:user_id].to_i > 0
scoped = scoped.user_id(params[:user_id])
end
scoped = scoped.user_id(params[:user_id]) if params[:user_id].present? && params[:user_id].to_i > 0
if params[:published].present?
scoped = scoped.published if params[:published].to_s == '1'
@@ -34,13 +34,9 @@ def substitute_item(s, item)
s = s.gsub('%author%', item.name) if s =~ /%author%/ && item.respond_to?(:name)
s = s.gsub('%body%', item.body) if s =~ /%body%/ && item.respond_to?(:body)
if s =~ /%categories%/ && item.respond_to?(:categories)
s = s.gsub('%categories%', item.categories.map(&:name).join(', '))
end
s = s.gsub('%categories%', item.categories.map(&:name).join(', ')) if s =~ /%categories%/ && item.respond_to?(:categories)
if s =~ /%tags%/ && item.respond_to?(:tags)
s = s.gsub('%tags%', item.tags.map(&:display_name).join(', '))
end
s = s.gsub('%tags%', item.tags.map(&:display_name).join(', ')) if s =~ /%tags%/ && item.respond_to?(:tags)
s
end
@@ -34,9 +34,7 @@ def image?(new_file)
def check_image_content_type!(new_file)
if image?(new_file)
magic_type = mime_magic_content_type(new_file)
if magic_type != new_file.content_type
raise CarrierWave::IntegrityError, 'has MIME type mismatch'
end
raise CarrierWave::IntegrityError, 'has MIME type mismatch' if magic_type != new_file.content_type
end
end
@@ -1,6 +1,4 @@
feed.title(feed_title)
if this_blog.blog_subtitle.present?
feed.subtitle(this_blog.blog_subtitle, 'type' => 'html')
end
feed.subtitle(this_blog.blog_subtitle, 'type' => 'html') if this_blog.blog_subtitle.present?
feed.updated items.first.updated_at if items.first
feed.generator 'Publify', uri: 'http://www.publify.co', version: PublifyCore::VERSION
@@ -6,9 +6,7 @@ def up
add_column :redirects, :content_id, :integer
Redirect.find_each do |redirect|
redirections = Redirection.where(redirect_id: redirect.id)
if redirections.count > 1
raise "Expected zero or one redirections, found #{redirections.count}"
end
raise "Expected zero or one redirections, found #{redirections.count}" if redirections.count > 1
redirection = redirections.first
next unless redirection
redirect.content_id = redirection.content_id
View
@@ -32,6 +32,4 @@
create_with(description: 'Textile', markup: 'textile', filters: [], params: {}).
find_or_create_by!(name: 'textile')
unless File.directory?("#{::Rails.root}/public/files")
Dir.mkdir("#{::Rails.root}/public/files")
end
Dir.mkdir("#{::Rails.root}/public/files") unless File.directory?("#{::Rails.root}/public/files")
@@ -49,9 +49,7 @@ def scan_text(string)
def check_uri_count(uris)
limit = this_blog.sp_url_limit
return if limit.to_i.zero?
if uris.size > limit
throw :hit, "Hard URL Limit hit: #{uris.size} > #{limit}"
end
throw :hit, "Hard URL Limit hit: #{uris.size} > #{limit}" if uris.size > limit
end
def scan_uris(uris = [])
@@ -8,9 +8,7 @@ def initialize(name, path)
def layout(action = :default)
if action.to_s == 'view_page'
if File.exist? "#{view_path}/layouts/pages.html.erb"
return 'layouts/pages'
end
return 'layouts/pages' if File.exist? "#{view_path}/layouts/pages.html.erb"
end
'layouts/default'
end
@@ -85,9 +85,7 @@ def with_each_theme
Theme.find_all.each do |theme|
theme_dir = theme.path
view_path = "#{theme_dir}/views"
if File.exist?("#{theme_dir}/helpers/theme_helper.rb")
require "#{theme_dir}/helpers/theme_helper.rb"
end
require "#{theme_dir}/helpers/theme_helper.rb" if File.exist?("#{theme_dir}/helpers/theme_helper.rb")
yield theme.name, view_path
end
end
View
@@ -30,8 +30,6 @@ class ActionView::TestCase::TestController
config.include Devise::Test::ControllerHelpers, type: :controller
config.after :each, type: :controller do
if response.body =~ /(&lt;[a-z]+)/
raise "Double escaped HTML in text (#{Regexp.last_match(1)})"
end
raise "Double escaped HTML in text (#{Regexp.last_match(1)})" if response.body =~ /(&lt;[a-z]+)/
end
end

0 comments on commit eda5018

Please sign in to comment.