Skip to content
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

Apply Rubocop rules in ERB files #4102

Merged
merged 16 commits into from
Feb 8, 2021
Merged

Conversation

dependabot-preview[bot]
Copy link
Contributor

@dependabot-preview dependabot-preview bot commented Aug 24, 2020

Objectives

  • Make sure the ERB code and our Ruby code follow the same conventions
  • Apply those convetions to make the code more consistent
  • Apply ClosingErbTagIndent ERB Lint rule to make ERB blocks consistent

Gem update details

Bumps erb_lint from 0.0.28 to 0.0.35.

Release notes

Sourced from erb_lint's releases.

v0.0.35

  • drop support for ruby < 2.5
  • add support for rubocop >= 0.87

v0.0.30

No release notes provided.

Commits
  • fa0fda3 bump version
  • 1944354 Merge pull request #182 from Shopify/drop-ruby-2.4
  • 3d6801e use unreleased rubocop-shopify version
  • 999a49c debug CI
  • 22b7813 shopify cops are not compatible with rubocop 0.89 yet
  • ec8a50b inherit styleguide from gem instead of from config file
  • c83363c Ruby 2.4 is EOL
  • 73c9a6e Merge pull request #179 from marcandre/rubocop_v1
  • f3b6b0a Update for RuboCop v0.87+
  • 87b62d8 Avoid redundant recalculations
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Note: This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

You can always request more updates by clicking Bump now in your Dependabot dashboard.

Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
  • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot dashboard:

  • Update frequency (including time of day and day of week)
  • Pull request limits (per update run and/or open at any time)
  • Automerge options (never/patch/minor, and dev/runtime dependencies)
  • Out-of-range updates (receive only lockfile updates, if desired)
  • Security updates (receive only security updates, if desired)

@dependabot-preview dependabot-preview bot added the dependencies Pull requests that updates a dependency label Aug 24, 2020
@dependabot-preview dependabot-preview bot force-pushed the dependabot/bundler/erb_lint-0.0.35 branch from b409980 to ff47934 Compare August 25, 2020 13:33
@dependabot-preview dependabot-preview bot force-pushed the dependabot/bundler/erb_lint-0.0.35 branch 2 times, most recently from 2bb5d22 to 347541e Compare September 28, 2020 19:50
@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch 4 times, most recently from 6a666ef to b164efa Compare September 30, 2020 20:56
Copy link

@houndci-bot houndci-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

.rubocop.yml: Rails/SafeNavigation has the wrong namespace - should be Style
.rubocop.yml: Rails/SafeNavigation has the wrong namespace - should be Style
Error: unrecognized cop Performance/CompareWithBlock found in .rubocop.yml, unrecognized cop Performance/DoubleStartEndWith found in .rubocop.yml, unrecognized cop Performance/EndWith found in .rubocop.yml, unrecognized cop Performance/StartWith found in .rubocop.yml, unrecognized cop Rails/Date found in .rubocop.yml, unrecognized cop Rails/EnvironmentComparison found in .rubocop.yml, unrecognized cop Rails/Presence found in .rubocop.yml, unrecognized cop Rails/TimeZone found in .rubocop.yml, unrecognized cop Rails/UnknownEnv found in .rubocop.yml, unrecognized cop Rails/CreateTableWithTimestamps found in .rubocop.yml, unrecognized cop Rails/DynamicFindBy found in .rubocop.yml, unrecognized cop Rails/EnumUniqueness found in .rubocop.yml, unrecognized cop Rails/FindBy found in .rubocop.yml, unrecognized cop Rails/FindEach found in .rubocop.yml, unrecognized cop Rails/HasAndBelongsToMany found in .rubocop.yml, unrecognized cop Rails/HasManyOrHasOneDependent found in .rubocop.yml, unrecognized cop Rails/InverseOf found in .rubocop.yml, unrecognized cop Rails/NotNullColumn found in .rubocop.yml, unrecognized cop Rails/OutputSafety found in .rubocop.yml, unrecognized cop Rails/PluralizationGrammar found in .rubocop.yml, unrecognized cop Rails/RelativeDateConstant found in .rubocop.yml, unrecognized cop Rails/RequestReferer found in .rubocop.yml, unrecognized cop Rails/ReversibleMigration found in .rubocop.yml, unrecognized cop Rails/SaveBang found in .rubocop.yml, unrecognized cop Rails/SkipsModelValidations found in .rubocop.yml, unrecognized cop Rails/Validation found in .rubocop.yml

@javierm javierm changed the title Bump erb_lint from 0.0.28 to 0.0.35 Apply Rubocop rules in ERB files Oct 1, 2020
@javierm javierm self-assigned this Oct 1, 2020
@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch from bf8ca87 to 425c855 Compare October 1, 2020 09:26
Copy link
Member

@javierm javierm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hound only supports ERB Lint 0.0.29, so we aren't going to merge this pull request for now.

@javierm javierm added this to Reviewing in Consul Democracy via automation Oct 14, 2020
@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch from 425c855 to 0d7f989 Compare October 14, 2020 17:31
Copy link

