KEMBAR78
Commas before closing brackets do not look consistent · Issue #10971 · rubocop/rubocop · GitHub
Skip to content

Commas before closing brackets do not look consistent #10971

@dmitrytrager

Description

@dmitrytrager

Rubocop has several style cops related to trailing commas. The meaning of trailing commas is often to allow adding new method arguments or structure elements without changing previous ones.

However, having syntax like this I won't be able to add new argument at the end without changing lines with existing arguments.

Should we disable comma before closing brackets?


Expected behavior

Commas right before closing brackets should not be allowed

Actual behavior

some_method(a: "b",
  c: "d",)

is a valid syntax

Steps to reproduce the problem

  1. Use this cop
Style/TrailingCommaInArguments:
  EnforcedStyleForMultiline: consistent_comma
  1. Add code described above
  2. Run rubocop

RuboCop version

$ bin/rubocop -V
1.31.2 (using Parser 3.1.2.0, rubocop-ast 1.18.0, running on ruby 3.1.2 x86_64-darwin21)
  - rubocop-performance 1.11.5
  - rubocop-rails 2.12.4
  - rubocop-rspec 2.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleIssues that haven't been active in a while

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions