summaryrefslogtreecommitdiff
path: root/spec/rubocop
Commit message (Collapse)AuthorAgeFilesLines
* Fix InjectEnterpriseEditionModule cop for qa/Yorick Peterse2019-08-281-0/+19
| | | | | | | This ensures the InjectEnterpriseEditionModule cop is able to detect the prepend patterns used in the qa/ directory. Previously it would not detect them as all EE QA modules reside in QA::EE, and not the top-level EE namespace.
* Replace it_behaves_like with include_examplesadd-rubocop-check-for-be-successVitali Tatarintev2019-08-281-8/+8
| | | | | | Improve specs output readability by replacing `it_behaves_like` with `include_examples` in `BeSuccessMatcher`
* Remove Rubocop::SpecHelper fileVitali Tatarintev2019-08-281-3/+0
|
* Inline shared examples for BeSuccessMatcherVitali Tatarintev2019-08-281-40/+31
| | | | | Former shared examples were used only once. Inlining them makes tests more clear.
* Refactor BeSuccessMatcher specs for readabilityVitali Tatarintev2019-08-281-33/+32
|
* Utilize Rubocop's Include for BeSuccessMatcherVitali Tatarintev2019-08-281-26/+8
| | | | | Use Rubocop's Include instead of manually checking the matcher in controllers specs.
* Add support of not_to/to_not to BeSuccessMatcherVitali Tatarintev2019-08-281-2/+18
| | | | | | | | | | | | | | BeSuccessMatcher now supports following examples: ``` expect(response).to be_success expect(response).to_not be_success expect(response).not_to be_success is_expected.to be_success is_expected.to_not be_success is_expected.not_to be_success ```
* Refactor BeSuccessMatcher specsVitali Tatarintev2019-08-281-36/+25
|
* Replace double quotes with single quotesVitali Tatarintev2019-08-281-9/+9
|
* Enable frozen string literalVitali Tatarintev2019-08-281-0/+2
|
* Autocorrect `be_success` to `be_successful`Vitali Tatarintev2019-08-281-0/+10
|
* Add Rubocop check to avoid using `be_success`Vitali Tatarintev2019-08-281-0/+77
| | | | | | | | | | | Prevent using `be_success` call in controller specs to avoid getting following deprecation warning: ``` DEPRECATION WARNING: The success? predicate is deprecated and will be removed in Rails 6.0. Please use successful? as provided by Rack::Response::Helpers. ```
* Utilize RuboCop's Include/Exclude configPeter Leitzen2019-08-263-46/+8
| | | | Stop checking the file location programmatically.
* Adds cop to enforce string limits on migrationsMayra Cabrera2019-08-231-0/+268
| | | | | | | This cop will analyze migrations that add columns with string, and report an offense if the string has no limit enforced Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/64505
* Add RSpec/TopLevelDescribePath copSean McGivern2019-08-011-0/+67
| | | | | | | | The RSpec/FilePath cop checks that a spec file's path is correct, but only if the file describes a constant. We want to check, for any file with a top-level `describe`, whether the file path ends in `_spec.rb`. We don't care what comes before that; just that it will be executed by RSpec at all.
* Extend cop for verifying injecting of EE modulesYorick Peterse2019-07-301-42/+102
| | | | | | | | | This extends the InjectEnterpriseEditionModule RuboCop cop so that it verifies the following: 1. The line number the injection occurs on (as before). 2. The method used (e.g. prepend instead of prepend_if_ee). 3. The argument type passed when using the new module injection methods.
* Change element_with_pattern cop to not use quotesddavison2019-07-101-2/+2
| | | | | | | Using quotes within string validations can be messy. Let's use a typical CSS selector for an unquoted attribute Update the cop spec to validate appropriate new message
* Add a rubocop for Rails.loggerMayra Cabrera2019-07-101-0/+42
| | | | | | Suggests to use a JSON structured log instead Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/54102
* Add a cop to ensure we authorize GraphQL typesBob Van Landuyt2019-06-211-0/+66
|
* Merge branch 'qa-extend-click-visit-actions' into 'master'Dan Davison2019-05-281-1/+10
|\ | | | | | | | | | | | | Implement dynamic validation on QA Pages Closes gitlab-qa#280 See merge request gitlab-org/gitlab-ce!25704
| * Implement dynamic validation on QA Pagesddavison2019-05-201-1/+10
| | | | | | | | | | | | Elements now have the ability to be required on pages or not Currently using the default wait mechanism Altered the ElementWithPattern Cop to fit new splat for init
* | Link to issue in CodeReuse/ActiveRecord messagelink-to-issue-in-code-reuse-active-record-rubocop-ruleLuke Duncalfe2019-05-221-3/+3
|/ | | | | This provides the user with some context as to why certain ActiveRecord methods are blacklisted.
* Add Rubocop rule to ban include ActionView::ContextStan Hu2019-04-291-0/+45
|
* Forbid the use of `#reload` and prefer `#reset`forbid-the-usage-of-reloadKamil Trzciński2019-04-151-0/+60
| | | | | | | The `#reload` makes to load all objects into memory, and the main purpose of `#reload` is to drop the association cache. The `#reset` seems to solve exactly that case.
* Properly handle `ee` migration specsHeinrich Lee Yu2019-03-281-0/+18
|
* Fix detecting nested EE constants in RuboCopYorick Peterse2019-01-161-0/+35
| | | | | | | | The InjectEnterpriseEditionModule cop would not detect certain nested EE constants such as `EE::Foo::Bar::Baz`. This could result in it not enforcing `prepend` being placed on the last line. This commit fixes this by just performing a string match on the line, instead of relying on AST matching.
* Added Cop for injecting EE modulesYorick Peterse2018-12-131-0/+133
| | | | | | | This Cop enforces the rule that injecting EE modules (using prepend, include, or extend) is done by placing the injection on the last line of a file, instead of somewhere in the middle. By placing these lines at the very end, merge conflicts will not happen.
* Fix ActiveRecord::Migration deprecationsYorick Peterse2018-12-123-10/+10
| | | | | Extending from ActiveRecord::Migration is deprecated, but was still used in a bunch of places.
* Make add_reference cop accept a hash for :indexToon Claes2018-11-271-2/+10
| | | | | | It might happen you want to make the reference column have a unique value, or you want to create partial indexes. So instead of only accepting a `true` value, also accept a hash of options.
* Add cop prohibiting params argument in url_for47986-rubocop-safe-paramsJarka Košanová2018-11-221-0/+39
|
* Add a new QA::ElementWithPattern copRémy Coutable2018-10-152-0/+87
| | | | | | | This cop forbids the use of `element :foo, 'pattern'` and `element :bar, /pattern/` in QA files. Signed-off-by: Rémy Coutable <remy@rymai.me>
* Applies the CE backport of EE#657Tiago Botelho2018-09-241-0/+28
|
* Fix leading slash in redirects and add copSanad Liaquat2018-09-211-0/+32
|
* Added FromUnion to easily select from a UNIONYorick Peterse2018-09-171-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds the module `FromUnion`, which provides the class method `from_union`. This simplifies the process of selecting data from the result of a UNION, and reduces the likelihood of making mistakes. As a result, instead of this: union = Gitlab::SQL::Union.new([foo, bar]) Foo.from("(#{union.to_sql}) #{Foo.table_name}") We can now write this instead: Foo.from_union([foo, bar]) This commit also includes some changes to make this new setup work properly. For example, a bug in Rails 4 (https://github.com/rails/rails/issues/24193) would break the use of `from("sub-query-here").includes(:relation)` in certain cases. There was also a CI query which appeared to repeat a lot of conditions from an outer query on an inner query, which isn't necessary. Finally, we include a RuboCop cop to ensure developers use this new module, instead of using Gitlab::SQL::Union directly. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/51307
* Added RuboCop cops to enforce code reuse rulesYorick Peterse2018-09-117-0/+891
| | | | | These Cops enforces the code reuse rules as defined in merge request https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21254.
* Fix LineBreakAroundConditionalBlock cop for a conditional after rescueRobert Speicher2018-09-051-0/+16
| | | | | | | | | | | | Previously this would violate on the `if`: def a_method do_something rescue if condition do_something end end
* Minor renames for clarityJacopo2018-08-291-1/+1
|
* Handles when ClassMethods is used inside a classJacopo2018-08-291-0/+11
|
* Applies rule only when extending ActiveSupport::ConcernJacopo2018-08-291-1/+22
|
* Adds Rubocop rule to enforce class_methods over module ClassMethodsJacopo2018-08-291-0/+66
|
* Reject ruby interpolation in externalized stringsbvl-correct-interpolation-i18nBob Van Landuyt2018-08-251-0/+68
| | | | | | | | | | | | | | | | When using ruby interpolation in externalized strings, they can't be detected. Which means they will never be presented to be translated. To mix variables into translations we need to use `sprintf` instead. Instead of: _("Hello #{subject}") Use: _("Hello %{subject}) % { subject: 'world' }
* Whitelist existing destroy_all offensesblacklist-destroy-allYorick Peterse2018-08-161-3/+3
| | | | This whitelists all existing places where we use "destroy_all".
* Blacklist the use of "destroy_all"Yorick Peterse2018-08-161-0/+43
| | | | | This method usually has really bad performance implications, as it loads rows into memory and deletes them one by one.
* Add rubocop check for add_reference to require index.Andreas Brandl2018-08-081-0/+54
|
* Merge branch 'update-large-tables-cop' into 'master'Grzegorz Bizon2018-06-221-0/+20
|\ | | | | | | | | Disallow methods that copy data on large tables See merge request gitlab-org/gitlab-ce!20021
| * Disallow methods that copy data on large tablesSean McGivern2018-06-191-0/+20
| | | | | | | | | | | | {change_column_type,rename_column}_concurrently both copy data from one column to another during a migration, which should not be done on GitLab.com. Instead, we should use background migrations.
* | Add a cop for `FinderMethods`bvl-finder-methods-copBob Van Landuyt2018-06-201-0/+56
|/ | | | | | | This notifies developers when calling `find(_by!)` chained on `execute`. And suggests using the methods from `FinderMethods`. These will perform the correct authorization checks on the resource when it is found.
* Allow comment after if/unless clause46758-fallout-of-cacheable-attributeRémy Coutable2018-05-291-0/+12
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Revert the addition of goldiloaderYorick Peterse2018-04-181-74/+0
| | | | | | | | | This reverts the addition of the "goldiloader" Gem and all use of it. While this Gem is very promising it's causing a variety of problems on GitLab.com due to it eager-loading too much data in places where we don't expect/can handle this. At least for the time being this means we have to go back to manually fixing N+1 query problems, but at least those should not cause a negative impact on availability.
* Resolve "Make a Rubocop that forbids returning from a block"🙈 jacopo beschi 🙉2018-04-182-0/+201
|