From c8b5565a6612ddb6bd89f3c5c1179db202ac73e0 Mon Sep 17 00:00:00 2001 From: Brian Hawley Date: Wed, 17 Aug 2022 08:18:25 -0700 Subject: [PATCH] Update rubocop to 1.35.0 - General bundle update. - Update the docs too. --- Gemfile | 2 +- Gemfile.lock | 10 +-- config/contents/layout/line_length.md | 1 + config/contents/lint/erb_new_arguments.md | 17 ++-- config/contents/style/hash_syntax.md | 15 ++++ config/contents/style/magic_comment_format.md | 90 +++++++++++++++++++ 6 files changed, 120 insertions(+), 15 deletions(-) create mode 100644 config/contents/style/magic_comment_format.md diff --git a/Gemfile b/Gemfile index 69c63cba..12416a91 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ source 'https://rubygems.org' gem "activesupport", require: false gem "parser" gem "pry", require: false -gem "rubocop", "1.34.1", require: false +gem "rubocop", "1.35.0", require: false gem "rubocop-i18n", require: false gem "rubocop-graphql", require: false gem "rubocop-minitest", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 373c6e1c..6784b43d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,7 +14,7 @@ GEM concurrent-ruby (~> 1.0) json (2.6.2) method_source (1.0.0) - minitest (5.16.2) + minitest (5.16.3) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) @@ -39,14 +39,14 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.34.1) + rubocop (1.35.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.20.0, < 2.0) + rubocop-ast (>= 1.20.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) @@ -77,7 +77,7 @@ GEM rubocop-thread_safety (0.4.4) rubocop (>= 0.53.0) ruby-progressbar (1.11.0) - test-prof (1.0.9) + test-prof (1.0.10) tzinfo (2.0.5) concurrent-ruby (~> 1.0) unicode-display_width (2.2.0) @@ -91,7 +91,7 @@ DEPENDENCIES pry rake rspec - rubocop (= 1.34.1) + rubocop (= 1.35.0) rubocop-graphql rubocop-i18n rubocop-minitest diff --git a/config/contents/layout/line_length.md b/config/contents/layout/line_length.md index 3686fb2d..e98004ee 100644 --- a/config/contents/layout/line_length.md +++ b/config/contents/layout/line_length.md @@ -15,6 +15,7 @@ are recommended to further format the broken lines. (Many of these are enabled by default.) * ArgumentAlignment +* ArrayAlignment * BlockAlignment * BlockDelimiters * BlockEndNewline diff --git a/config/contents/lint/erb_new_arguments.md b/config/contents/lint/erb_new_arguments.md index 12653336..00d5786b 100644 --- a/config/contents/lint/erb_new_arguments.md +++ b/config/contents/lint/erb_new_arguments.md @@ -1,18 +1,17 @@ This cop emulates the following Ruby warnings in Ruby 2.6. +```console % cat example.rb ERB.new('hi', nil, '-', '@output_buffer') % ruby -rerb example.rb -example.rb:1: warning: Passing safe_level with the 2nd argument of -ERB.new is deprecated. Do not use it, and specify other arguments as -keyword arguments. -example.rb:1: warning: Passing trim_mode with the 3rd argument of -ERB.new is deprecated. Use keyword argument like -ERB.new(str, trim_mode:...) instead. -example.rb:1: warning: Passing eoutvar with the 4th argument of ERB.new -is deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) -instead. +example.rb:1: warning: Passing safe_level with the 2nd argument of ERB.new is +deprecated. Do not use it, and specify other arguments as keyword arguments. +example.rb:1: warning: Passing trim_mode with the 3rd argument of ERB.new is +deprecated. Use keyword argument like ERB.new(str, trim_mode:...) instead. +example.rb:1: warning: Passing eoutvar with the 4th argument of ERB.new is +deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) instead. +``` Now non-keyword arguments other than first one are softly deprecated and will be removed when Ruby 2.5 becomes EOL. diff --git a/config/contents/style/hash_syntax.md b/config/contents/style/hash_syntax.md index 00943808..c77beee6 100644 --- a/config/contents/style/hash_syntax.md +++ b/config/contents/style/hash_syntax.md @@ -23,6 +23,7 @@ The supported styles are: * always - forces use of the 3.1 syntax (e.g. {foo:}) * never - forces use of explicit hash literal value * either - accepts both shorthand and explicit use of hash literal value +* consistent - like "always", but will avoid mixing styles in a single hash ### Example: EnforcedStyle: ruby19 (default) # bad @@ -83,3 +84,17 @@ The supported styles are: # good {foo:, bar:} + +### Example: EnforcedShorthandSyntax: consistent + + # bad + {foo: , bar: bar} + + # good + {foo:, bar:} + + # bad + {foo: , bar: baz} + + # good + {foo: foo, bar: baz} diff --git a/config/contents/style/magic_comment_format.md b/config/contents/style/magic_comment_format.md new file mode 100644 index 00000000..40ca006a --- /dev/null +++ b/config/contents/style/magic_comment_format.md @@ -0,0 +1,90 @@ +Ensures magic comments are written consistently throughout your code base. +Looks for discrepancies in separators (`-` vs `_`) and capitalization for +both magic comment directives and values. + +Required capitalization can be set with the `DirectiveCapitalization` and +`ValueCapitalization` configuration keys. + +NOTE: If one of these configuration is set to nil, any capitalization is allowed. + +### Example: EnforcedStyle: snake_case (default) + # The `snake_case` style will enforce that the frozen string literal + # comment is written in snake case. (Words separated by underscores) + # bad + # frozen-string-literal: true + + module Bar + # ... + end + + # good + # frozen_string_literal: false + + module Bar + # ... + end + +### Example: EnforcedStyle: kebab_case + # The `kebab_case` style will enforce that the frozen string literal + # comment is written in kebab case. (Words separated by hyphens) + # bad + # frozen_string_literal: true + + module Baz + # ... + end + + # good + # frozen-string-literal: true + + module Baz + # ... + end + +### Example: DirectiveCapitalization: lowercase (default) + # bad + # FROZEN-STRING-LITERAL: true + + # good + # frozen-string-literal: true + +### Example: DirectiveCapitalization: uppercase + # bad + # frozen-string-literal: true + + # good + # FROZEN-STRING-LITERAL: true + +### Example: DirectiveCapitalization: nil + # any capitalization is accepted + + # good + # frozen-string-literal: true + + # good + # FROZEN-STRING-LITERAL: true + +### Example: ValueCapitalization: nil (default) + # any capitalization is accepted + + # good + # frozen-string-literal: true + + # good + # frozen-string-literal: TRUE + +### Example: ValueCapitalization: lowercase + # when a value is not given, any capitalization is accepted + + # bad + # frozen-string-literal: TRUE + + # good + # frozen-string-literal: TRUE + +### Example: ValueCapitalization: uppercase + # bad + # frozen-string-literal: true + + # good + # frozen-string-literal: TRUE