From decae056f10fe9740769d3154fde08c8794347c8 Mon Sep 17 00:00:00 2001 From: rhymes Date: Mon, 18 May 2020 10:27:51 +0200 Subject: [PATCH] Routine rubocop fixes (#7885) --- .rubocop.yml | 10 ++++++++++ .rubocop_todo.yml | 8 ++++---- app/labor/bufferizer.rb | 1 + app/labor/reading_list.rb | 1 + app/labor/sticky_article_collection.rb | 1 + app/liquid_tags/glitch_tag.rb | 1 + app/liquid_tags/medium_tag.rb | 1 + app/liquid_tags/podcast_tag.rb | 1 + app/liquid_tags/spotify_tag.rb | 2 +- app/services/rss_reader.rb | 2 +- spec/liquid_tags/spotify_tag_spec.rb | 2 +- .../internal/admin_manages_organizations_spec.rb | 2 +- spec/system/user_uses_the_editor_spec.rb | 2 +- 13 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5616b29b6..4a6ddee5d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -31,6 +31,12 @@ Layout/DotPosition: # TODO: [@thepracticaldev/oss] enable leading? EnforcedStyle: trailing + +Layout/EmptyLinesAroundAttributeAccessor: + Description: "Keep blank lines around attribute accessors." + StyleGuide: '#empty-lines-around-attribute-accessor' + Enabled: true + # Layout/FirstArrayElementLineBreak: # Description: >- # Checks for a line break before the first element in a @@ -321,6 +327,10 @@ Style/SingleLineBlockParams: Description: 'Enforces the names of some block params.' Enabled: true +Style/SlicingWithRange: + Description: 'Checks array slicing is done with endless ranges when suitable.' + Enabled: true + Style/StringLiterals: Description: 'Checks if uses of quotes match the configured preference.' StyleGuide: '#consistent-string-literals' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b7c077db1..2d350c49f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,13 +6,13 @@ require: # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-05-08 12:21:06 +0200 using RuboCop version 0.82.0. +# on 2020-05-15 16:11:31 +0200 using RuboCop version 0.83.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: 264 +# Offense count: 266 # Configuration parameters: IgnoredMethods. Metrics/AbcSize: Max: 64 @@ -41,7 +41,7 @@ RSpec/ExampleLength: - 'spec/models/comment_spec.rb' - 'spec/requests/display_ad_events_spec.rb' -# Offense count: 859 +# Offense count: 872 RSpec/MultipleExpectations: Max: 10 @@ -95,7 +95,7 @@ Style/SingleLineBlockParams: Exclude: - 'app/labor/markdown_fixer.rb' -# Offense count: 5028 +# Offense count: 5168 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https diff --git a/app/labor/bufferizer.rb b/app/labor/bufferizer.rb index d748d9f28..3169e44f0 100644 --- a/app/labor/bufferizer.rb +++ b/app/labor/bufferizer.rb @@ -1,5 +1,6 @@ class Bufferizer attr_accessor :post_type, :post, :text + include ApplicationHelper def initialize(post_type, post, text, admin_id = nil) diff --git a/app/labor/reading_list.rb b/app/labor/reading_list.rb index 8c1011e6b..d2b486462 100644 --- a/app/labor/reading_list.rb +++ b/app/labor/reading_list.rb @@ -1,5 +1,6 @@ class ReadingList attr_accessor :user + def initialize(user) @user = user end diff --git a/app/labor/sticky_article_collection.rb b/app/labor/sticky_article_collection.rb index dae2fe4e1..073d0ef0a 100644 --- a/app/labor/sticky_article_collection.rb +++ b/app/labor/sticky_article_collection.rb @@ -1,5 +1,6 @@ class StickyArticleCollection attr_accessor :article, :author, :reaction_count_num, :comment_count_num + def initialize(article, author) @article = article @author = author diff --git a/app/liquid_tags/glitch_tag.rb b/app/liquid_tags/glitch_tag.rb index 2afc5d817..96507beda 100644 --- a/app/liquid_tags/glitch_tag.rb +++ b/app/liquid_tags/glitch_tag.rb @@ -2,6 +2,7 @@ require "uri" class GlitchTag < LiquidTagBase attr_accessor :uri + PARTIAL = "liquids/glitch".freeze ID_REGEXP = /\A[a-zA-Z0-9\-]{1,110}\z/.freeze OPTION_REGEXP = /(app|code|no-files|preview-first|no-attribution|file\=\w(\.\w)?)/.freeze diff --git a/app/liquid_tags/medium_tag.rb b/app/liquid_tags/medium_tag.rb index 1414965a1..2aa0a21bd 100644 --- a/app/liquid_tags/medium_tag.rb +++ b/app/liquid_tags/medium_tag.rb @@ -3,6 +3,7 @@ class MediumTag < LiquidTagBase include ActionView::Helpers::TagHelper include InlineSvg::ActionView::Helpers attr_reader :response + PARTIAL = "liquids/medium".freeze def initialize(_tag_name, url, _tokens) diff --git a/app/liquid_tags/podcast_tag.rb b/app/liquid_tags/podcast_tag.rb index 8c6087177..2a5eba41c 100644 --- a/app/liquid_tags/podcast_tag.rb +++ b/app/liquid_tags/podcast_tag.rb @@ -3,6 +3,7 @@ class PodcastTag < LiquidTagBase include CloudinaryHelper attr_reader :episode, :podcast + PARTIAL = "podcast_episodes/liquid".freeze SCRIPT = <<~JAVASCRIPT.freeze diff --git a/app/liquid_tags/spotify_tag.rb b/app/liquid_tags/spotify_tag.rb index eb1d711a6..17f947573 100644 --- a/app/liquid_tags/spotify_tag.rb +++ b/app/liquid_tags/spotify_tag.rb @@ -37,7 +37,7 @@ class SpotifyTag < LiquidTagBase end def generate_embed_link(parsed_uri) - parsed_uri.string.split(":")[1..-1].unshift("https://open.spotify.com/embed").join("/") + parsed_uri.string.split(":")[1..].unshift("https://open.spotify.com/embed").join("/") end def raise_error diff --git a/app/services/rss_reader.rb b/app/services/rss_reader.rb index 8c35aabb5..897fe9452 100644 --- a/app/services/rss_reader.rb +++ b/app/services/rss_reader.rb @@ -85,7 +85,7 @@ class RssReader def get_host_without_www(url) url = "http://#{url}" if URI.parse(url).scheme.nil? host = URI.parse(url).host.downcase - host.start_with?("www.") ? host[4..-1] : host + host.start_with?("www.") ? host[4..] : host end def medium_reply?(item) diff --git a/spec/liquid_tags/spotify_tag_spec.rb b/spec/liquid_tags/spotify_tag_spec.rb index 35fe4a21a..db834b513 100644 --- a/spec/liquid_tags/spotify_tag_spec.rb +++ b/spec/liquid_tags/spotify_tag_spec.rb @@ -13,7 +13,7 @@ RSpec.describe SpotifyTag, type: :liquid_tag do end def generate_iframe(uri, height) - parsed_uri = uri.split(":")[1..-1].unshift("https://open.spotify.com/embed").join("/") + parsed_uri = uri.split(":")[1..].unshift("https://open.spotify.com/embed").join("/") <<~HTML