Permalink
Browse files

More tidying for rubocop.

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...
1 parent 1c555b8 commit 40210fce9ff8dce7a62b912c7a961541a0afda18 @hmallett hmallett committed Mar 1, 2015
Showing with 274 additions and 272 deletions.
  1. +5 −1 .rubocop.yml
  2. +13 −13 .rubocop_todo.yml
  3. +11 −11 Guardfile
  4. +2 −2 app/controllers/admin/content_controller.rb
  5. +4 −4 app/controllers/admin/dashboard_controller.rb
  6. +2 −2 app/controllers/admin/feedback_controller.rb
  7. +1 −1 app/controllers/admin/themes_controller.rb
  8. +5 −5 app/controllers/articles_controller.rb
  9. +1 −1 app/controllers/comments_controller.rb
  10. +2 −2 app/controllers/tags_controller.rb
  11. +1 −1 app/controllers/trackbacks_controller.rb
  12. +1 −1 app/controllers/xml_controller.rb
  13. +4 −4 app/helpers/admin/base_helper.rb
  14. +1 −1 app/helpers/admin/feedback_helper.rb
  15. +2 −2 app/helpers/application_helper.rb
  16. +4 −4 app/models/article.rb
  17. +80 −80 app/models/blog.rb
  18. +5 −5 app/models/content.rb
  19. +1 −1 app/models/feedback.rb
  20. +6 −6 app/models/feedback/states.rb
  21. +2 −2 app/models/ping.rb
  22. +4 −4 app/models/profile.rb
  23. +1 −1 app/models/tag.rb
  24. +2 −2 app/models/text_filter.rb
  25. +21 −23 app/models/user.rb
  26. +2 −2 lib/amazon_sidebar/lib/amazon_sidebar.rb
  27. +1 −1 lib/archives_sidebar/lib/archives_sidebar.rb
  28. +1 −1 lib/authors_sidebar/lib/authors_sidebar.rb
  29. +1 −1 lib/notes_sidebar/lib/notes_sidebar.rb
  30. +1 −1 lib/popular_sidebar/lib/popular_sidebar.rb
  31. +1 −1 lib/publify_avatar_gravatar/Rakefile
  32. +2 −2 lib/publify_login_system/access_control.rb
  33. +2 −2 lib/publify_login_system/login_system.rb
  34. +2 −2 lib/publify_textfilter_code.rb
  35. +12 −12 lib/publify_textfilter_flickr.rb
  36. +13 −13 lib/publify_textfilter_lightbox.rb
  37. +7 −7 lib/publify_time.rb
  38. +4 −4 lib/sidebar.rb
  39. +2 −2 lib/stateful.rb
  40. +1 −1 lib/static_sidebar/lib/static_sidebar.rb
  41. +2 −2 lib/tag_sidebar/lib/tag_sidebar.rb
  42. +2 −2 lib/text_filter_plugin.rb
  43. +2 −2 lib/xml_sidebar/lib/xml_sidebar.rb
  44. +7 −7 spec/controllers/accounts_controller_spec.rb
  45. +8 −8 spec/factories.rb
  46. +13 −13 spec/lib/publify_time_spec.rb
  47. +4 −4 spec/models/article_spec.rb
  48. +1 −1 spec/models/comment_spec.rb
  49. +1 −1 spec/models/content_spec.rb
  50. +1 −1 spec/rails_helper.rb
View
@@ -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
View
@@ -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
@@ -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
@@ -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
@@ -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.
View
@@ -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
@@ -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
@@ -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
@@ -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)
@@ -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
@@ -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'
@@ -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(', ')
@@ -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!
@@ -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?
@@ -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
@@ -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
@@ -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
@@ -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'
@@ -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
@@ -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),
@@ -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
@@ -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'
@@ -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
Oops, something went wrong.

0 comments on commit 40210fc

Please sign in to comment.