Permalink
Browse files

Merge pull request #833 from publify/update-rubocop

Update rubocop
  • Loading branch information...
mvz committed Nov 11, 2017
2 parents 000d057 + 2b91892 commit 02ddbed52199ef61f0fe78fd3f17577c1d29b094
Showing with 314 additions and 271 deletions.
  1. +62 −5 .rubocop.yml
  2. +75 −0 .rubocop_todo.yml
  3. +2 −2 Gemfile
  4. +3 −0 app/models/application_record.rb
  5. +0 −2 db/migrate/113_initial_schema.publify_core_engine.rb
  6. +1 −1 db/migrate/114_fixes_buggy_articles_and_notes.publify_core_engine.rb
  7. +3 −4 db/migrate/115_drops_categories_for_tags.publify_core_engine.rb
  8. +5 −1 db/migrate/20150808052637_add_blog_ids.publify_core_engine.rb
  9. +1 −1 db/scripts/fix_permalinks.rb
  10. +1 −3 publify_amazon_sidebar/Rakefile
  11. +2 −2 publify_amazon_sidebar/publify_amazon_sidebar.gemspec
  12. +1 −2 publify_amazon_sidebar/spec/models/amazon_sidebar_spec.rb
  13. +1 −3 publify_core/Rakefile
  14. +7 −18 publify_core/app/controllers/admin/content_controller.rb
  15. +1 −2 publify_core/app/controllers/admin/dashboard_controller.rb
  16. +1 −1 publify_core/app/controllers/admin/notes_controller.rb
  17. +5 −18 publify_core/app/controllers/admin/pages_controller.rb
  18. +1 −1 publify_core/app/controllers/admin/profiles_controller.rb
  19. +0 −2 publify_core/app/controllers/admin/sidebar_controller.rb
  20. +4 −4 publify_core/app/controllers/comments_controller.rb
  21. +1 −2 publify_core/app/controllers/setup_controller.rb
  22. +1 −2 publify_core/app/helpers/admin/base_helper.rb
  23. +0 −2 publify_core/app/helpers/base_helper.rb
  24. +1 −1 publify_core/app/helpers/xml_helper.rb
  25. +2 −6 publify_core/app/models/article.rb
  26. +6 −6 publify_core/app/models/blog.rb
  27. +3 −7 publify_core/app/models/content.rb
  28. +1 −1 publify_core/app/models/feedback.rb
  29. +0 −2 publify_core/app/models/meta_sidebar.rb
  30. +2 −3 publify_core/app/models/note.rb
  31. +1 −2 publify_core/app/models/page.rb
  32. +1 −1 publify_core/app/models/ping.rb
  33. +1 −3 publify_core/app/models/post_type.rb
  34. +3 −2 publify_core/app/models/redirect.rb
  35. +1 −1 publify_core/app/models/redirection.rb
  36. +1 −1 publify_core/app/models/resource.rb
  37. +1 −1 publify_core/app/models/sidebar.rb
  38. +0 −2 publify_core/app/models/static_sidebar.rb
  39. +1 −1 publify_core/app/models/tag.rb
  40. +1 −1 publify_core/app/models/text_filter.rb
  41. +2 −2 publify_core/app/models/trigger.rb
  42. +1 −1 publify_core/app/models/user.rb
  43. +5 −5 publify_core/app/services/title_builder.rb
  44. +2 −2 publify_core/app/views/admin/content/autosave.js.erb
  45. +1 −1 publify_core/app/views/admin/seo/_general.html.erb
  46. +2 −2 publify_core/app/views/admin/seo/_permalinks.html.erb
  47. +9 −13 publify_core/app/views/shared/_atom_item_article.atom.builder
  48. +2 −3 publify_core/app/views/shared/_rss_item_article.rss.builder
  49. +1 −1 publify_core/config/initializers/mime_types.rb
  50. +1 −1 publify_core/config/routes.rb
  51. +0 −2 publify_core/db/migrate/113_initial_schema.rb
  52. +1 −1 publify_core/db/migrate/114_fixes_buggy_articles_and_notes.rb
  53. +3 −4 publify_core/db/migrate/115_drops_categories_for_tags.rb
  54. +5 −1 publify_core/db/migrate/20150808052637_add_blog_ids.rb
  55. +2 −2 publify_core/db/seeds.rb
  56. +1 −11 publify_core/lib/format.rb
  57. +1 −1 publify_core/lib/publify_core/version.rb
  58. +2 −1 publify_core/lib/spam_protection.rb
  59. +3 −4 publify_core/lib/text_filter_plugin.rb
  60. +0 −2 publify_core/lib/transforms.rb
  61. +6 −6 publify_core/publify_core.gemspec
  62. +1 −1 publify_core/spec/controllers/admin/content_controller_spec.rb
  63. +1 −3 publify_core/spec/controllers/admin/pages_controller_spec.rb
  64. +1 −3 publify_core/spec/controllers/articles_controller_spec.rb
  65. +1 −1 publify_core/spec/controllers/authors_controller_spec.rb
  66. +14 −1 publify_core/spec/controllers/notes_controller_spec.rb
  67. +1 −3 publify_core/spec/factories.rb
  68. +0 −2 publify_core/spec/helpers/base_helper_spec.rb
  69. +0 −2 publify_core/spec/lib/transforms_spec.rb
  70. +5 −9 publify_core/spec/models/article_spec.rb
  71. +2 −6 publify_core/spec/models/blog_spec.rb
  72. +5 −5 publify_core/spec/models/comment_spec.rb
  73. +2 −2 publify_core/spec/models/configuration_spec.rb
  74. +3 −5 publify_core/spec/models/content_spec.rb
  75. +1 −1 publify_core/spec/models/feedback_spec.rb
  76. +0 −2 publify_core/spec/models/note_spec.rb
  77. +0 −2 publify_core/spec/models/page_spec.rb
  78. +0 −2 publify_core/spec/models/post_type_spec.rb
  79. +1 −1 publify_core/spec/rails_helper.rb
  80. +1 −2 publify_core/spec/views/articles/feedback_atom_feed_spec.rb
  81. +2 −4 publify_core/spec/views/articles/index_atom_feed_spec.rb
  82. +2 −6 publify_core/spec/views/articles/index_rss_feed_spec.rb
  83. +4 −4 publify_core/spec/views/comments/html_sanitization_spec.rb
  84. +2 −2 publify_core/spec/views/shared/_page_header_spec.rb
  85. +1 −3 publify_textfilter_code/Rakefile
  86. +3 −3 publify_textfilter_code/publify_textfilter_code.gemspec
  87. +6 −6 publify_textfilter_code/spec/lib/publify_app/textfilter_code_spec.rb
  88. +1 −5 spec/factories.rb
View
@@ -1,5 +1,3 @@
# Default style guide 'https://github.com/bbatsov/ruby-style-guide'.
AllCops:
Exclude:
- 'bin/**/*'
@@ -11,6 +9,8 @@ AllCops:
- 'publify_amazon_sidebar/spec/dummy/**/*'
- 'publify_textfilter_code/bin/*'
- 'publify_textfilter_code/spec/dummy/**/*'
- 'db/converters/*.rb'
- 'db/scripts/fix_permalinks.rb'
- 'db/schema.rb'
TargetRubyVersion: '2.2'
@@ -50,14 +50,56 @@ Lint/AmbiguousBlockAssociation:
Lint/AssignmentInCondition:
AllowSafeAssignment: true
# Spec describe blocks can be any length
# TODO: Lower Max and fix offenses
Metrics/AbcSize:
Max: 155
# Suppress BlockLength for some files:
# - Spec describe blocks can be any length
# - Routes blocks can be any length
# - Gem specification blocks can be any length
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
- '**/*.gemspec'
- 'publify_core/config/routes.rb'
- 'publify_core/spec/**/*'
- 'publify_amazon_sidebar/spec/**/*'
- 'publify_textfilter_code/spec/**/*'
# TODO: Lower Max and fix offenses
Metrics/ClassLength:
Max: 225
# TODO: Lower Max and fix offenses
Metrics/CyclomaticComplexity:
Max: 17
# TODO: Lower Max and fix offenses
Metrics/LineLength:
Max: 274
# Initial schema has a very large change method
# TODO: Lower Max and fix offenses
Metrics/MethodLength:
Exclude:
- 'publify_core/db/migrate/113_initial_schema.rb'
- 'db/migrate/113_initial_schema.publify_core_engine.rb'
Max: 45
# TODO: Lower Max and fix offenses
Metrics/ModuleLength:
Max: 211
# Offense count: 1
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 6
# Offense count: 8
Metrics/PerceivedComplexity:
Max: 17
# Do not require long paths to be split by comma's.
Rails/FilePath:
Enabled: false
@@ -66,9 +108,22 @@ Rails/FilePath:
Style/Documentation:
Enabled: false
# Provides more information, while still being displayable in modern wide-screen.
# TODO: Lower Max and fix offenses
# Target is around 100
Metrics/LineLength:
Max: 100
Max: 274
# Migrations should not use ApplicationRecord
Rails/ApplicationRecord:
Exclude:
- 'db/migrate/*'
- 'publify_core/db/migrate/*'
# Migrations should not do validations in general?
Rails/SkipsModelValidations:
Exclude:
- 'db/migrate/*'
- 'publify_core/db/migrate/*'
# Allow the use of 'and' 'or' in control structures.
Style/AndOr:
@@ -121,3 +176,5 @@ Style/SymbolArray:
# Allow small arrays of words with quotes
Style/WordArray:
MinSize: 4
inherit_from: .rubocop_todo.yml
View
@@ -0,0 +1,75 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-10-20 14:42:54 +0200 using RuboCop version 0.51.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:
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'
# Offense count: 3
Lint/UriEscapeUnescape:
Exclude:
- 'publify_core/app/models/article.rb'
- 'publify_core/lib/publify_textfilter_twitterfilter.rb'
# Offense count: 5
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
- 'spec/**/*'
- 'publify_core/app/helpers/authors_helper.rb'
- 'publify_core/app/models/article.rb'
- 'publify_core/app/models/blog.rb'
- 'publify_core/app/models/user.rb'
- 'publify_core/lib/spam_protection.rb'
# Offense count: 3
Security/Eval:
Exclude:
- 'Gemfile'
- 'publify_core/lib/publify_plugins.rb'
# Offense count: 5
Style/ClassVars:
Exclude:
- 'publify_core/app/controllers/admin/base_controller.rb'
- 'publify_core/lib/email_notify.rb'
- 'publify_core/lib/publify_plugins.rb'
- 'publify_core/lib/text_filter_plugin.rb'
# Offense count: 2
Style/CommentedKeyword:
Exclude:
- 'publify_core/lib/publify_plugins.rb'
# Offense count: 12
Style/DateTime:
Exclude:
- 'publify_core/spec/controllers/authors_controller_spec.rb'
- 'publify_core/spec/controllers/notes_controller_spec.rb'
- 'publify_core/spec/factories.rb'
- 'publify_core/spec/models/archives_sidebar_spec.rb'
- 'publify_core/spec/models/article_spec.rb'
- 'publify_core/spec/models/comment_spec.rb'
- 'publify_core/spec/models/content_spec.rb'
- 'publify_core/spec/models/feedback_spec.rb'
- 'spec/factories.rb'
# Offense count: 24
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
View
@@ -7,9 +7,9 @@ if ENV['HEROKU']
gem 'rails_12factor'
gem 'thin' # Change this to another web server if you want (ie. unicorn, passenger, puma...)
else
gem 'sqlite3'
gem 'pg'
gem 'mysql2', '~> 0.4.4'
gem 'pg'
gem 'sqlite3'
end
gem 'rails', '~> 5.1.2'
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
@@ -1,5 +1,3 @@
# encoding: UTF-8
class InitialSchema < ActiveRecord::Migration[4.2]
def change
create_table 'articles_tags', id: false, force: true do |t|
@@ -16,7 +16,7 @@ def set_permalink
end
def create_guid
return true unless guid.blank?
return true if guid.present?
self.guid = UUIDTools::UUID.random_create.to_s
end
@@ -17,8 +17,8 @@ def up
tg.display_name = cat.name
end
redirect = Redirect.create(from_path: "category/#{cat.permalink}",
to_path: File.join(Blog.first.base_url, 'tag', tag.name))
Redirect.create(from_path: "category/#{cat.permalink}",
to_path: File.join(Blog.first.base_url, 'tag', tag.name))
cat.articles.each do |article|
article.tags << tag
article.save
@@ -29,6 +29,5 @@ def up
drop_table :categories
end
def down
end
def down; end
end
@@ -23,7 +23,11 @@ def down
remove_index(:contents, name: index.name) if index.name =~ /blog_id/
end
else
remove_index :contents, :blog_id rescue nil
begin
remove_index :contents, :blog_id
rescue
nil
end
end
remove_column :contents, :blog_id
remove_column :sidebars, :blog_id
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/environment'
Article.find(:all).each do |a|
(puts "Processing #{a.title} (#{a.stripped_title})" ; a.save) if a.permalink.blank?
(puts "Processing #{a.title} (#{a.stripped_title})"; a.save) if a.permalink.blank?
end
@@ -39,9 +39,7 @@ namespace :manifest do
desc 'Check manifest'
task :check do
unless gemmable_files == manifest_files
abort 'Manifest check failed'
end
abort 'Manifest check failed' unless gemmable_files == manifest_files
end
end
task default: 'manifest:check'
@@ -16,10 +16,10 @@ Gem::Specification.new do |s|
s.files = File.open('Manifest.txt').readlines.map(&:chomp)
s.add_dependency 'rails', '~> 5.1.2'
s.add_dependency 'publify_core', '~> 9.0.0'
s.add_dependency 'rails', '~> 5.1.2'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'rspec-rails', '~> 3.6.0'
s.add_development_dependency 'simplecov', '~> 0.14.0'
s.add_development_dependency 'sqlite3'
end
@@ -18,8 +18,7 @@
it "description should be 'Adds sidebar links...'" do
expect(sidebar.description).to eq(
'Adds sidebar links to any Amazon.com books linked in the body of the page'
)
'Adds sidebar links to any Amazon.com books linked in the body of the page')
end
it 'sidebar should be valid' do
View
@@ -41,9 +41,7 @@ namespace :manifest do
desc 'Check manifest'
task :check do
unless gemmable_files == manifest_files
fail 'Manifest check failed'
end
raise 'Manifest check failed' unless gemmable_files == manifest_files
end
end
task default: 'manifest:check'
@@ -3,8 +3,6 @@
module Admin; end
class Admin::ContentController < Admin::BaseController
layout :get_layout
def index
@search = params[:search] ? params[:search] : {}
@articles = this_blog.articles.search_with(@search).page(params[:page]).per(this_blog.admin_display_elements)
@@ -21,6 +19,7 @@ def index
def new
@article = Article::Factory.new(this_blog, current_user).default
load_resources
render layout: 'editor'
end
def edit
@@ -29,6 +28,7 @@ def edit
@article.text_filter ||= current_user.default_text_filter
@article.keywords = Tag.collection_to_string @article.tags
load_resources
render layout: 'editor'
end
def create
@@ -49,7 +49,7 @@ def create
else
@article.keywords = Tag.collection_to_string @article.tags
load_resources
render 'new'
render 'new', layout: 'editor'
end
end
@@ -59,7 +59,7 @@ def update
@article = Article.find(id)
if params[:article][:draft]
get_fresh_or_existing_draft_for_article
fetch_fresh_or_existing_draft_for_article
else
@article = Article.find(@article.parent_id) unless @article.parent_id.nil?
end
@@ -100,7 +100,7 @@ def autosave
article_factory = Article::Factory.new(this_blog, current_user)
@article = article_factory.get_or_build_from(id)
get_fresh_or_existing_draft_for_article
fetch_fresh_or_existing_draft_for_article
@article.attributes = params[:article].permit!
@@ -116,7 +116,7 @@ def autosave
if @article.save
flash[:success] = I18n.t('admin.content.autosave.success')
@must_update_calendar = (params[:article][:published_at] and params[:article][:published_at].to_time.to_i < Time.now.to_time.to_i and @article.parent_id.nil?)
@must_update_calendar = (params[:article][:published_at] and params[:article][:published_at].to_time.to_i < Time.zone.now.to_time.to_i and @article.parent_id.nil?)
respond_to do |format|
format.js
end
@@ -125,7 +125,7 @@ def autosave
protected
def get_fresh_or_existing_draft_for_article
def fetch_fresh_or_existing_draft_for_article
return unless @article.published? && @article.id
parent_id = @article.id
@@ -177,15 +177,4 @@ def update_params
:title,
:keywords)
end
def get_layout
case action_name
when 'new', 'edit', 'create'
'editor'
when 'show', 'autosave'
nil
else
'administration'
end
end
end
@@ -6,8 +6,7 @@ class Admin::DashboardController < Admin::BaseController
require 'rexml/document'
def index
t = Time.new
today = t.strftime('%Y-%m-%d 00:00')
today = Time.zone.now.strftime('%Y-%m-%d 00:00')
# Since last visit
last_sign_in = current_user.last_sign_in_at
@@ -23,7 +23,7 @@ def create
note.state = 'published'
note.attributes = params[:note].permit!
note.text_filter ||= current_user.default_text_filter
note.published_at ||= Time.now
note.published_at ||= Time.zone.now
if note.save
if params[:push_to_twitter] && note.twitter_id.blank?
unless note.send_to_twitter
Oops, something went wrong.

0 comments on commit 02ddbed

Please sign in to comment.