Skip to content

Layout/AlignHash at Sun Oct 28 23:30:20 UTC 2018#97

Merged
ryz310 merged 1 commit into
masterfrom
rubocop-challenge/Layout-AlignHash-20181028233018
Oct 29, 2018
Merged

Layout/AlignHash at Sun Oct 28 23:30:20 UTC 2018#97
ryz310 merged 1 commit into
masterfrom
rubocop-challenge/Layout-AlignHash-20181028233018

Conversation

@ryz310
Copy link
Copy Markdown
Owner

@ryz310 ryz310 commented Oct 28, 2018

Rubocop challenge!

Layout/AlignHash

Description

Overview

Check that the keys, separators, and values of a multi-line hash
literal are aligned according to configuration. The configuration
options are:

  • key (left align keys, one space before hash rockets and values)
  • separator (align hash rockets and colons, right align keys)
  • table (left align keys, hash rockets, and values)

The treatment of hashes passed as the last argument to a method call
can also be configured. The options are:

  • always_inspect
  • always_ignore
  • ignore_implicit (without curly braces)
  • ignore_explicit (with curly braces)

Examples

# bad
{
  :foo => bar,
   :ba => baz
}
{
  :foo => bar,
  :ba  => baz
}

# good
{
  :foo => bar,
  :ba => baz
}
# bad
{
  :foo => bar,
  :ba => baz
}
{
  :foo => bar,
  :ba  => baz
}

# good
{
  :foo => bar,
   :ba => baz
}
# bad
{
  :foo => bar,
   :ba => baz
}

# good
{
  :foo => bar,
  :ba  => baz
}
# bad
{
  foo: bar,
   ba: baz
}
{
  foo: bar,
  ba:  baz
}

# good
{
  foo: bar,
  ba: baz
}
# bad
{
  foo: bar,
  ba: baz
}

# good
{
  foo: bar,
   ba: baz
}
# bad
{
  foo: bar,
  ba: baz
}

# good
{
  foo: bar,
  ba:  baz
}
# Inspect both implicit and explicit hashes.

# bad
do_something(foo: 1,
  bar: 2)

# bad
do_something({foo: 1,
  bar: 2})

# good
do_something(foo: 1,
             bar: 2)

# good
do_something(
  foo: 1,
  bar: 2
)

# good
do_something({foo: 1,
              bar: 2})

# good
do_something({
  foo: 1,
  bar: 2
})
# Ignore both implicit and explicit hashes.

# good
do_something(foo: 1,
  bar: 2)

# good
do_something({foo: 1,
  bar: 2})
# Ignore only implicit hashes.

# bad
do_something({foo: 1,
  bar: 2})

# good
do_something(foo: 1,
  bar: 2)
# Ignore only explicit hashes.

# bad
do_something(foo: 1,
  bar: 2)

# good
do_something({foo: 1,
  bar: 2})

Checklist

  • Operation check
  • Team agreement

Auto generated by rubocop_challenger

Auto generated by PR daikou

@ghost ghost assigned ryz310 Oct 28, 2018
@ryz310 ryz310 merged commit 3153919 into master Oct 29, 2018
@ryz310 ryz310 deleted the rubocop-challenge/Layout-AlignHash-20181028233018 branch October 29, 2018 00:50
@ghost ghost removed the in progress label Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant