Commit Graph

29 Commits

Author SHA1 Message Date
Robin Ward 6f391b9387 Upgrade rubocop 2020-04-17 11:16:14 -04:00
Jarek Radosz 7ff889574d
DEV: Add rubocop-rspec (#9288)
This adds rubocop-rspec, and enables some cops that were either already passing or are passing now, after fixing them in this commit.

Some new cops are disabled for now, with annotation: "TODO" or "To be decided". Those either need to be discussed first, or require manual changes, or the number of found and fixed offenses is too large to bundle them up in a single PR.

Includes:

* DEV: Update rubocop's `TargetRubyVersion` to 2.6
* DEV: Enable RSpec/VoidExpect
* DEV: Enable RSpec/SharedContext
* DEV: Enable RSpec/EmptyExampleGroup (Removed an obsolete empty spec file)
* DEV: Enable RSpec/ItBehavesLike
* DEV: Remove RSpec/ScatteredLet (It's too strict, as it doesn't recognize fab! as a let-like)
* DEV: Remove RSpec/MultipleExpectations
2020-03-27 17:35:40 +01:00
Jarek Radosz d21d80198c
DEV: Update rubocop-discourse (#9270)
Includes:
* DEV: Use `eq_time` matcher
2020-03-26 16:32:41 +01:00
Robin Ward 812119f673 This rule was removed from Rubocop due to different behavior in Ruby 3.
See: https://github.com/rubocop-hq/rubocop/issues/7641
2020-02-19 13:44:20 -05:00
Martin Brennan ce03092e61 Fix DiscourseCops/NoURIEscapeEncode errors and re-enable 2019-12-12 14:54:26 +10:00
Martin Brennan 44e0c9e0b4 Temporarily disable DiscourseCops/NoURIEscapeEncode for plugins 2019-12-12 14:40:13 +10:00
Martin Brennan 9c1e0b8bd2 bump rubocop-discourse to 1.0.2 for NoURIEscapeEncode cop 2019-12-12 14:30:27 +10:00
Sam Saffron 0c52537f10 DEV: update rubocop to version 0.77
We like to stay as close as possible to latest with rubocop cause the cops
get better.

This update required some code changes, specifically the default is to avoid
explicit returns where implicit is done

Also this renames a few rules
2019-12-10 11:48:39 +11:00
Joffrey JAFFEUX 0d3d2c43a0
DEV: s/\$redis/Discourse\.redis (#8431)
This commit also adds a rubocop rule to prevent global variables.
2019-12-03 10:05:53 +01:00
David Taylor 0350247130 DEV: Exclude plugin specs when running chdir cop 2019-11-18 16:00:18 +00:00
David Taylor eaf6096890 DEV: Use rubocop-discourse gem to add custom chdir cop
Followup to b27e009655
2019-11-18 15:39:41 +00:00
Penar Musaraj be15abcf7f DEV: Add RedundantReturn style check to Rubocop 2019-11-14 14:42:36 -05:00
David Taylor b27e009655 DEV: Temporarily remove NoChdir cop
We inherit this rubocop config from plugins and other projects, so the `require` line does not work reliably.
2019-11-13 10:26:40 +00:00
David Taylor 9fea43e46a
DEV: Remove use of `cd` in the app (#8337)
`FileUtils.cd` and `Dir.chdir` cause the working directory to change for the entire process. We run sidekiq jobs, hijacked requests and deferred jobs in threads, which can make working directory changes have unintended side-effects.

- Add a rubocop rule to warn about usage of Dir.chdir and FileUtils.cd
- Added rubocop:disable for scripts used outside the app
- Refactored code using cd to use alternative methods
- Temporarily skipped the rubocop check for lib/backup_restore. This will require more complex refactoring, so I will create a separate PR for review
2019-11-13 09:57:39 +00:00
Penar Musaraj 4d1d8b40db DEV: Re-enable Rubocop checks for plugins
But exclude gems in plugins.
2019-07-30 09:09:00 -04:00
Penar Musaraj 73bce82c82 Exclude plugins from RuboCop checks
Since official plugins are now in the discourse_test image, rubocop catches issues in plugins.

This is a temporary measure.
2019-06-14 10:06:26 -04:00
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00
Régis Hanol 3c9c95ac83 Update Rubocop to 0.60 2018-12-04 10:48:16 +01:00
David Taylor 9248ad1905 DEV: Enable `Style/SingleLineMethods` and `Style/Semicolon` in Rubocop (#6717) 2018-12-04 11:48:13 +08:00
Guo Xiang Tan df2d02a7bc Revert "Enable `Style/BlockDelimiters` rule."
This reverts commit 3c22fb6b70.
2018-11-30 10:59:45 +08:00
Guo Xiang Tan 3c22fb6b70 Enable `Style/BlockDelimiters` rule. 2018-11-30 10:18:15 +08:00
Guo Xiang Tan 8dc1463ab3 Enable `Lint/ShadowingOuterLocalVariable` for Rubocop. 2018-09-04 10:16:42 +08:00
Sam 95968380bc correct rules 2018-03-13 18:00:22 +11:00
Gerhard Schlager a6b0e627cd exclude public directory from RuboCop 2017-11-02 20:31:04 +01:00
Guo Xiang Tan e0d37c1f74 Add debugger Rubocop lint. 2017-08-08 19:16:40 +09:00
Guo Xiang Tan aab0b06cbe Rubocop should ignore schema.rb. 2017-08-08 14:29:44 +09:00
David Taylor 4b00fdbc5b Exclude bundle directory when running rubocop (#5016)
* Exclude bundle directory when running rubocop

* Include the default excludes as well
2017-08-01 12:47:09 -04:00
Guo Xiang Tan 5012d46cbd Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
Gerhard Schlager 781f364d86
Make RuboCop and RubyMine less annoying 2017-05-29 20:59:14 +02:00