Skip to content

Commit

Permalink
More tidying for rubocop.
Browse files Browse the repository at this point in the history
Lots more rubocop tidy up.

Includes running cops not run by default.

Lots more rubocop tidy up.

Includes running cops not run by default.

Put back AmbiguousOperator fix I accidentally clobbered.

Put back UnderscorePrefixedVariableName fix I accidentally clobbered.

CollectionMethods and ExtraSpacing checks added to rubocop.
  • Loading branch information
hmallett committed Mar 4, 2015
1 parent 1c555b8 commit 40210fc
Show file tree
Hide file tree
Showing 50 changed files with 274 additions and 272 deletions.
6 changes: 5 additions & 1 deletion .rubocop.yml
Expand Up @@ -33,12 +33,16 @@ Style/ClassAndModuleChildren:
Enabled: false

Style/CollectionMethods:
Enabled: false
Enabled: true

# Place . on the previous line
Style/DotPosition:
EnforcedStyle: trailing

# Do not use unnecessary spacing.
Style/ExtraSpacing:
Enabled: true

# Allows format strings with: format, sprintf or percent.
Style/FormatString:
Enabled: false
Expand Down
26 changes: 13 additions & 13 deletions .rubocop_todo.yml
@@ -1,5 +1,5 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-02-28 01:26:22 +0000 using RuboCop version 0.29.1.
# on 2015-03-04 14:34:54 +0000 using RuboCop version 0.29.1.
# 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
Expand All @@ -9,43 +9,43 @@
Lint/Eval:
Enabled: false

# Offense count: 97
# Offense count: 86
Metrics/AbcSize:
Max: 72

# Offense count: 12
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 245
Max: 242

# Offense count: 22
# Offense count: 19
Metrics/CyclomaticComplexity:
Max: 20

# Offense count: 906
# Offense count: 910
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 1196

# Offense count: 82
# Offense count: 74
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 49
Max: 48

# Offense count: 1
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 6

# Offense count: 13
# Offense count: 10
Metrics/PerceivedComplexity:
Max: 20

# Offense count: 13
Style/AccessorMethodName:
Enabled: false

# Offense count: 11
# Offense count: 3
# Cop supports --auto-correct.
Style/Blocks:
Enabled: false
Expand All @@ -59,12 +59,12 @@ Style/ClassVars:
Style/GlobalVars:
Enabled: false

# Offense count: 30
# Offense count: 26
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false

# Offense count: 3
# Offense count: 1
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Enabled: false
Expand All @@ -75,9 +75,9 @@ Style/PredicateName:
Enabled: false

# Offense count: 6
# Configuration parameters: EnforcedStyle, SupportedStyles.
# Configuration parameters: SupportedStyles.
Style/RaiseArgs:
Enabled: false
EnforcedStyle: compact

# Offense count: 20
# Configuration parameters: MaxSlashes.
Expand Down
22 changes: 11 additions & 11 deletions Guardfile
Expand Up @@ -17,22 +17,22 @@
# * 'just' rspec: 'rspec'
guard :rspec, cmd: 'bundle exec rspec', failed_mode: :focus do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { 'spec' }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { 'spec' }

# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
watch('config/routes.rb') { 'spec/routing' }
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
watch('spec/rails_helper.rb') { 'spec' }
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
watch('config/routes.rb') { 'spec/routing' }
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
watch('spec/rails_helper.rb') { 'spec' }

# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
4 changes: 2 additions & 2 deletions app/controllers/admin/content_controller.rb
Expand Up @@ -121,8 +121,8 @@ def get_fresh_or_existing_draft_for_article
parent_id = @article.id
@article = Article.drafts.child_of(parent_id).first || Article.new
@article.allow_comments = this_blog.default_allow_comments
@article.allow_pings = this_blog.default_allow_pings
@article.parent_id = parent_id
@article.allow_pings = this_blog.default_allow_pings
@article.parent_id = parent_id
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/admin/dashboard_controller.rb
Expand Up @@ -86,11 +86,11 @@ def parse_rss(body)

