Commit Graph

14 Commits

Author SHA1 Message Date
Javi Martín
995f7036de Run every linter separately in Github Actions
The main reason for this change is that Pronto doesn't run in pull
requests opened by external contributors, and we haven't found how to
fix this issue.

Another reason is that Pronto only detects issues in the lines where the
changes are done, but sometimes we introduce issues related to other
lines and those aren't detected by Pronto. Also, when adding or changing
Rubocop rules, or when we update Rubocop, Pronto doesn't check whether
those rules are applied in every Ruby and ERB file, and we sometimes
forget to do so (particularly in ERB files).

So, from now, the linters will check all the code in every pull request.

Note we're now excluding the `vendor` folder in our linters because the
`setup-ruby` action actions generates a `vendor/bundle/` folder with all
our gem dependencies, and we don't want to check those files.
2024-06-18 19:11:55 +02:00
Javi Martín
94145f4d09 Don't check ERB Lint ErbSafety in files using raw
We're excluding these files because they use `raw` to render content
than only administrators can edit, and we trust administrators not to
provide unsafe HTML. We should definitely sanitize them at some point
but, at the same time, we should also try to keep compatibility in
installations taking advantage of `raw`.

Also note that ERB Lint does not allow customizing the severity of a
linter; if it ever does, we'll use the severity rule instead of
excluding files.
2024-06-18 18:27:32 +02:00
dependabot[bot]
21d39bac62 Bump rubocop-rails from 2.20.2 to 2.21.2
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.20.2 to 2.21.2.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.20.2...v2.21.2)

---
updated-dependencies:
- dependency-name: rubocop-rails
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Note version 2.21.0 relaxes the default `Include` path for
`Rails/FindEach`, and so this version can find and correct offenses
outside the `app/models/` folder [1].

Also note this version replaces `unless something.include?` with `if
something.exclude?`; since we don't use the `exclude?` method anywhere,
we're removing the `include?` method from the list of methods checked by
this cop.

Finally, the Rails/HttpStatus method now returns a false positive when
rendering a dashboard partial and passing the `status` variable. In
order to avoid this issue, we could change the name of the local
variable or move the partial to a component, but for now we're simply
excluding these files for this cop.

[1] https://github.com/rubocop/rubocop-rails/pull/1059/commits/0066b3505

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 14:22:09 +01:00
Javi Martín
99b0ef07f2 Enable CommentSyntax ERB Linter
It's a default linter in erb_lint 0.3.0, and it's useful during
development since I'm always unsure about the right way to add ERB
comments.
2023-03-20 17:07:09 +01:00
Javi Martín
4ddcfde529 Explicitly enable ERB linters
I thought SelfClosingTag was enabled since it was on the list and the
`enabled: false` got lost among all the `enabled: true`. ERB Lint 0.1
and later will also add RequireInputAutocomplete as a default linter,
and we're not interested in it, at least for now.

So, just like we do for Rubocop, we're disabling all linters and
enabling the ones we use explicitly.
2023-03-20 17:06:05 +01:00
Javi Martín
b214205d8f Use Capybara to disable animations in tests
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.
2021-02-05 17:46:23 +01:00
Javi Martín
32ef8ff301 Unify Ruby and ERB Rubocop rules
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
2021-02-05 17:45:50 +01:00
Javi Martín
f864156b21 Add and apply ClosingErbTagIndent ERB Lint rule
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.
2021-02-05 17:39:42 +01:00
Javi Martín
b1b449b187 Add rubocop and erb-lints rules for output safetey
This way we make sure we won't add `html_safe` or `raw` calls in the
future.

I'm excluding `text_with_links_helpers` for this check, because in this
situation the use of `html_safe` is justified: we check the original
input is safe, and we're only adding link tags to raw URLs.
2019-10-08 19:10:13 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
ee8426c5b5 Indent with spaces instead of tabs 2019-09-10 20:02:15 +02:00
Javi Martín
347fc21cf0 Fix trailing whitespace 2019-09-10 19:21:03 +02:00
Javi Martín
4ab535dec4 Remove comma inside a HTML tag
The typo was detected thanks to erb-lint SpaceInHtmlTag rule.
2019-08-27 17:22:22 +02:00
Javi Martín
f30afab9e3 Add ERB Lint configuration file
The rubocop linter cannot use the `rubocop_config` option because it's
not compatible with Ruby 2.3. So we're setting the rubocop rules
manually.
2019-03-20 14:35:40 +01:00