New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Oct 29, 2018

Conversation

Projects
None yet
1 participant
@ryz310
Owner

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

@ryz310 ryz310 merged commit 3153919 into master Oct 29, 2018

6 checks passed

ci/circleci: build_on_ruby_2.3 Your tests passed on CircleCI!
Details
ci/circleci: build_on_ruby_2.4 Your tests passed on CircleCI!
Details
ci/circleci: build_on_ruby_2.5 Your tests passed on CircleCI!
Details
ci/circleci: build_on_ruby_latest Your tests passed on CircleCI!
Details
ci/circleci: rubocop Your tests passed on CircleCI!
Details
ci/circleci: verify_rubocop_challenge Your tests passed on CircleCI!
Details

@ryz310 ryz310 deleted the rubocop-challenge/Layout-AlignHash-20181028233018 branch Oct 29, 2018

@wafflebot wafflebot bot 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