35 Commits

Author SHA1 Message Date
David Rodríguez
4c6d894bc0 Bump RuboCop to 1.86.6
There were a few changes needed:

* Plugins are now specified through `plugin:` config keyword.
* All plugin gems need to be specified explicitly in Gemfile since they
  are no longer dependencies of plugins already specified explicitly.
* All plugin gems need to be updated in other to use the new APIs.
* One cop was renamed.
* New offenses safe to correct were corrected directly with `bundle exec
  rubocop -a`.
* New offenses unsafe to correct were added to the TODO configuration
  with `bundle exec rubocop --auto-gen-config --auto-gen-only-exclude
  --exclude-limit 1400 --no-auto-gen-timestamp`.
2025-10-27 11:30:33 +01:00
Maikel Linke
409492ce33 Explicitely require all rubocop extensions
I think that rspec-rails loaded the other extensions already but Rubocop
was suggesting these extensions to be loaded as well.

The alternative is to disable suggestions of new extensions but that
could hide new shiny tools when they become available.
2024-05-02 16:34:11 +10:00
David Cook
6f2b29eeec Move rspec styleguide to separate file 2024-02-28 16:17:49 +11:00
David Cook
0091a60a6e Install rubocop-rspec
Why not enforce more consistency in our specs also?

Some of them generated way too many violations, so I relaxed them a bit.
2024-02-23 12:03:55 +11:00
Maikel Linke
decab911bd Use relaxed Rubocop styleguide as basis
We then refine it with our own rules.
2022-02-25 10:44:32 +11:00
Maikel Linke
67aa3447da Automatically regenerate style todo list
We used to keep a manual file for metrics violations because the
automatic file didn't exclude on a file-by-file basis. But Rubocop has
an additional option these days so that we can generate that
automatically in the normal todo list.

The todo list was also out of date.
2021-12-10 09:29:20 +11:00
Maikel Linke
8f79fe2768 Use the same config on Code Climate as locally
We configured Code Climate to be aware of all open issues instead of
ignoring open issues via the rubocop todo lists. We were hoping that
Code Climate could give us some nice stats like progress if it's aware
of all our open issues. But the graphs don't tell us anything. So it's
better to have one source of truth for our open style issues and that is
our rubocop config in this repository. It contains two todo lists that
document all violations we would like to fix in the future but it's okay
to submit pull requests that don't fix those.

Instead of accepting new style issues in Code Climate, every pull
request with new violations has to add them to the rubocop config. I
hope that this will make rubocop more useful and encourage developers to
reduce code style debt.
2021-03-31 15:25:19 +11:00
Maikel Linke
8ee6d1c320 Add rubocop-rails gem
The rails cops used to be in the rubocop gem itself but moved into their
own gem recently. Our style guide refers to these cops though.
2020-01-10 08:59:44 +11:00
Maikel Linke
7ad40074a5 Make Code Climate show our real score ans split rubocop config
Our rubocop config hides all current violations. It allows us to have a
passing rubocop run on the current code and improve it gradually. It
detects new violations, but doesn't annoy us with all the existing ones.

Code Climate has its own way of remembering all current violations which
is more sophisticated than ours. The new config for Code Climate doesn't
hide any violations so that Code Climate can give us a realistic score
of code quality and warn us about every new violation.

Splitting the configuration into the main three parts gives a quicker
overview and makes maintaining the parts easier.
2018-11-05 10:19:30 +11:00
Maikel Linke
e798532a2f Add offending files to rubocop config
The file .rubocop_todo.yml is generated automatically and contains a
configuration to make all files pass. For a lot of cops it just lists
the offending files. But for some cops it sets a different metric.

Since we don't want these lax metrics, we override them in our config
file .rubocop.yml. This leads to a lot of offences again. This patch
lists all offending files for each cop to make rubocop pass. We can
improve the code over time and remove items from the list.
2018-11-05 10:11:35 +11:00
Pau Pérez Fabregat
fe149967e4 Merge pull request #2521 from luisramos0/cookies_in_engine
[OFN Domains] Breaking OFN into domains - POC cookies inside an engine
2018-10-15 10:03:30 +02:00
Matt-Yorkley
ebb03906cf Increase rubocop line limit to 100 2018-10-11 15:37:38 +01:00
Maikel
f0bb927020 Merge pull request #2734 from coopdevs/make-rubocop-useful
Get useful feedback from Rubocop Metrics cops
2018-09-23 19:48:05 +10:00
Pau Perez
0ac16ce096 Get useful feedback from Rubocop Metrics cops
One of the biggest pros of linters like Rubocop is to get valuable feedback to
help write better code. The way we have Rubocop configured now we don't prevent
new code from adhere improved code quality and this is specially important when
touching code that already suffers from complexity.