REXML::XPath.each(xml, '//item/') do |elem|
item = RssItem.new
item.title = REXML::XPath.match(elem, 'title/text()').first.value rescue ''
item.link = REXML::XPath.match(elem, 'link/text()').first.value rescue ''
item.title = REXML::XPath.match(elem, 'title/text()').first.value rescue ''
item.link = REXML::XPath.match(elem, 'link/text()').first.value rescue ''
item.description = REXML::XPath.match(elem, 'description/text()').first.value rescue ''
item.author = REXML::XPath.match(elem, 'dc:publisher/text()').first.value rescue ''
item.date = Time.mktime(*ParseDate.parsedate(REXML::XPath.match(elem, 'dc:date/text()').first.value)) rescue Date.parse(REXML::XPath.match(elem, 'pubDate/text()').first.value) rescue Time.now
item.author = REXML::XPath.match(elem, 'dc:publisher/text()').first.value rescue ''
item.date = Time.mktime(*ParseDate.parsedate(REXML::XPath.match(elem, 'dc:date/text()').first.value)) rescue Date.parse(REXML::XPath.match(elem, 'pubDate/text()').first.value) rescue Time.now

item.description_link = item.description
item.description.gsub!(/<\/?a\b.*?>/, '') # remove all <a> tags
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/feedback_controller.rb
Expand Up @@ -122,10 +122,10 @@ def bulkops
end
when 'Mark Checked Items as Ham'
update_feedback(items, :mark_as_ham!)
flash[:success] = I18n.t('admin.feedback.bulkops.success_mark_as_ham', count: ids.size)
flash[:success] = I18n.t('admin.feedback.bulkops.success_mark_as_ham', count: ids.size)
when 'Mark Checked Items as Spam'
update_feedback(items, :mark_as_spam!)
flash[:success] = I18n.t('admin.feedback.bulkops.success_mark_as_spam', count: ids.size)
flash[:success] = I18n.t('admin.feedback.bulkops.success_mark_as_spam', count: ids.size)
when 'Confirm Classification of Checked Items'
update_feedback(items, :confirm_classification!)
flash[:success] = I18n.t('admin.feedback.bulkops.success_classification', count: ids.size)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/themes_controller.rb
Expand Up @@ -30,6 +30,6 @@ def switchto
protected

def zap_theme_caches
FileUtils.rm_rf(%w(stylesheets javascript images).collect { |v| page_cache_directory + "/#{v}/theme" })
FileUtils.rm_rf(%w(stylesheets javascript images).map { |v| page_cache_directory + "/#{v}/theme" })
end
end
10 changes: 5 additions & 5 deletions app/controllers/articles_controller.rb
Expand Up @@ -147,7 +147,7 @@ def markup_help
private

def verify_config
if !this_blog.configured?
if !this_blog.configured?
redirect_to controller: 'setup', action: 'index'
elsif User.count == 0
redirect_to controller: 'accounts', action: 'signup'
Expand All @@ -158,8 +158,8 @@ def verify_config

# See an article We need define @article before
def show_article
@comment = Comment.new
@page_title = this_blog.article_title_template.to_title(@article, this_blog, params)
@comment = Comment.new
@page_title = this_blog.article_title_template.to_title(@article, this_blog, params)
@description = this_blog.article_desc_template.to_title(@article, this_blog, params)
groupings = @article.tags
@keywords = groupings.map(&:name).join(', ')
Expand All @@ -168,8 +168,8 @@ def show_article
respond_to do |format|
format.html { render "articles/#{@article.post_type}" }
format.atom { render_feedback_feed('atom') }
format.rss { render_feedback_feed('rss') }
format.xml { render_feedback_feed('atom') }
format.rss { render_feedback_feed('rss') }
format.xml { render_feedback_feed('atom') }
end
rescue ActiveRecord::RecordNotFound
error!
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/comments_controller.rb
Expand Up @@ -14,7 +14,7 @@ def create
set_cookies_for @comment

partial = '/articles/comment_failed'
if recaptcha_ok_for?(@comment) && @comment.save
if recaptcha_ok_for?(@comment) && @comment.save
partial = '/articles/comment'
end
if request.xhr?
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/tags_controller.rb
Expand Up @@ -49,7 +49,7 @@ def show
render 'articles/index_atom_feed', layout: false
end

format.rss do
format.rss do
@articles = @articles[0, this_blog.limit_rss_display]
render 'articles/index_rss_feed', layout: false
end
Expand All @@ -76,7 +76,7 @@ def grouping_name

def show_page_title_for(_grouping, _page)
if grouping_name.singularize == 'Tag'
@page_title = this_blog.tag_title_template.to_title(@grouping, this_blog, params)
@page_title = this_blog.tag_title_template.to_title(@grouping, this_blog, params)
@description = this_blog.tag_title_template.to_title(@grouping, this_blog, params)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/trackbacks_controller.rb
Expand Up @@ -7,7 +7,7 @@ def create
# Part of the trackback spec... not sure what we should be doing here though.
else
begin
@trackback = this_blog.ping_article!(
@trackback = this_blog.ping_article!(
params.merge(ip: request.remote_ip, published: true))
''
rescue ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/xml_controller.rb
Expand Up @@ -7,7 +7,7 @@ class XmlController < ApplicationController
'atom10' => 'atom', 'atom03' => 'atom', 'rss20' => 'rss',
'googlesitemap' => 'googlesitemap', 'rsd' => 'rsd' }

ACCEPTED_TYPE = %w(feed comments article tag author trackbacks sitemap)
ACCEPTED_TYPE = %w(feed comments article tag author trackbacks sitemap)

def feed
@format = 'rss'
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/admin/base_helper.rb
Expand Up @@ -75,25 +75,25 @@ def link_to_edit_with_profiles(label, record, controller_name = controller.contr
end

def text_filter_options
TextFilter.all.collect do |filter|
TextFilter.all.map do |filter|
[filter.description, filter]
end
end

def text_filter_options_with_id
TextFilter.all.collect do |filter|
TextFilter.all.map do |filter|
[filter.description, filter.id]
end
end

def plugin_options(kind)
PublifyPlugins::Keeper.available_plugins(kind).collect do |plugin|
PublifyPlugins::Keeper.available_plugins(kind).map do |plugin|
[plugin.name, plugin.to_s]
end
end

def show_actions(item)
content_tag(:div, class: 'action', style: '') do
content_tag(:div, class: 'action', style: '') do
[button_to_edit(item),
button_to_delete(item),
button_to_short_url(item)].join(' ').html_safe
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/admin/feedback_helper.rb
Expand Up @@ -8,7 +8,7 @@ def comment_class(state)

def show_feedback_actions(item, context = 'listing')
return if current_user.profile.label == 'contributor'
content_tag(:div, class: 'action', style: '') do
content_tag(:div, class: 'action', style: '') do
[content_tag(:small, change_status(item, context)),
button_to_edit_comment(item),
button_to_delete_comment(item),
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -156,8 +156,8 @@ def use_canonical
end

def page_header_includes
content_array.collect(&:whiteboard).collect do |w|
w.select { |k, _v| k =~ /^page_header_/ }.collect do |_, v|
content_array.map(&:whiteboard).map do |w|
w.select { |k, _v| k =~ /^page_header_/ }.map do |_, v|
v = v.chomp
# trim the same number of spaces from the beginning of each line
# this way plugins can indent nicely without making ugly source output
Expand Down
8 changes: 4 additions & 4 deletions app/models/article.rb
Expand Up @@ -30,9 +30,9 @@ def spam
end
end

has_many :published_comments, -> { where(published: true).order('created_at ASC') }, class_name: 'Comment'
has_many :published_trackbacks, -> { where(published: true).order('created_at ASC') }, class_name: 'Trackback'
has_many :published_feedback, -> { where(published: true).order('created_at ASC') }, class_name: 'Feedback'
has_many :published_comments, -> { where(published: true).order('created_at ASC') }, class_name: 'Comment'
has_many :published_trackbacks, -> { where(published: true).order('created_at ASC') }, class_name: 'Trackback'
has_many :published_feedback, -> { where(published: true).order('created_at ASC') }, class_name: 'Feedback'

has_and_belongs_to_many :tags, join_table: 'articles_tags'

Expand Down Expand Up @@ -82,7 +82,7 @@ def has_child?
end

def post_type
post_type = read_attribute(:post_type)
post_type = self[:post_type]
post_type = 'read' if post_type.blank?
post_type
end
Expand Down

0 comments on commit 40210fc

Please sign in to comment.