From 8fa114a3ca4ad2077af8791387545c5ec23cf099 Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 07:12:16 -0700 Subject: [PATCH 01/11] Disable pending cops by default --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 13d084ee3b..317bd906f3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,7 +45,7 @@ require: AllCops: # See https://docs.rubocop.org/rubocop/versioning.html#pending-cops - NewCops: enable + NewCops: disable ########################### Excluded files ################################### # Completely ignore the following From 9d449f2e8b432bb5ad25d741d742bd6c16a4a428 Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 07:18:01 -0700 Subject: [PATCH 02/11] Remove mry gem It was only for pre-release versions of RuboCop, which is now at 1.30. And I didn't use it much (or maybe at all)./ --- Gemfile | 3 --- Gemfile.lock | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index ada4c01215..1f97e2659c 100644 --- a/Gemfile +++ b/Gemfile @@ -140,9 +140,6 @@ gem("rubocop-rails", ">= 2.8.1") # version for older rubocop # http://github.com/DmitryTsepelev/rubocop-graphql gem("rubocop-graphql", require: false) -# use mry to support safe updating of .rubocop.yml -gem("mry", require: false) - ########## GraphQL API ######################################## # GraphQL-Ruby diff --git a/Gemfile.lock b/Gemfile.lock index f56bd70cc2..ae869d2b02 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -183,8 +183,6 @@ GEM minitest (>= 5.0) ruby-progressbar mocha (1.14.0) - mry (0.78.0.0) - rubocop (>= 0.41.0) mysql2 (0.5.4) nio4r (2.5.8) nokogiri (1.13.6-x86_64-linux) @@ -361,7 +359,6 @@ DEPENDENCIES minitest minitest-reporters mocha - mry mysql2 rack-cors rails (~> 6.1) @@ -385,4 +382,4 @@ DEPENDENCIES xmlrpc BUNDLED WITH - 2.3.14 + 2.3.6 From 3b1f448bb88ef16faa3bcb24e9be3247b37e5d01 Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 07:24:05 -0700 Subject: [PATCH 03/11] Unlock versions of rubocop-associated gems RuboCop was frozen; Hard to upgrade otherwise `>=` for other cops unneeded since RuboCop itself will be upgraded --- Gemfile | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 1f97e2659c..2f68a3c29d 100644 --- a/Gemfile +++ b/Gemfile @@ -123,15 +123,9 @@ gem("simplecov-lcov", require: false) gem("brakeman", require: false) # Use rubocop and associated gems for code quality control -# -# WARNING: -# When upgrading RuboCop, please use the procedure specified in .rubocop.yml -# -# Temporarily lock RuboCop version while we are working our way through -# auto-correctable offenses -gem("rubocop", "= 0.89", require: false) -gem("rubocop-performance", ">= 1.8.1") # version for older rubocop -gem("rubocop-rails", ">= 2.8.1") # version for older rubocop +gem("rubocop", require: false) +gem("rubocop-performance") +gem("rubocop-rails") # Rubocop extension for enforcing graphql-ruby best practices. # You need to tell RuboCop to load the GraphQL extension. rubocop.yml # require: From d9de0636c8676ad92e18be018c42a0d557cdd902 Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 07:44:40 -0700 Subject: [PATCH 04/11] Update (non-GraphQL) RuboCop-associated gems rubocop, rubocop-performance, rubocop-rails --- Gemfile.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ae869d2b02..c70f9f72b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -193,7 +193,7 @@ GEM promise.rb (0.7.4) public_suffix (4.0.7) racc (1.6.0) - rack (2.2.3) + rack (2.2.3.1) rack-cors (1.1.1) rack (>= 2.0.0) rack-test (1.1.0) @@ -242,29 +242,29 @@ GEM activerecord (>= 6.0.4) activesupport (>= 6.0.4) i18n - regexp_parser (2.4.0) + regexp_parser (2.5.0) rexml (3.2.5) rtf (0.3.3) - rubocop (0.89.0) + rubocop (1.30.0) parallel (~> 1.10) - parser (>= 2.7.1.1) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.7) - rexml - rubocop-ast (>= 0.1.0, < 1.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.18.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.8.0) - parser (>= 2.7.1.5) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.18.0) + parser (>= 3.1.1.0) rubocop-graphql (0.14.3) rubocop (>= 0.87, < 2) - rubocop-performance (1.8.1) - rubocop (>= 0.87.0) + rubocop-performance (1.14.0) + rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.8.1) + rubocop-rails (2.14.2) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.87.0) + rubocop (>= 1.7.0, < 2.0) ruby-progressbar (1.11.0) rubyzip (2.3.2) sassc (2.4.0) @@ -302,7 +302,7 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.8.0) + unicode-display_width (2.1.0) unicorn (5.4.1) kgio (~> 2.6) raindrops (~> 0.7) @@ -365,10 +365,10 @@ DEPENDENCIES rails-controller-testing rails_db (~> 2.4.0) rtf - rubocop (= 0.89) + rubocop rubocop-graphql - rubocop-performance (>= 1.8.1) - rubocop-rails (>= 2.8.1) + rubocop-performance + rubocop-rails rubyzip sassc-rails simple_enum From 01fb763e0a231d7ca698abaf7a2c69aac26ff04e Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 08:11:51 -0700 Subject: [PATCH 05/11] Update RuboCop version used by Codeclimate Use 1-23-0, which is Codeclimate's highest available RuboCop channel. While not quite as good as 1-30, it's better than a pre-relase version. --- .codeclimate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index a25b4ec765..e386ef7593 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -120,7 +120,7 @@ plugins: # Specify RuboCop version so that we're not stuck with Code Climate's # default, which can be different than what's in Gemfile.lock. See # docs.codeclimate.com/docs/rubocop#section-using-rubocop-s-newer-versions - channel: rubocop-0-89 + channel: rubocop-1-23-0 # scss style checker scss-lint: From 208e4980e2324b459a5d28f9ebd4e024aeaeaff0 Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 08:34:43 -0700 Subject: [PATCH 06/11] Simplify instructions about updating RuboCop They were so complicated that they deterred updates. --- .rubocop.yml | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 317bd906f3..5eb2bfd9e1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,37 +5,18 @@ require: - rubocop-rails # ------------------------------------------------------------------------------ +# Updating RuboCop # -# UPDATING RUBOCOP in MushroomObserver -# Please use the following procedure or equivalent in order to: -# - Avoid discrepancies between RuboCop locally vs in continuous integration; -# - Prevent increases in the number of offenses. -# -# *** Update the Codeclimate channel +# *** Update The Codeclimate Channel When Updating Rubocop +# See docs.codeclimate.com/docs/rubocop#section-using-rubocop-s-newer-versions +# Use the highest available channel that's compatible with the RuboCop version. # .codeclimate.yml specifies the RuboCop version ('channel') used # by Code Climate, which can be different than the version in Gemfile.lock -# See docs.codeclimate.com/docs/rubocop#section-using-rubocop-s-newer-versions -# Therefore .codeclimate.yml should be updated whenever updating RuboCop -# -# *** Install the higher version of rubocop -# - Update the Gemfile -# - bundle update rubocop -# -# *** Update the RuboCop configuration (this file) -# - Run "rubocop --auto-gen-config" BUT DON'T COMMIT .rubocop_todo.yml -# - Add any new cops to .rubocop.yml (this file) if the output so indicates. -# -# *** Fix any new offenses caused by the update -# - Iteratively do the following steps until all new offenses are fixed: -# - Again run "rubocop --auto-gen-config" BUT DON'T COMMIT .rubocop_todo.yml -# - Compare the newly generated and existing versions of .rubocop_todo.yml -# - Fix any new offenses. -# (The initial new offenses will have been caused by new or updated cops. -# Fixing those offenses may cause new offenses. And so forth.) # -# *** Prune the todo list -# Compare the new and existing versions of .rubocop_todo.yml (the todo list) -# Accept any changes that reduce the todo list. +# *** Re-generate the RuboCop auto-configuration todo list +# at least run rubocop --regenerate-todo and commit changes +# optionally follow other suggestions at +# https://docs.rubocop.org/rubocop/configuration.html#automatically-generated-configuration # # ------------------------------------------------------------------------------ From df63bb5daf4eab23adf8ed2949e826dae3ce23bd Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 09:04:49 -0700 Subject: [PATCH 07/11] Regenerate RuiboCop todo This is needed in order to prevent CodeClimate from flagging new offenses on unchanged lines. Unfortunately, it suppresses thousands of existing offenses. --- .rubocop_todo.yml | 328 +++++++++++++++++++++++++++++----------------- 1 file changed, 210 insertions(+), 118 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index da7f8b15da..2c9ac3c96b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,21 +1,35 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-05-01 22:42:53 UTC using RuboCop version 0.89.0. +# on 2022-05-29 15:54:50 UTC using RuboCop version 1.30.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: 41 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleAlignWith, Severity. +# SupportedStylesAlignWith: start_of_line, begin +Layout/BeginEndAlignment: + Enabled: false + +# Offense count: 41 +# This cop supports safe autocorrection (--autocorrect). +Layout/RescueEnsureAlignment: + Enabled: false + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'test/graphql_queries.rb' + # Offense count: 34 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: Enabled: false -# Offense count: 2 -Lint/BinaryOperatorWithIdenticalOperands: - Exclude: - - 'script/slowest_pages' - # Offense count: 8 Lint/DuplicateMethods: Exclude: @@ -25,6 +39,12 @@ Lint/DuplicateMethods: - 'app/classes/query/modules/high_level_queries.rb' - 'app/models/image.rb' +# Offense count: 2 +# Configuration parameters: AllowComments. +Lint/EmptyConditionalBody: + Exclude: + - 'lib/tasks/email.rake' + # Offense count: 2 Lint/IneffectiveAccessModifier: Exclude: @@ -48,7 +68,7 @@ Lint/MissingCopEnableDirective: - 'app/classes/report/raw.rb' - 'app/classes/report/symbiota.rb' -# Offense count: 15 +# Offense count: 10 Lint/MissingSuper: Exclude: - 'app/classes/api/errors.rb' @@ -56,11 +76,6 @@ Lint/MissingSuper: - 'app/classes/api/upload.rb' - 'app/classes/checklist.rb' - 'app/classes/geocoder.rb' - - 'app/classes/query/modules/active_record.rb' - - 'app/classes/query/modules/serialization.rb' - - 'app/models/language_exporter.rb' - - 'script/update_googlebots.rb' - - 'script/update_ip_stats.rb' - 'test/uploaded_string.rb' # Offense count: 1 @@ -68,11 +83,24 @@ Lint/NonLocalExitFromIterator: Exclude: - 'test/general_extensions.rb' -# Offense count: 2 -# Cop supports --auto-correct. +# Offense count: 20 +# This cop supports safe autocorrection (--autocorrect). Lint/RedundantCopDisableDirective: Exclude: + - 'app/classes/ip_stats.rb' + - 'app/models/external_link.rb' - 'test/controllers/name_controller_test.rb' + - 'test/models/api2_test.rb' + - 'test/models/api_test.rb' + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods. +# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal? +Lint/RedundantSafeNavigation: + Exclude: + - 'app/models/comment.rb' + - 'app/presenters/matrix_box_presenter.rb' # Offense count: 1 Lint/RescueException: @@ -97,7 +125,7 @@ Lint/ShadowingOuterLocalVariable: - 'test/session_form_extensions.rb' # Offense count: 18 -# Configuration parameters: AllowComments. +# Configuration parameters: AllowComments, AllowNil. Lint/SuppressedException: Exclude: - 'app/helpers/api_helper.rb' @@ -105,6 +133,13 @@ Lint/SuppressedException: - 'script/make_eol_xml' - 'test/controllers/species_list_controller_test.rb' +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/UselessMethodDefinition: + Exclude: + - 'app/classes/query/location_by_editor.rb' + - 'test/models/auto_complete_test.rb' + # Offense count: 9 # Configuration parameters: CheckForMethodsWithNoSideEffects. Lint/Void: @@ -117,17 +152,17 @@ Lint/Void: - 'test/models/api_test.rb' # Offense count: 198 -# Configuration parameters: IgnoredMethods. +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: - Max: 134 + Max: 135 # Offense count: 22 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. -# ExcludedMethods: refine +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine Metrics/BlockLength: Max: 161 -# Offense count: 43 +# Offense count: 42 # Configuration parameters: CountBlocks. Metrics/BlockNesting: Max: 5 @@ -135,15 +170,15 @@ Metrics/BlockNesting: # Offense count: 21 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 1064 + Max: 1054 -# Offense count: 148 +# Offense count: 146 # Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: Max: 55 # Offense count: 62 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. Metrics/MethodLength: Max: 124 @@ -152,12 +187,12 @@ Metrics/MethodLength: Metrics/ModuleLength: Max: 504 -# Offense count: 10 -# Configuration parameters: CountKeywordArgs. +# Offense count: 8 +# Configuration parameters: CountKeywordArgs, MaxOptionalParameters. Metrics/ParameterLists: Max: 9 -# Offense count: 133 +# Offense count: 131 # Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: Max: 43 @@ -193,66 +228,42 @@ Naming/HeredocDelimiterNaming: Naming/PredicateName: Enabled: false -# Offense count: 8 -# Configuration parameters: MinSize. -Performance/CollectionLiteralInLoop: - Exclude: - - 'app/controllers/species_list_controller.rb' - - 'script/jpegsize' - - 'script/mushroom_mapper.rb' - - 'script/update_googlebots.rb' - - 'script/update_ip_stats.rb' - - 'test/controllers/api2_controller_test.rb' - - 'test/controllers/api_controller_test.rb' - - 'test/models/abstract_model_test.rb' +# Offense count: 138 +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. +# SupportedStyles: snake_case, normalcase, non_integer +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 +Naming/VariableNumber: + Enabled: false # Offense count: 5 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Performance/Detect: Exclude: - 'test/controllers/api2_controller_test.rb' - 'test/controllers/name_controller_test.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/ActiveRecordCallbacksOrder: - Exclude: - - 'app/models/observation.rb' - -# Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Rails/ApplicationMailer: Exclude: - 'app/models/account_mailer.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent. Rails/Blank: Exclude: - 'app/controllers/application_controller.rb' -# Offense count: 46 -# Cop supports --auto-correct. +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). Rails/ContentTag: Exclude: - 'app/helpers/application_helper.rb' - - 'app/helpers/description_helper.rb' - - 'app/helpers/exporter_helper.rb' - - 'app/helpers/footer_helper.rb' - - 'app/helpers/interest_icons_helper.rb' - - 'app/helpers/map_helper.rb' - - 'app/helpers/object_link_helper.rb' - - 'app/helpers/pagination_helper.rb' - 'app/helpers/pivotal_helper.rb' - - 'app/helpers/thumbnail_helper.rb' - - 'app/helpers/version_helper.rb' - - 'test/controllers/application_helper_test.rb' -# Offense count: 90 -# Cop supports --auto-correct. +# Offense count: 85 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. # Whitelist: find_by_sql # AllowedMethods: find_by_sql @@ -270,7 +281,7 @@ Rails/FilePath: - 'test/general_extensions.rb' - 'test/models/language_exporter_test.rb' -# Offense count: 45 +# Offense count: 47 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/HasManyOrHasOneDependent: @@ -305,14 +316,24 @@ Rails/HelperInstanceVariable: - 'app/helpers/version_helper.rb' # Offense count: 335 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Include. # Include: spec/**/*, test/**/* Rails/HttpPositionalArguments: Enabled: false +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Rails/IndexWith: + Exclude: + - 'app/classes/site_data.rb' + - 'app/models/name/propagate_generic_classifications.rb' + - 'test/controllers/name_controller_test.rb' + - 'test/controllers/translation_controller_test.rb' + - 'test/integration/expert_test.rb' + # Offense count: 14 -# Configuration parameters: Include. +# Configuration parameters: IgnoreScopes, Include. # Include: app/models/**/*.rb Rails/InverseOf: Exclude: @@ -327,6 +348,7 @@ Rails/InverseOf: - 'app/models/user_group.rb' # Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Include. # Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb Rails/Output: @@ -345,17 +367,22 @@ Rails/OutputSafety: - 'app/helpers/version_helper.rb' - 'config/application.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/Pick: + Exclude: + - 'app/models/user.rb' + # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Include. # Include: **/Rakefile, **/*.rake Rails/RakeEnvironment: Exclude: - - 'lib/capistrano/tasks/**/*.rake' - 'lib/tasks/lang.rake' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Rails/RedundantForeignKey: Exclude: - 'app/models/glossary_term.rb' @@ -366,14 +393,6 @@ Rails/RedundantForeignKey: - 'app/models/project.rb' - 'app/models/queued_email.rb' -# Offense count: 6 -Rails/RenderInline: - Exclude: - - 'app/controllers/ajax_controller/exif.rb' - - 'app/controllers/ajax_controller/export.rb' - - 'app/controllers/ajax_controller/pivotal.rb' - - 'app/controllers/ajax_controller/vote.rb' - # Offense count: 2 # Configuration parameters: Include. # Include: app/models/**/*.rb @@ -382,21 +401,13 @@ Rails/UniqueValidationWithoutIndex: - 'app/models/external_link.rb' - 'app/models/external_site.rb' -# Offense count: 8 -# Cop supports --auto-correct. -Rails/WhereNot: - Exclude: - - 'test/models/api2_test.rb' - - 'test/models/api_test.rb' - - 'test/models/pattern_search_test.rb' - # Offense count: 1 Security/Eval: Exclude: - 'script/config.rb' # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Security/YAMLLoad: Exclude: - 'app/classes/country_counter.rb' @@ -404,27 +415,28 @@ Security/YAMLLoad: - 'app/models/location.rb' # Offense count: 137 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: separated, grouped Style/AccessorGrouping: Enabled: false # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Style/ArrayCoercion: Exclude: - 'app/classes/map_collapsible.rb' - 'app/classes/query/modules/conditions.rb' - 'app/controllers/application_controller.rb' -# Offense count: 19 -# Cop supports --auto-correct. +# Offense count: 21 +# This cop supports unsafe autocorrection (--autocorrect-all). Style/CaseLikeIf: Exclude: - 'app/classes/api/results.rb' - 'app/classes/eol_data.rb' - 'app/classes/minimal_map_observation.rb' + - 'app/classes/pivotal/story.rb' - 'app/classes/query/modules/sql.rb' - 'app/classes/query/modules/validation.rb' - 'app/classes/textile.rb' @@ -432,45 +444,84 @@ Style/CaseLikeIf: - 'app/controllers/ajax_controller/external_link.rb' - 'app/controllers/ajax_controller/pivotal.rb' - 'app/controllers/collection_number_controller.rb' + - 'app/controllers/description_controller_helpers.rb' - 'app/controllers/observer_controller/indexes.rb' - 'test/session_extensions.rb' - 'test/session_form_extensions.rb' # Offense count: 147 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Enabled: false -# Offense count: 72 +# Offense count: 9 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: ==, equal?, eql? +Style/ClassEqualityComparison: + Exclude: + - 'app/controllers/description_controller_helpers.rb' + - 'app/helpers/javascript_helper.rb' + - 'app/models/account_mailer.rb' + - 'app/models/name_sorter.rb' + - 'test/models/api2_test.rb' + - 'test/models/api_test.rb' + +# Offense count: 71 Style/ClassVars: Enabled: false +# Offense count: 8 +Style/CombinableLoops: + Exclude: + - 'script/check_enum_values' + - 'script/mushroom_mapper.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Keywords, RequireColon. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE +Style/CommentAnnotation: + Exclude: + - 'app/controllers/name_controller.rb' + - 'app/models/project.rb' + # Offense count: 16 +# This cop supports safe autocorrection (--autocorrect). Style/CommentedKeyword: Exclude: - 'app/controllers/observer_controller/markup_controller.rb' - 'app/helpers/pagination_helper.rb' - 'test/integration/capybara_lurker_test.rb' -# Offense count: 269 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'app/classes/query/modules/initialization.rb' + +# Offense count: 256 +# Configuration parameters: AllowedConstants. Style/Documentation: Enabled: false -# Offense count: 7 +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: allowed_in_returns, forbidden Style/DoubleNegation: Exclude: - 'app/classes/gmaps.rb' - 'app/classes/query/modules/ordering.rb' - - 'app/controllers/translation_controller.rb' - 'app/models/image.rb' - 'test/models/language_exporter_test.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, expanded Style/EmptyMethod: @@ -479,20 +530,20 @@ Style/EmptyMethod: - 'app/controllers/theme_controller.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/ExpandPathArguments: Exclude: - 'config.ru' -# Offense count: 91 -# Cop supports --auto-correct. +# Offense count: 88 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: each, for Style/For: Enabled: false # Offense count: 10 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent Style/FormatString: @@ -501,31 +552,28 @@ Style/FormatString: - 'app/models/name_sorter.rb' - 'app/views/name/eol.xml.builder' -# Offense count: 53 -# Configuration parameters: EnforcedStyle. +# Offense count: 40 +# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, IgnoredMethods. # SupportedStyles: annotated, template, unannotated Style/FormatStringToken: Exclude: - - 'app/classes/query/modules/serialization.rb' - 'app/classes/query/modules/validation.rb' - 'app/controllers/observer_controller/user_controller.rb' - - 'app/helpers/api_helper.rb' - - 'app/helpers/tabs_helper.rb' - - 'app/models/name_sorter.rb' - 'app/models/species_list.rb' - - 'app/views/name/eol.xml.builder' - 'lib/tasks/email.rake' - 'script/monitor_top' - 'script/slowest_pages' - 'test/models/collapsible_map_test.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. Style/HashEachMethods: Exclude: - 'app/controllers/image_controller.rb' # Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowIfModifier. Style/IfInsideElse: Exclude: @@ -534,16 +582,22 @@ Style/IfInsideElse: - 'lib/tasks/cache.rake' # Offense count: 5 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: InverseMethods, InverseBlocks. Style/InverseMethods: Exclude: - 'app/helpers/description_helper.rb' - 'test/models/api_test.rb' -# Offense count: 32 -# Cop supports --auto-correct. -# Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, EnforcedStyle. +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/KeywordParametersOrder: + Exclude: + - 'app/controllers/observer_controller/search_controller.rb' + +# Offense count: 31 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IgnoreMacros, IgnoredMethods, AllowedPatterns, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, AllowParenthesesInStringInterpolation, EnforcedStyle. # SupportedStyles: require_parentheses, omit_parentheses Style/MethodCallWithArgsParentheses: Exclude: @@ -554,7 +608,6 @@ Style/MethodCallWithArgsParentheses: - 'app/models/glossary_term.rb' - 'app/models/location.rb' - 'app/models/name.rb' - - 'app/models/name/taxonomy.rb' - 'app/models/name_sorter.rb' - 'config/routes.rb' - 'lib/tasks/lang.rake' @@ -569,18 +622,36 @@ Style/MissingRespondToMissing: - 'script/update_googlebots.rb' - 'script/update_ip_stats.rb' -# Offense count: 69 +# Offense count: 68 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? Style/OptionalBooleanParameter: Enabled: false +# Offense count: 9 +# This cop supports safe autocorrection (--autocorrect). +Style/PerlBackrefs: + Exclude: + - 'app/controllers/translation_controller.rb' + - 'app/extensions/string_extensions.rb' + - 'app/models/language_exporter.rb' + - 'test/check_for_unsafe_html.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantBegin: + Exclude: + - 'app/classes/query/modules/nested_queries.rb' + - 'app/models/name/synonymy.rb' + # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/RedundantFileExtensionInRequire: Exclude: - 'test/language_extensions.rb' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: Exclude: - 'app/classes/pattern_search/term.rb' @@ -591,7 +662,28 @@ Style/SlicingWithRange: - 'test/models/comment_test.rb' - 'test/models/image_script_test.rb' +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'app/controllers/observer_controller/create_and_edit_observation.rb' + - 'app/views/api2/_user.json.jbuilder' + - 'app/views/api2/_user.xml.builder' + # Offense count: 168 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. Style/StringConcatenation: Enabled: false + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'app/classes/gmaps.rb' + - 'app/classes/pattern_search/term.rb' + - 'app/classes/query/modules/initialization.rb' + - 'script/refresh_name_lister_cache' From b53dd5e18d806d033ed247104991534ac74030f5 Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 11:54:53 -0700 Subject: [PATCH 08/11] Regenerate Gemfile.lock I needed to do that after merging master into this branch --- Gemfile.lock | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e59d009dfc..ee57eeb4b1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,8 +145,6 @@ GEM minitest (>= 5.0) ruby-progressbar mocha (1.14.0) - mry (0.78.0.0) - rubocop (>= 0.41.0) mysql2 (0.5.4) nokogiri (1.13.6-x86_64-linux) racc (~> 1.4) @@ -296,16 +294,15 @@ DEPENDENCIES minitest minitest-reporters mocha - mry mysql2 rack-cors rails-controller-testing railties (~> 6.1) rtf - rubocop (= 0.89) + rubocop rubocop-graphql - rubocop-performance (>= 1.8.1) - rubocop-rails (>= 2.8.1) + rubocop-performance + rubocop-rails rubyzip sassc-rails simple_enum @@ -320,4 +317,4 @@ DEPENDENCIES xmlrpc BUNDLED WITH - 2.3.13 + 2.3.6 From 010ac3bdc6a9abca4133122ba7484183bb797786 Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 13:26:13 -0700 Subject: [PATCH 09/11] Re-update gems Run `bundle update` to re-update the rubocop gems. I needed to do this after merging master into this branch. --- Gemfile.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ee57eeb4b1..24c7e9a9d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -180,26 +180,26 @@ GEM regexp_parser (2.5.0) rexml (3.2.5) rtf (0.3.3) - rubocop (0.89.0) + rubocop (1.30.0) parallel (~> 1.10) - parser (>= 2.7.1.1) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.7) - rexml - rubocop-ast (>= 0.1.0, < 1.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.18.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.8.0) - parser (>= 2.7.1.5) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.18.0) + parser (>= 3.1.1.0) rubocop-graphql (0.14.3) rubocop (>= 0.87, < 2) - rubocop-performance (1.8.1) - rubocop (>= 0.87.0) + rubocop-performance (1.14.0) + rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.8.1) + rubocop-rails (2.14.2) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.87.0) + rubocop (>= 1.7.0, < 2.0) ruby-progressbar (1.11.0) rubyzip (2.3.2) sassc (2.4.0) @@ -232,7 +232,7 @@ GEM concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.8.0) + unicode-display_width (2.1.0) unicorn (5.4.1) kgio (~> 2.6) raindrops (~> 0.7) From 659a7259071bd15f9ebe9042ad21bd6c82355ce4 Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Sun, 29 May 2022 16:54:49 -0700 Subject: [PATCH 10/11] Remove redundant double negation Fixes Codeclimate issue --- app/controllers/translation_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/translation_controller.rb b/app/controllers/translation_controller.rb index 6aa723b83f..43c1a1fbbc 100644 --- a/app/controllers/translation_controller.rb +++ b/app/controllers/translation_controller.rb @@ -313,7 +313,7 @@ def process_comment(str) reset_everything elsif /^[A-Z][^a-z]*(--|$)/.match?(str) @major_head << str - @on_pages = !!/PAGES/.match?(str) + @on_pages = /PAGES/.match?(str) elsif @expecting_minor_head @minor_head << str else From 861686603bd08c2e6b1921c07e48961fd60b9e32 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Sun, 29 May 2022 18:12:59 -0700 Subject: [PATCH 11/11] Preliminary fixes for two cops Joe - if you can fix the ABC in IpStats#update_one_stat have at it! It really looks fine to me. --- app/classes/ip_stats.rb | 2 ++ app/controllers/translation_controller.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/classes/ip_stats.rb b/app/classes/ip_stats.rb index 070e78074a..1c7a95ef0a 100644 --- a/app/classes/ip_stats.rb +++ b/app/classes/ip_stats.rb @@ -59,6 +59,7 @@ def add_one_line_to_stats(data, vals, now, do_activity) update_one_stat(hash, vals, weight, do_activity) end + # rubocop:disable Metrics/AbcSize def update_one_stat(hash, vals, weight, do_activity) time, ip, user, load, controller, action, api_key = *vals hash[:ip] = ip @@ -69,6 +70,7 @@ def update_one_stat(hash, vals, weight, do_activity) hash[:activity] << [time, load.to_f, controller, action] \ if do_activity end + # rubocop:enable Metrics/AbcSize def clean_stats cutoff = (Time.now.utc - STATS_TIME * 60).to_s diff --git a/app/controllers/translation_controller.rb b/app/controllers/translation_controller.rb index 6aa723b83f..43c1a1fbbc 100644 --- a/app/controllers/translation_controller.rb +++ b/app/controllers/translation_controller.rb @@ -313,7 +313,7 @@ def process_comment(str) reset_everything elsif /^[A-Z][^a-z]*(--|$)/.match?(str) @major_head << str - @on_pages = !!/PAGES/.match?(str) + @on_pages = /PAGES/.match?(str) elsif @expecting_minor_head @minor_head << str else