Skip to content

Commit

Permalink
Upgrade rubocop and rubocop-performance (forem#2802) [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
rhymes authored and maestromac committed May 13, 2019
1 parent 419ee34 commit 66ddcbc
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 41 deletions.
42 changes: 16 additions & 26 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-04-10 05:04:16 +0200 using RuboCop version 0.67.2.
# on 2019-05-14 00:36:38 +0200 using RuboCop version 0.69.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
Expand All @@ -10,9 +10,9 @@
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 69
Max: 63

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

Expand All @@ -21,52 +21,42 @@ RSpec/AnyInstance:
Exclude:
- 'spec/requests/stripe_cancellations_spec.rb'

# Offense count: 145
# Offense count: 185
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 6

# Offense count: 16
# Offense count: 15
Rails/OutputSafety:
Exclude:
- 'app/controllers/stripe_subscriptions_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/comments_helper.rb'
- 'app/labor/markdown_parser.rb'
- 'app/liquid_tags/dev_comment_tag.rb'
- 'app/liquid_tags/github_tag/github_issue_tag.rb'
- 'app/liquid_tags/liquid_tag_base.rb'
- 'app/liquid_tags/tweet_tag.rb'
- 'app/models/comment.rb'
- 'app/models/display_ad.rb'
- 'app/models/message.rb'
- 'app/views/api/v0/articles/show.json.jbuilder'
- 'app/views/articles/feed.rss.builder'

# Offense count: 15
# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Enabled: false

# Offense count: 1
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'app/controllers/api/v0/api_controller.rb'
- 'app/controllers/internal/application_controller.rb'
- 'app/controllers/internal/articles_controller.rb'
- 'app/controllers/internal/broadcasts_controller.rb'
- 'app/controllers/internal/buffer_updates_controller.rb'
- 'app/controllers/internal/comments_controller.rb'
- 'app/controllers/internal/dogfood_controller.rb'
- 'app/controllers/internal/feedback_messages_controller.rb'
- 'app/controllers/internal/members_controller.rb'
- 'app/controllers/internal/reactions_controller.rb'
- 'app/controllers/internal/tags_controller.rb'
- 'app/controllers/internal/users_controller.rb'
- 'app/controllers/internal/welcome_controller.rb'
- 'app/controllers/notifications/counts_controller.rb'
- 'app/controllers/notifications/reads_controller.rb'
- 'app/models/article.rb'

# Offense count: 1754
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# Offense count: 2101
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 279
Max: 278
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ group :development do
gem "pry", "~> 0.12" # An IRB alternative and runtime developer console
gem "pry-rails", "~> 0.3" # Use Pry as your rails console
gem "web-console", "~> 3.7" # Rails Console on the Browser
gem "yard", "~> 0.9.19" # YARD is a documentation generation tool for the Ruby programming language
gem "yard-activerecord", "~> 0.0.16" # YARD extension that handles and interprets methods used when developing applications with ActiveRecord
gem "yard-activesupport-concern", "~> 0.0.1" # YARD extension that brings support for modules making use of ActiveSupport::Concern
gem "yard", "~> 0.9.19" # YARD is a documentation generation tool for the Ruby programming language
end

group :development, :test do
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,8 @@ GEM
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.1.0)
rubocop (>= 0.67.0)
rubocop-performance (1.3.0)
rubocop (>= 0.68.0)
rubocop-rspec (1.33.0)
rubocop (>= 0.60.0)
ruby-prof (0.17.0)
Expand Down
17 changes: 9 additions & 8 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ def preview
if @article
format.json { render json: @article.errors, status: :unprocessable_entity }
else
format.json { render json: {
processed_html: processed_html,
title: parsed["title"],
tags: (Article.new.tag_list.add(parsed["tags"], parser: ActsAsTaggableOn::TagParser) if parsed["tags"]),
cover_image: (ApplicationController.helpers.cloud_cover_url(parsed["cover_image"]) if parsed["cover_image"])
},
status: 200
}
format.json do
render json: {
processed_html: processed_html,
title: parsed["title"],
tags: (Article.new.tag_list.add(parsed["tags"], parser: ActsAsTaggableOn::TagParser) if parsed["tags"]),
cover_image: (ApplicationController.helpers.cloud_cover_url(parsed["cover_image"]) if parsed["cover_image"])
},
status: 200
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/reading_list_items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class ReadingListItemsController < ApplicationController

def index
@reading_list_items_index = true
set_view
Expand All @@ -9,6 +8,7 @@ def index
def update
@reaction = Reaction.find(params[:id])
raise if @reaction.user_id != current_user.id # Lazy but I'm tired. HACK

@reaction.status = params[:current_status] == "archived" ? "valid" : "archived"
@reaction.save
head :ok
Expand Down
1 change: 1 addition & 0 deletions app/labor/markdown_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def prefix_all_images(html, width = 880)
next unless src
# allow image to render as-is
next if allowed_image_host?(src)

img["loading"] = "lazy"
img["src"] = if giphy_img?(src)
src.gsub("https://media.", "https://i.")
Expand Down
1 change: 1 addition & 0 deletions app/models/reaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def remove_from_index

def reactable_user
return unless category == "readinglist"

{
username: reactable.user_username,
name: reactable.user_name,
Expand Down
1 change: 0 additions & 1 deletion app/services/article_with_video_creation_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def initialize(article_params, current_user)

def create!
Article.create! do |article|

article = initial_article_with_params(article)
article.processed_html = ""
article.user_id = @current_user.id
Expand Down
2 changes: 1 addition & 1 deletion docs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ source "https://rubygems.org"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem "activerecord", "~> 5.2.3" # Databases on Rails
gem "yard", "~> 0.9.19" # YARD is a documentation generation tool for the Ruby programming language
gem "yard-activerecord", "~> 0.0.16" # YARD extension that handles and interprets methods used when developing applications with ActiveRecord
gem "yard-activesupport-concern", "~> 0.0.1" # YARD extension that brings support for modules making use of ActiveSupport::Concern
gem "yard", "~> 0.9.19" # YARD is a documentation generation tool for the Ruby programming language
2 changes: 1 addition & 1 deletion spec/requests/reading_list_items_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
expect(reaction.reload.status).to eq("archived")
end
it "unarchives an item if current_status is passed as archived" do
put "/reading_list_items/#{reaction.id}", params: {current_status: "archived"}
put "/reading_list_items/#{reaction.id}", params: { current_status: "archived" }
expect(reaction.reload.status).to eq("valid")
end
end
Expand Down

0 comments on commit 66ddcbc

Please sign in to comment.