Without all Rubocop's Metrics cops enabled there's no way to get this insights
and write better code. This enables them while regenerating the
`.rubocop_todo.yml` to hide the current violations.

So, next time we touch existing code that we think could be simpler, we should
go to `.rubocop_todo.yml` and remove any occurrences of the file in question.
This way we could Rubocop's feedback right in the editor. This is tremendously
helpful when refactoring. It shows you where to start.
2018-09-19 19:27:40 +02:00
luisramos0
d170a4d489 New domain Web (rails engine) with the following features extracted from the main app:
- cookies banner
- cookies policy page
- cookies policy and privacy policy links in the footer
2018-09-17 16:05:32 +01:00
Pau Perez
1de13a5049 Favor #public_send over #send using Rubocop's cop
Devs keep using `#send` although that method does not preserve
private/protected visibility. Watching after this turned out to be quite
time-consuming while doing code review.

Currently, the Style/Send cop doesn't enforce `#public_send` however
(that's what we want). It simply discourages the use of #send. See
https://github.com/rubocop-hq/rubocop/pull/2081#issuecomment-292251650
for details. So a new entry on the Code Conventions doc has been added
to overcome this limitation:
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Code-Conventions#prefer-public_send-over-send
2018-08-30 18:48:45 +02:00
Kristina Lim
a494fb274e Disable rubocop cop Rails/ActiveRecordAliases
The methods :update! and :update (to replace :update_attributes! and
:update_attributes) were not added until Rails 4.

See this for more information:
https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Rails/ActiveRecordAliases
2018-08-06 18:12:43 +08:00
Maikel Linke
fcb9d1411f Exclude file that rubocop fails to parse 2018-05-08 15:19:44 +10:00
Maikel Linke
10d3abeaac Upgrade Rubocop to the latest version 2018-05-08 14:46:57 +10:00
Enrico Stano
00bdcd3948 Merge pull request #2045 from coopdevs/use-symbol-hash-syntax
Enable HashSyntax rubocop cop with symbol style
2018-01-31 09:30:06 +01:00
Pau Perez
cbfdfb43e3 Enable HashSyntax rubocop cop with symbol style
This enforces the ruby 1.9 symbol hash syntax and consistency among the
style of the keys.

  # bad
  {:a => 1, :b => 2}
  {c: 2, 'd' => 3} # should just use hash rockets

  # good
  {a: 1, b: 2}
  {:c => 3, 'd' => 4}

The .rubocop-todo.yml is also updated to keep track of the existing
violations.
2018-01-20 12:50:50 +01:00
Matt-Yorkley
62e4cbd052 Update rubocop.yml 2018-01-04 16:01:06 +00:00
Matt-Yorkley
d147d2035d Disable symbol array cop 2017-10-07 11:50:59 +01:00
Rob Harrington
3bb6d68adf Exclude node_modules from rubocop analysis
I don't need to see offences for node modules when I run rubocop locally
2017-07-21 11:06:16 +10:00
Pau Perez
cee24dcca7 Use indented style for multiline method calls
This enables the Rubocop's Style/MultilineMethodCallIndentation cop with
indentend enforced style. Which makes you split multiline method calls like:

  orders = Spree::Order
    .an_scope
    .another_scope
    .where(id: list_of_ids)

It also autofixes the current violations and updates the
rubocop_todo.yml
2017-07-12 10:40:53 +02:00
Rob Harrington
ce85027b79 Update rubocop_todo.yml using rubocop 0.49.1 2017-06-29 10:47:56 +10:00
Rob Harrington
d8a158c56d Rubocop: Update comment on Rails/DynamicFindBy, justifying Enabled: false 2017-06-24 13:37:47 +10:00
Rob Harrington
d26970d04c Rubocop: Move Style/ClassAndModuleChildren back to rubocop_todo.yml 2017-06-24 12:59:03 +10:00
Rob Harrington
e5340cb53a Rubocop: Correct Lint/UselessAssignment offences, disable for /spec in main config 2017-06-23 16:49:08 +10:00
Rob Harrington
f79dcaba15 Rubocop: Add Rails cops to config and todo 2017-06-23 16:49:08 +10:00
Rob Harrington
33a1d97d5e Rubocop: Disable Style/ClassAndModuleChildren in main config 2017-06-23 16:49:08 +10:00
Rob Harrington
fbdbbb980f Rubocop: Disable Lint/AmbiguousBlockAssociation in main config 2017-06-23 16:49:08 +10:00
Rob Harrington
4acb3f1962 Rubocop: Use Relaxed.Ruby.Style as starting point for settings
Updated .rubocop_todo.yml
2017-06-23 16:49:08 +10:00
Rob Harrington
5061d0c4cd Rubocop: Tweak config, and add todo file 2017-06-23 16:49:07 +10:00
Paul Mackay
98e5df6aac Add Rubocop config file 2016-02-09 06:00:05 +00:00