From 86642450811075ffed06c106306bfb93c56abb1d Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Sun, 12 Nov 2023 15:12:29 +0100 Subject: [PATCH 1/6] use rubocop settings from shopify and set some rules where we deviate --- .rubocop.yml | 334 +-------------------------------------------------- Gemfile | 4 +- Gemfile.lock | 15 +-- 3 files changed, 8 insertions(+), 345 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d7b548944..83daa996a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,341 +1,15 @@ -require: - - rubocop-packaging - - rubocop-performance - - rubocop-rails - -AllCops: - TargetRubyVersion: 3.0 - # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop - # to ignore them, so only the ones explicitly set in this file are enabled. - DisabledByDefault: false - Exclude: - - '**/tmp/**/*' - - '**/templates/**/*' - - '**/vendor/**/*' - - 'actionpack/lib/action_dispatch/journey/parser.rb' - - 'actionmailbox/test/dummy/**/*' - - 'actiontext/test/dummy/**/*' - - '**/node_modules/**/*' - -Performance: - Exclude: - - '**/test/**/*' - -# Prefer assert_not over assert ! -Rails/AssertNot: - Include: - - '**/test/**/*' - -# Prefer assert_not_x over refute_x -Rails/RefuteMethods: - Include: - - '**/test/**/*' - -Rails/IndexBy: - Enabled: true - -Rails/IndexWith: - Enabled: true - -# Prefer &&/|| over and/or. -Style/AndOr: - Enabled: true - -Layout/ArgumentAlignment: - Enabled: true - -Layout/ArrayAlignment: - Enabled: true - -Layout/BlockAlignment: - Enabled: true - -# Align `when` with `case`. -Layout/CaseIndentation: - Enabled: true - -Layout/ClosingHeredocIndentation: - Enabled: true - -# Align comments with method definitions. -Layout/CommentIndentation: - Enabled: true - -Layout/ElseAlignment: - Enabled: true - -# Align `end` with the matching keyword or starting expression except for -# assignments, where it should be aligned with the LHS. -Layout/EndAlignment: - Enabled: true - EnforcedStyleAlignWith: variable - AutoCorrect: true - -Layout/EmptyLines: - Enabled: true - -Layout/EmptyLineAfterMagicComment: - Enabled: true - -Layout/EmptyLinesAroundAccessModifier: - Enabled: true - -Layout/EmptyLinesAroundBlockBody: - Enabled: true - -# In a regular class definition, no empty lines around the body. -Layout/EmptyLinesAroundClassBody: - Enabled: true - -# In a regular method definition, no empty lines around the body. -Layout/EmptyLinesAroundMethodBody: - Enabled: true - -# In a regular module definition, no empty lines around the body. -Layout/EmptyLinesAroundModuleBody: - Enabled: true - -Layout/ExtraSpacing: - Enabled: true +inherit_gem: + rubocop-shopify: rubocop.yml Layout/LineLength: Max: 80 -# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. -Style/HashSyntax: - Enabled: true - -Layout/FirstArgumentIndentation: - Enabled: true - -Layout/HashAlignment: - Enabled: true - -# Method definitions after `private` or `protected` isolated calls need one -# extra level of indentation. Layout/IndentationConsistency: - Enabled: true EnforcedStyle: indented_internal_methods -# Two spaces, no tabs (for indentation). -Layout/IndentationWidth: - Enabled: true - -Layout/LeadingCommentSpace: - Enabled: true - -Layout/MultilineOperationIndentation: - Enabled: true - -Layout/SpaceAfterColon: - Enabled: true - -Layout/SpaceAfterComma: - Enabled: true - -Layout/SpaceAfterSemicolon: - Enabled: true - -Layout/SpaceAroundEqualsInParameterDefault: - Enabled: true - -Layout/SpaceAroundKeyword: - Enabled: true - -Layout/SpaceBeforeComma: - Enabled: true - -Layout/SpaceBeforeComment: - Enabled: true - -Layout/SpaceBeforeFirstArg: - Enabled: true - -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: true - -Style/BlockDelimiters: - Enabled: true - -Style/BlockComments: - Enabled: true - -Style/ConditionalAssignment: - Enabled: true - -Style/DefWithParentheses: - Enabled: true - -Style/Documentation: - Enabled: true - -# Defining a method with parameters needs parentheses. -Style/MethodDefParentheses: - Enabled: true - -Style/MethodCallWithoutArgsParentheses: - Enabled: true - -Style/FrozenStringLiteralComment: - Enabled: true - EnforcedStyle: always - Exclude: - - 'actionview/test/**/*.builder' - - 'actionview/test/**/*.ruby' - - 'actionpack/test/**/*.builder' - - 'actionpack/test/**/*.ruby' - - 'activestorage/db/migrate/**/*.rb' - - 'activestorage/db/update_migrate/**/*.rb' - - 'actionmailbox/db/migrate/**/*.rb' - - 'actiontext/db/migrate/**/*.rb' - -Style/NumericLiterals: - Enabled: true - -Style/NumericPredicate: - Enabled: true - -Style/RedundantFreeze: - Enabled: true - -Style/SymbolProc: - Enabled: true - -Style/SymbolArray: - Enabled: false - -# Use `foo {}` not `foo{}`. -Layout/SpaceBeforeBlockBraces: - Enabled: true - -# Use `foo { bar }` not `foo {bar}`. -Layout/SpaceInsideBlockBraces: - Enabled: true - EnforcedStyleForEmptyBraces: space - -# Use `{ a: 1 }` not `{a:1}`. -Layout/SpaceInsideHashLiteralBraces: - Enabled: true - -Layout/SpaceInsideParens: - Enabled: true - -# Check quotes usage according to lint rule below. Style/StringLiterals: - Enabled: true EnforcedStyle: single_quotes -# Detect hard tabs, no hard tabs. -Layout/IndentationStyle: - Enabled: true - -# Empty lines should not have any spaces. -Layout/TrailingEmptyLines: - Enabled: true - -# No trailing whitespace. -Layout/TrailingWhitespace: - Enabled: true - -# Use quotes for string literals when they are enough. -Style/RedundantPercentQ: - Enabled: true - -Lint/AmbiguousOperator: - Enabled: true - -Lint/AmbiguousRegexpLiteral: - Enabled: true - -Lint/ErbNewArguments: - Enabled: true - -# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. -Lint/RequireParentheses: - Enabled: true - -Lint/ShadowingOuterLocalVariable: - Enabled: true - -Lint/RedundantStringCoercion: - Enabled: true - -Lint/UriEscapeUnescape: - Enabled: true - -Lint/UselessAssignment: - Enabled: true - -Lint/DeprecatedClassMethods: - Enabled: true - -Naming/VariableNumber: - Enabled: true - -Style/ParenthesesAroundCondition: - Enabled: true - -Style/HashTransformKeys: - Enabled: true - -Style/HashTransformValues: - Enabled: true - -Style/RedundantBegin: - Enabled: true - -Style/RedundantReturn: - Enabled: true - AllowMultipleReturnValues: true - -Style/Semicolon: - Enabled: true - AllowAsExpressionSeparator: true - -# Prefer Foo.method over Foo::method -Style/ColonMethodCall: - Enabled: true - -Style/TrivialAccessors: - Enabled: true - -Performance/FlatMap: - Enabled: true - -Performance/RedundantMerge: - Enabled: true - -Performance/StartWith: - Enabled: true - -Performance/EndWith: - Enabled: true - -Performance/RegexpMatch: - Enabled: true - -Performance/ReverseEach: - Enabled: true - -Performance/UnfreezeString: - Enabled: true - -Performance/DeletePrefix: - Enabled: true - -Performance/DeleteSuffix: - Enabled: true - -Metrics/ModuleLength: - Enabled: false - -Metrics/ClassLength: - Enabled: false - -Metrics/MethodLength: - Exclude: - - 'app/abilities/**/*' +Style/FrozenStringLiteralComment: + EnforcedStyle: never -Metrics/AbcSize: - Exclude: - - 'app/abilities/**/*' \ No newline at end of file diff --git a/Gemfile b/Gemfile index 228b9e901..853702acd 100644 --- a/Gemfile +++ b/Gemfile @@ -119,9 +119,7 @@ group :development, :docker_development do gem "spring" gem "spring-watcher-listen", "~> 2.0.0" gem "rubocop", "~> 1.50", require: false - gem "rubocop-packaging", require: false - gem "rubocop-performance", require: false - gem "rubocop-rails", require: false + gem "rubocop-shopify", require: false gem "erb_lint", require: false gem "pgreset" gem "marcel" diff --git a/Gemfile.lock b/Gemfile.lock index c1296235d..26d0bab46 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -508,15 +508,8 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.28.0) parser (>= 3.2.1.0) - rubocop-packaging (0.5.1) - rubocop (>= 0.89, < 2.0) - rubocop-performance (1.10.2) - rubocop (>= 0.90.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.9.1) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 0.90.0, < 2.0) + rubocop-shopify (2.13.0) + rubocop (~> 1.50) ruby-graphviz (1.2.5) rexml ruby-progressbar (1.13.0) @@ -717,9 +710,7 @@ DEPENDENCIES rqrcode rspec-rails rubocop (~> 1.50) - rubocop-packaging - rubocop-performance - rubocop-rails + rubocop-shopify rubyzip (~> 2.3.0) sass-rails (>= 6) selenium-webdriver From 552405520991e2e11505c0a21f6c1a3051836d94 Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Tue, 14 Nov 2023 20:19:35 +0100 Subject: [PATCH 2/6] remove some of the deviatons from shopify rubocop settings --- .rubocop.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 83daa996a..c733695f1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,12 +4,6 @@ inherit_gem: Layout/LineLength: Max: 80 -Layout/IndentationConsistency: - EnforcedStyle: indented_internal_methods - -Style/StringLiterals: - EnforcedStyle: single_quotes - Style/FrozenStringLiteralComment: EnforcedStyle: never From c4187a4a392f72a960c7fc96c98da11eb438f257 Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:40:55 +0100 Subject: [PATCH 3/6] chage maximum line length settings, remove empty newline --- .rubocop.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c733695f1..f427fb0b7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,9 @@ inherit_gem: rubocop-shopify: rubocop.yml +# Hard limit is 100 characters, soft limit is 80 characters Layout/LineLength: - Max: 80 + Max: 100 Style/FrozenStringLiteralComment: EnforcedStyle: never - From 2292a63aa48f6e16909664c5541de3ce9ef9c3ee Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:52:46 +0100 Subject: [PATCH 4/6] update rubocop and rubocop-shopify versions --- Gemfile | 5 ++--- Gemfile.lock | 41 ++++++++++++++--------------------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/Gemfile b/Gemfile index 853702acd..bc17d0a58 100644 --- a/Gemfile +++ b/Gemfile @@ -118,9 +118,8 @@ group :development, :docker_development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem "spring" gem "spring-watcher-listen", "~> 2.0.0" - gem "rubocop", "~> 1.50", require: false - gem "rubocop-shopify", require: false - gem "erb_lint", require: false + gem "rubocop", "~> 1.57", require: false + gem "rubocop-shopify", "~> 2.14", require: false gem "pgreset" gem "marcel" # gem 'bullet' diff --git a/Gemfile.lock b/Gemfile.lock index 26d0bab46..74cc01bae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -132,13 +132,6 @@ GEM execjs (~> 2.0) barby (0.6.8) bcrypt (3.1.18) - better_html (2.0.1) - actionview (>= 6.0) - activesupport (>= 6.0) - ast (~> 2.0) - erubi (~> 1.4) - parser (>= 2.4) - smart_properties bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) @@ -205,13 +198,6 @@ GEM unf (>= 0.0.5, < 1.0.0) down (5.4.0) addressable (~> 2.8) - erb_lint (0.4.0) - activesupport - better_html (>= 2.0.1) - parser (>= 2.7.1.4) - rainbow - rubocop - smart_properties erubi (1.12.0) erubis (2.7.0) et-orbi (1.2.7) @@ -324,6 +310,7 @@ GEM kramdown (~> 2.0) kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) + language_server-protocol (3.17.0.3) launchy (2.5.2) addressable (~> 2.8) listen (3.0.8) @@ -373,8 +360,9 @@ GEM orm_adapter (0.5.0) pairing_heap (3.0.0) parallel (1.23.0) - parser (3.2.2.0) + parser (3.2.2.4) ast (~> 2.4.1) + racc pdf-reader (2.11.0) Ascii85 (~> 1.0) afm (~> 0.2.1) @@ -455,7 +443,7 @@ GEM ffi (~> 1.0) redis-client (0.14.1) connection_pool - regexp_parser (2.8.0) + regexp_parser (2.8.2) request_store (1.5.1) rack (>= 1.4) responders (3.1.0) @@ -496,20 +484,21 @@ GEM rspec-mocks (~> 3.11) rspec-support (~> 3.11) rspec-support (3.12.0) - rubocop (1.50.2) + rubocop (1.57.2) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + parser (>= 3.2.2.4) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.28.0) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) - rubocop-shopify (2.13.0) - rubocop (~> 1.50) + rubocop-shopify (2.14.0) + rubocop (~> 1.51) ruby-graphviz (1.2.5) rexml ruby-progressbar (1.13.0) @@ -557,7 +546,6 @@ GEM simplecov (~> 0.19) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - smart_properties (1.17.0) spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) @@ -620,7 +608,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.8.2) - unicode-display_width (2.4.2) + unicode-display_width (2.5.0) warden (1.2.9) rack (>= 2.0.9) web-console (4.2.0) @@ -670,7 +658,6 @@ DEPENDENCIES database_cleaner devise devise-bootstrap-views - erb_lint erubis exception_handler (~> 0.8.0.0) factory_bot_rails @@ -709,8 +696,8 @@ DEPENDENCIES rgl rqrcode rspec-rails - rubocop (~> 1.50) - rubocop-shopify + rubocop (~> 1.57) + rubocop-shopify (~> 2.14) rubyzip (~> 2.3.0) sass-rails (>= 6) selenium-webdriver From 4db8503c30fded667da004d611655ea7166289a4 Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:54:24 +0100 Subject: [PATCH 5/6] change setting for ClassMethodsDefinitions --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index f427fb0b7..8681903b3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,3 +7,6 @@ Layout/LineLength: Style/FrozenStringLiteralComment: EnforcedStyle: never + +Style/ClassMethodsDefinitions: + EnforcedStyle: self_class \ No newline at end of file From 1e50c5034cb3e14a691255f8f78ff74f6ea418b2 Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Wed, 15 Nov 2023 20:04:48 +0100 Subject: [PATCH 6/6] add missing new line at the end of file --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8681903b3..3f6a2ee1f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,4 +9,4 @@ Style/FrozenStringLiteralComment: EnforcedStyle: never Style/ClassMethodsDefinitions: - EnforcedStyle: self_class \ No newline at end of file + EnforcedStyle: self_class