Routine Rubocop fixes (#9302)
* rubocop -A * rubocop --auto-gen-config * Fix sorting in Bundler/OrderedGems to consider punctuation
This commit is contained in:
parent
2fadc24d28
commit
3ab9b91575
13 changed files with 84 additions and 31 deletions
66
.rubocop.yml
66
.rubocop.yml
|
|
@ -19,6 +19,14 @@ AllCops:
|
|||
ExtraDetails: true
|
||||
TargetRubyVersion: 2.7
|
||||
|
||||
#################### Bundler ###########################
|
||||
|
||||
Bundler/OrderedGems:
|
||||
Description: >-
|
||||
Gems within groups in the Gemfile should be alphabetically sorted.
|
||||
Enabled: true
|
||||
ConsiderPunctuation: true
|
||||
|
||||
#################### Layout ###########################
|
||||
|
||||
# Layout/ClassStructure:
|
||||
|
|
@ -230,10 +238,20 @@ Style/AsciiComments:
|
|||
StyleGuide: '#english-comments'
|
||||
Enabled: false
|
||||
|
||||
Style/AccessorGrouping:
|
||||
Description: 'Checks for grouping of accessors in `class` and `module` bodies.'
|
||||
Enabled: true
|
||||
|
||||
# Style/AutoResourceCleanup:
|
||||
# Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
|
||||
# Enabled: false
|
||||
|
||||
Style/BisectedAttrAccessor:
|
||||
Description: >-
|
||||
Checks for places where `attr_reader` and `attr_writer`
|
||||
for the same method can be combined into single `attr_accessor`.
|
||||
Enabled: true
|
||||
|
||||
Style/CollectionMethods:
|
||||
Description: 'Preferred collection methods.'
|
||||
StyleGuide: '#map-find-select-reduce-include-size'
|
||||
|
|
@ -342,6 +360,10 @@ Style/Next:
|
|||
StyleGuide: '#no-nested-conditionals'
|
||||
Enabled: false
|
||||
|
||||
Style/RedundantAssignment:
|
||||
Description: 'Checks for redundant assignment before returning.'
|
||||
Enabled: true
|
||||
|
||||
Style/RedundantFetchBlock:
|
||||
Description: >-
|
||||
Use `fetch(key, value)` instead of `fetch(key) { value }`
|
||||
|
|
@ -404,6 +426,15 @@ Style/TrailingCommaInArrayLiteral:
|
|||
|
||||
# Performance cops from rubocop-performance
|
||||
# https://github.com/rubocop-hq/rubocop-performance/blob/master/config/default.yml
|
||||
Performance/AncestorsInclude:
|
||||
Description: 'Use `A <= B` instead of `A.ancestors.include?(B)`.'
|
||||
Reference: 'https://github.com/JuanitoFatas/fast-ruby#ancestorsinclude-vs--code'
|
||||
Enabled: true
|
||||
|
||||
Performance/BigDecimalWithNumericArgument:
|
||||
Description: 'Convert numeric argument to string before passing to BigDecimal.'
|
||||
Enabled: true
|
||||
|
||||
Performance/CaseWhenSplat:
|
||||
Description: >-
|
||||
Reordering `when` conditions with a splat to the end
|
||||
|
|
@ -417,16 +448,47 @@ Performance/ChainArrayAllocation:
|
|||
Reference: 'https://twitter.com/schneems/status/1034123879978029057'
|
||||
Enabled: false
|
||||
|
||||
Performance/IoReadlines:
|
||||
Description: 'Use `IO.each_line` (`IO#each_line`) instead of `IO.readlines` (`IO#readlines`).'
|
||||
Reference: 'https://docs.gitlab.com/ee/development/performance.html#reading-from-files-and-other-data-sources'
|
||||
Enabled: true
|
||||
VersionAdded: '1.7'
|
||||
|
||||
Performance/OpenStruct:
|
||||
Description: 'Use `Struct` instead of `OpenStruct`.'
|
||||
Enabled: true
|
||||
|
||||
Rails/FilePath:
|
||||
EnforcedStyle: slashes
|
||||
Performance/RedundantSortBlock:
|
||||
Description: 'Use `sort` instead of `sort { |a, b| a <=> b }`.'
|
||||
Enabled: true
|
||||
|
||||
Performance/RedundantStringChars:
|
||||
Description: 'Checks for redundant `String#chars`.'
|
||||
Enabled: true
|
||||
|
||||
Performance/ReverseFirst:
|
||||
Description: 'Use `last(n).reverse` instead of `reverse.first(n)`.'
|
||||
Enabled: true
|
||||
|
||||
Performance/SortReverse:
|
||||
Description: 'Use `sort.reverse` instead of `sort { |a, b| b <=> a }`.'
|
||||
Enabled: true
|
||||
|
||||
Performance/Squeeze:
|
||||
Description: "Use `squeeze('a')` instead of `gsub(/a+/, 'a')`."
|
||||
Reference: 'https://github.com/JuanitoFatas/fast-ruby#remove-extra-spaces-or-other-contiguous-characters-code'
|
||||
Enabled: true
|
||||
|
||||
Performance/StringInclude:
|
||||
Description: 'Use `String#include?` instead of a regex match with literal-only pattern.'
|
||||
Enabled: true
|
||||
|
||||
# Rails cops from rubocop-rails
|
||||
# https://github.com/rubocop-hq/rubocop-rails/blob/master/config/default.yml
|
||||
# TODO: [@thepracticaldev/oss] enable these Rails cops
|
||||
Rails/FilePath:
|
||||
EnforcedStyle: slashes
|
||||
|
||||
Rails/HasManyOrHasOneDependent:
|
||||
Description: 'Define the dependent option to the has_many and has_one associations.'
|
||||
StyleGuide: 'https://rails.rubystyle.guide#has_many-has_one-dependent-option'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ require:
|
|||
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2020-07-08 07:58:23 UTC using RuboCop version 0.86.0.
|
||||
# on 2020-07-14 10:49:48 UTC using RuboCop version 0.87.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
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class OrganizationsController < ApplicationController
|
|||
private
|
||||
|
||||
def permitted_params
|
||||
accessible = %i[
|
||||
%i[
|
||||
id
|
||||
name
|
||||
summary
|
||||
|
|
@ -84,7 +84,6 @@ class OrganizationsController < ApplicationController
|
|||
cta_button_url
|
||||
cta_body_markdown
|
||||
]
|
||||
accessible
|
||||
end
|
||||
|
||||
def organization_params
|
||||
|
|
|
|||
|
|
@ -191,6 +191,6 @@ class MailchimpBot
|
|||
end
|
||||
|
||||
def previously_subcribed?(error)
|
||||
error.title.match?(/Member In Compliance State/)
|
||||
error.title.include?("Member In Compliance State")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ module ReverseMarkdown
|
|||
text = remove_border_newlines(text)
|
||||
text = remove_inner_newlines(text)
|
||||
text = escape_keychars(text)
|
||||
text = preserve_keychars_within_backticks(text)
|
||||
text
|
||||
preserve_keychars_within_backticks(text)
|
||||
end
|
||||
|
||||
def preserve_nbsp(text)
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ class Message < ApplicationRecord
|
|||
def target_blank_links(html)
|
||||
return html if html.blank?
|
||||
|
||||
html = html.gsub("<a href", "<a target='_blank' rel='noopener nofollow' href")
|
||||
html
|
||||
html.gsub("<a href", "<a target='_blank' rel='noopener nofollow' href")
|
||||
end
|
||||
|
||||
# rubocop:disable Layout/LineLength
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
require_relative "../lib/acts_as_taggable_on/tag.rb"
|
||||
|
||||
class Tag < ActsAsTaggableOn::Tag
|
||||
attr_accessor :points
|
||||
attr_accessor :points, :tag_moderator_id, :remove_moderator_id
|
||||
|
||||
acts_as_followable
|
||||
resourcify
|
||||
|
||||
ALLOWED_CATEGORIES = %w[uncategorized language library tool site_mechanic location subcommunity].freeze
|
||||
|
||||
attr_accessor :tag_moderator_id, :remove_moderator_id
|
||||
|
||||
belongs_to :badge, optional: true
|
||||
has_one :sponsorship, as: :sponsorable, inverse_of: :sponsorable, dependent: :destroy
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
module Exporter
|
||||
class Articles
|
||||
attr_reader :name
|
||||
attr_reader :user
|
||||
attr_reader :name, :user
|
||||
|
||||
def initialize(user)
|
||||
@name = :articles
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
module Exporter
|
||||
class Comments
|
||||
attr_reader :name
|
||||
attr_reader :user
|
||||
attr_reader :name, :user
|
||||
|
||||
def initialize(user)
|
||||
@name = :comments
|
||||
|
|
|
|||
|
|
@ -19,13 +19,12 @@ module Notifications
|
|||
reason_for_adjustment: tag_adjustment.reason_for_adjustment,
|
||||
tag_name: tag_adjustment.tag_name
|
||||
}
|
||||
notification = Notification.create(
|
||||
Notification.create(
|
||||
user_id: article.user_id,
|
||||
notifiable_id: tag_adjustment.id,
|
||||
notifiable_type: tag_adjustment.class.name,
|
||||
json_data: json_data,
|
||||
)
|
||||
notification
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -7,14 +7,13 @@ module Suggester
|
|||
end
|
||||
|
||||
def suggest
|
||||
users = if user.decorate.cached_followed_tag_names.any?
|
||||
(recent_producers(3) - [user]).
|
||||
sample(50).uniq
|
||||
else
|
||||
(recent_commenters(4, 30) + recent_top_producers - [user]).
|
||||
uniq.sample(50)
|
||||
end
|
||||
users
|
||||
if user.decorate.cached_followed_tag_names.any?
|
||||
(recent_producers(3) - [user]).
|
||||
sample(50).uniq
|
||||
else
|
||||
(recent_commenters(4, 30) + recent_top_producers - [user]).
|
||||
uniq.sample(50)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# This file is used by Rack-based servers to start the application.
|
||||
|
||||
require ::File.expand_path("../config/environment", __FILE__)
|
||||
require ::File.expand_path("config/environment", __dir__)
|
||||
run Rails.application
|
||||
|
|
|
|||
|
|
@ -45,13 +45,13 @@
|
|||
"jest --findRelatedTests"
|
||||
],
|
||||
"{app,spec,config,lib}/**/*.rb": [
|
||||
"bundle exec rubocop --require rubocop-rspec --safe-auto-correct"
|
||||
"bundle exec rubocop --require rubocop-rspec --auto-correct"
|
||||
],
|
||||
"app/views/**/*.jbuilder": [
|
||||
"bundle exec rubocop --require rubocop-rspec --safe-auto-correct"
|
||||
"bundle exec rubocop --require rubocop-rspec --auto-correct"
|
||||
],
|
||||
"Gemfile": [
|
||||
"bundle exec rubocop --require rubocop-rspec --safe-auto-correct"
|
||||
"bundle exec rubocop --require rubocop-rspec --auto-correct"
|
||||
],
|
||||
"app/**/*.html.erb": [
|
||||
"bundle exec erblint --autocorrect"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue