diff --git a/.rubocop.yml b/.rubocop.yml index 1c8e27787..d8d51ced2 100644 --- a/.rubocop.yml +++ b/.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' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d7e955f59..61c0ce404 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index b20a3b62b..7649c3917 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -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 diff --git a/app/labor/mailchimp_bot.rb b/app/labor/mailchimp_bot.rb index c1c0194d1..d054a6909 100644 --- a/app/labor/mailchimp_bot.rb +++ b/app/labor/mailchimp_bot.rb @@ -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 diff --git a/app/lib/reverse_markdown/converters/custom_text.rb b/app/lib/reverse_markdown/converters/custom_text.rb index 3c6f84841..c9b63b49a 100644 --- a/app/lib/reverse_markdown/converters/custom_text.rb +++ b/app/lib/reverse_markdown/converters/custom_text.rb @@ -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) diff --git a/app/models/message.rb b/app/models/message.rb index fd1101c12..09b2a15c5 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -94,8 +94,7 @@ class Message < ApplicationRecord def target_blank_links(html) return html if html.blank? - html = html.gsub("