summaryrefslogtreecommitdiff
path: root/rubocop
Commit message (Collapse)AuthorAgeFilesLines
* Change element_with_pattern cop to not use quotesddavison2019-07-101-1/+1
| | | | | | | 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
* Introduce data-qa-selector to supplant .qa-classddavison2019-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | | In order to break away from using CSS classes as our primary method of element identification, we need to provide the ability to search for data attributes. Make Test::Sanity::Selectors now work Utilize regex to match on literal strings of the element name Suggest the data-qa-selector pattern vs the qa- Add data-qa-selector to login page to start We need a page that is heavily used in order to be confident that this functionality works. Let's start with the Login page Use appropriate HAML data tag practices
* Add a rubocop for Rails.loggerMayra Cabrera2019-07-102-0/+52
| | | | | | 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-212-0/+62
|
* Merge branch 'qa-extend-click-visit-actions' into 'master'Dan Davison2019-05-281-7/+13
|\ | | | | | | | | | | | | 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-7/+13
| | | | | | | | | | | | 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-1/+2
|/ | | | | This provides the user with some context as to why certain ActiveRecord methods are blacklisted.
* Run rubocop -a on CE filessh-upgrade-rubocop-0.68.0-ceStan Hu2019-05-051-1/+0
|
* Upgrade to Rubocop 0.68.1Stan Hu2019-05-051-2/+2
| | | | This adds Ruby 2.6 support.
* Cache current working directory to speed up Rubocopsh-cache-rubocop-cwdStan Hu2019-05-032-3/+5
| | | | | | | This saves thousands of getcwd() system calls and improves the performance of running Rubocop, which is also used by HAML linting. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/61383
* Add Rubocop rule to ban include ActionView::ContextStan Hu2019-04-292-0/+32
|
* Forbid the use of `#reload` and prefer `#reset`forbid-the-usage-of-reloadKamil Trzciński2019-04-152-0/+22
| | | | | | | 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-1/+1
|
* Merge branch 'fix-rubocop-ee-module-injection-detection' into 'master'Rémy Coutable2019-01-161-3/+7
|\ | | | | | | | | Fix detecting nested EE constants in RuboCop See merge request gitlab-org/gitlab-ce!24430
| * Fix detecting nested EE constants in RuboCopYorick Peterse2019-01-161-3/+7
| | | | | | | | | | | | | | | | 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.
* | Prevent factories in background migration specsBob Van Landuyt2019-01-161-3/+8
|/ | | | | The Background migration specs also run against a certain version of the database. So we should avoid using factories.
* Added Cop for injecting EE modulesYorick Peterse2018-12-132-0/+48
| | | | | | | 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.
* Make add_reference cop accept a hash for :indexToon Claes2018-11-271-2/+7
| | | | | | 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-222-0/+35
|
* Whitelist none method from ActiveRecord::Queryingda-rubocop-whitelist-active-record-noneDouglas Barbosa Alexandre2018-10-311-1/+0
|
* Add a new QA::ElementWithPattern copRémy Coutable2018-10-153-0/+51
| | | | | | | 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-242-0/+23
|
* Fix leading slash in redirects and add copSanad Liaquat2018-09-212-0/+53
|
* Remove unused constantbvl-remove-unused-regexBob Van Landuyt2018-09-191-1/+0
| | | | | | This removes an unused constant from the `RubyInterpolationInTranslation`. The constant was used in a first implementation of this class.
* Added FromUnion to easily select from a UNIONYorick Peterse2018-09-172-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-118-0/+548
| | | | | 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-1/+6
| | | | | | | | | | | | 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-2/+2
|
* Handles when ClassMethods is used inside a classJacopo2018-08-291-2/+4
|
* Fixes rubocop chain ordinary method after safe navigation operatorJacopo2018-08-291-2/+5
|
* Applies rule only when extending ActiveSupport::ConcernJacopo2018-08-291-2/+22
|
* Adds Rubocop rule to enforce class_methods over module ClassMethodsJacopo2018-08-292-0/+49
|
* Reject ruby interpolation in externalized stringsbvl-correct-interpolation-i18nBob Van Landuyt2018-08-253-0/+36
| | | | | | | | | | | | | | | | 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' }
* Blacklist the use of "destroy_all"Yorick Peterse2018-08-162-0/+23
| | | | | 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-082-0/+50
|
* Update rubocop to get rid of a warning in other MRLin Jen-Shin2018-07-091-0/+2
|
* Merge branch 'update-large-tables-cop' into 'master'Grzegorz Bizon2018-06-221-2/+13
|\ | | | | | | | | Disallow methods that copy data on large tables See merge request gitlab-org/gitlab-ce!20021
| * Add more large tables to copupdate-large-tables-copSean McGivern2018-06-221-1/+5
| | | | | | | | | | These are all over 20 GB on GitLab.com. merge_request_diff_commits is several hundred gigabytes in size.
| * Disallow methods that copy data on large tablesSean McGivern2018-06-191-1/+8
| | | | | | | | | | | | {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-202-0/+53
|/ | | | | | | 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-1/+1
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Introduce spec/fast_spec_helper.rb to run spec files that don't rely on the ↵Rémy Coutable2018-04-231-1/+1
| | | | | | whole Rails env Signed-off-by: Rémy Coutable <remy@rymai.me>
* Revert the addition of goldiloaderYorick Peterse2018-04-182-47/+1
| | | | | | | | | 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-184-2/+129
|
* Add cop for has_many :through without disabled autoloadingfix-n-plus-one-when-getting-notification-settings-for-recipientsSean McGivern2018-04-092-1/+47
| | | | | | | | | | | | | Goldiloader is great, but has several issues with has_many :through relations: * https://github.com/salsify/goldiloader/issues/12 * https://github.com/salsify/goldiloader/issues/14 * https://github.com/salsify/goldiloader/issues/18 Rather than try to figure out which applies in each case, we should just do the drudge work of manually disabling autoloading for all relations of this type. We can always use regular preloading for specific cases, but this way we avoid generating invalid queries through Goldiloader's magic.
* Introduce a new FactoriesInMigrationSpecs copRémy Coutable2018-04-063-1/+53
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Merge branch 'fj-15329-services-callbacks-ssrf' into 'security-10-6'Douwe Maan2018-03-212-0/+63
| | | | | Server Side Request Forgery in Services and Web Hooks See merge request gitlab/gitlabhq!2337
* [CE] Add Naming/FileName rule checking expected class/module per filenameGabriel Mazetto2018-03-081-0/+1
|
* Enable RuboCop Style/RegexpLiteralTakuya Noguchi2018-02-011-1/+1
|
* Introduce PredicateMemoization cop and fix offensesLin Jen-Shin2018-01-122-0/+40
| | | | with StrongMemoize