@houndci-bot houndci-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

Error: unrecognized cop Rails/ContentTag found in .rubocop.yml
Error: unrecognized cop Rails/ContentTag found in .rubocop.yml

@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch from 0d7f989 to 22861c9 Compare October 25, 2020 11:38
@javierm
Copy link
Member

javierm commented Oct 25, 2020

Since version 0.0.29 is not compatible with Rubocop 0.87+, we're upgrading to verstion 0.0.35.

@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch 2 times, most recently from 5ac3fbb to d87db0f Compare October 25, 2020 12:39
@javierm javierm changed the base branch from master to dependabot/bundler/rubocop-rails-2.6.0 October 25, 2020 12:39
@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch from d87db0f to 1ca10ba Compare October 25, 2020 12:49
@javierm javierm force-pushed the dependabot/bundler/rubocop-rails-2.6.0 branch from 34e9f74 to 4c69455 Compare October 25, 2020 12:58
@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch from 1ca10ba to 270686a Compare October 25, 2020 12:58
@javierm javierm force-pushed the dependabot/bundler/rubocop-rails-2.6.0 branch 2 times, most recently from c6e0dde to 4658e18 Compare October 26, 2020 10:27
Base automatically changed from dependabot/bundler/rubocop-rails-2.6.0 to master October 26, 2020 11:04
@dependabot-preview
Copy link
Contributor Author

A newer version of erb_lint exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.

dependabot-preview bot and others added 2 commits February 5, 2021 16:24
Bumps [erb_lint](https://github.com/Shopify/erb-lint) from 0.0.28 to 0.0.35.
- [Release notes](https://github.com/Shopify/erb-lint/releases)
- [Commits](Shopify/erb-lint@v0.0.28...v0.0.35)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Just like we do for the rest of the gems.
@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch 2 times, most recently from bca174a to 5090cbb Compare February 5, 2021 15:47
Note this rule does still allow us to add new lines after opening tags;
it just makes sure that if we do, we also add it in closing tags.
Likewise, if we don't add it in the opening tag, it forces us not to add
it in the closing tag either.

I don't have a strong preference about either style; in these cases I've
chosen the latter because it seemed more common in our code.
@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch 2 times, most recently from 652194e to ebda95e Compare February 5, 2021 16:45
So now we remove duplication between .rubocop.yml and the rubocop rules
defined for erblint. Having the rules in two places led to some
mistakes, like renaming Layout/Tab to Layout/IndentationStyle in
`.rubocop.yml` but forgetting to do so in `.erb-lint.yml`.

This also means we can use the EnforcedStyle options for
Layout/SpaceInsideHashLiteralBraces in views as well.

We couldn't implement this feature earlier because it required Ruby 2.4
and due to incompatibilities between versions of erb_lint and versions
of rubocop.

There are some rules which do not apply to ERB files and so we're
disabling them.

* Layout/LineLength, Layout/TrailingEmptyLines and Lint/UselssAssignment
  generate false positives
* Rails/OutputSafety is redundant since its functionality is already
  covered by ERB Lint ErbSafety linter
Note that in Ruby files this rule allows vertical alignment, but doesn't
seem to do the same in ERB. Since we only used vertical alignment in one
place, and that place also had an unneeded extra space on every aligned
line, I've decided to change the code in that place and follow the rule.
This way we can simplify the code and don't have to rely on `.try`
statements which are confusing and so we don't allow them in the
`Rails/SafeNavigation` Rubocop rule.
The association `organization.user` returns `nil` when the user is
hidden.

This was discovered thanks to the `Style/AndOr` rule. We were using
`and` and `||` on the same line, which is confusing.
We were doing it manually, but Capybara offers an option which does the
exact same thing.

This way we also apply the NoJavascriptTagHelper ERB rule, which
reported one error in the `disable_animations_in_tests` partial.
@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch from ebda95e to b214205 Compare February 5, 2021 16:46
Copy link
Member

@javierm javierm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we need to upgrade to 0.0.35 to keep Rubocop compatibility, the fact that Hound doesn't support this version is secondary IMHO. So we may proceed with the upgrade.

Consul Democracy automation moved this from Reviewing to Testing Feb 5, 2021
Copy link
Member

@javierm javierm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to upgrade to version 0.0.35 in order to get Rubocop compatibility, so we're upgrading even if Hound does not support this version.

@javierm javierm moved this from Testing to Reviewing in Consul Democracy Feb 5, 2021
@taitus taitus self-assigned this Feb 8, 2021
@javierm javierm force-pushed the dependabot/bundler/erb_lint-0.0.35 branch from a63a13c to 00656e2 Compare February 8, 2021 14:19
Consul Democracy automation moved this from Reviewing to Testing Feb 8, 2021
@javierm javierm merged commit 63820fb into master Feb 8, 2021
Consul Democracy automation moved this from Testing to Release 1.3.0 Feb 8, 2021
@javierm javierm deleted the dependabot/bundler/erb_lint-0.0.35 branch February 8, 2021 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that updates a dependency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants