@@ -5180,6 +5180,7 @@ The supported styles are:
51805180* always - forces use of the 3.1 syntax (e.g. {foo:})
51815181* never - forces use of explicit hash literal value
51825182* either - accepts both shorthand and explicit use of hash literal value
5183+ * consistent - like "always", but will avoid mixing styles in a single hash
51835184
51845185=== Examples
51855186
@@ -5268,6 +5269,23 @@ The supported styles are:
52685269{foo:, bar:}
52695270----
52705271
5272+ ==== EnforcedShorthandSyntax: consistent
5273+
5274+ [source,ruby]
5275+ ----
5276+ # bad
5277+ {foo: , bar: bar}
5278+
5279+ # good
5280+ {foo:, bar:}
5281+
5282+ # bad
5283+ {foo: , bar: baz}
5284+
5285+ # good
5286+ {foo: foo, bar: baz}
5287+ ----
5288+
52715289=== Configurable attributes
52725290
52735291|===
@@ -5279,7 +5297,7 @@ The supported styles are:
52795297
52805298| EnforcedShorthandSyntax
52815299| `always`
5282- | `always`, `never`, `either`
5300+ | `always`, `never`, `either`, `consistent`
52835301
52845302| UseHashRocketsWithSymbolValues
52855303| `false`
@@ -6250,6 +6268,161 @@ some_str = 'ala' \
62506268 'bala'
62516269----
62526270
6271+ == Style/MagicCommentFormat
6272+
6273+ |===
6274+ | Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
6275+
6276+ | Pending
6277+ | Yes
6278+ | Yes
6279+ | 1.35
6280+ | -
6281+ |===
6282+
6283+ Ensures magic comments are written consistently throughout your code base.
6284+ Looks for discrepancies in separators (`-` vs `_`) and capitalization for
6285+ both magic comment directives and values.
6286+
6287+ Required capitalization can be set with the `DirectiveCapitalization` and
6288+ `ValueCapitalization` configuration keys.
6289+
6290+ NOTE: If one of these configuration is set to nil, any capitalization is allowed.
6291+
6292+ === Examples
6293+
6294+ ==== EnforcedStyle: snake_case (default)
6295+
6296+ [source,ruby]
6297+ ----
6298+ # The `snake_case` style will enforce that the frozen string literal
6299+ # comment is written in snake case. (Words separated by underscores)
6300+ # bad
6301+ # frozen-string-literal: true
6302+
6303+ module Bar
6304+ # ...
6305+ end
6306+
6307+ # good
6308+ # frozen_string_literal: false
6309+
6310+ module Bar
6311+ # ...
6312+ end
6313+ ----
6314+
6315+ ==== EnforcedStyle: kebab_case
6316+
6317+ [source,ruby]
6318+ ----
6319+ # The `kebab_case` style will enforce that the frozen string literal
6320+ # comment is written in kebab case. (Words separated by hyphens)
6321+ # bad
6322+ # frozen_string_literal: true
6323+
6324+ module Baz
6325+ # ...
6326+ end
6327+
6328+ # good
6329+ # frozen-string-literal: true
6330+
6331+ module Baz
6332+ # ...
6333+ end
6334+ ----
6335+
6336+ ==== DirectiveCapitalization: lowercase (default)
6337+
6338+ [source,ruby]
6339+ ----
6340+ # bad
6341+ # FROZEN-STRING-LITERAL: true
6342+
6343+ # good
6344+ # frozen-string-literal: true
6345+ ----
6346+
6347+ ==== DirectiveCapitalization: uppercase
6348+
6349+ [source,ruby]
6350+ ----
6351+ # bad
6352+ # frozen-string-literal: true
6353+
6354+ # good
6355+ # FROZEN-STRING-LITERAL: true
6356+ ----
6357+
6358+ ==== DirectiveCapitalization: nil
6359+
6360+ [source,ruby]
6361+ ----
6362+ # any capitalization is accepted
6363+
6364+ # good
6365+ # frozen-string-literal: true
6366+
6367+ # good
6368+ # FROZEN-STRING-LITERAL: true
6369+ ----
6370+
6371+ ==== ValueCapitalization: nil (default)
6372+
6373+ [source,ruby]
6374+ ----
6375+ # any capitalization is accepted
6376+
6377+ # good
6378+ # frozen-string-literal: true
6379+
6380+ # good
6381+ # frozen-string-literal: TRUE
6382+ ----
6383+
6384+ ==== ValueCapitalization: lowercase
6385+
6386+ [source,ruby]
6387+ ----
6388+ # when a value is not given, any capitalization is accepted
6389+
6390+ # bad
6391+ # frozen-string-literal: TRUE
6392+
6393+ # good
6394+ # frozen-string-literal: TRUE
6395+ ----
6396+
6397+ ==== ValueCapitalization: uppercase
6398+
6399+ [source,ruby]
6400+ ----
6401+ # bad
6402+ # frozen-string-literal: true
6403+
6404+ # good
6405+ # frozen-string-literal: TRUE
6406+ ----
6407+
6408+ === Configurable attributes
6409+
6410+ |===
6411+ | Name | Default value | Configurable values
6412+
6413+ | EnforcedStyle
6414+ | `snake_case`
6415+ | `snake_case`, `kebab_case`
6416+
6417+ | DirectiveCapitalization
6418+ | `lowercase`
6419+ | String
6420+
6421+ | ValueCapitalization
6422+ | `<none>`
6423+ |
6424+ |===
6425+
62536426== Style/MapCompactWithConditionalBlock
62546427
62556428|===
0 commit comments